This project implements a real-time video encryption system using the ChaCha20 stream cipher. The system captures video from a webcam on a Raspberry Pi, encrypts each frame using ChaCha20 encryption, and transmits the encrypted data over a network to a receiving computer for decryption and display.
This project demonstrates:
- Real-time cryptographic operations on video data
- Stream cipher implementation using ChaCha20
- Network programming with socket communication
- Performance optimization for real-time video processing
- Cryptographic key management and nonce generation
- Cross-platform development (Raspberry Pi to PC communication)
- Sender (Raspberry Pi): Captures video, encrypts frames, sends over network
- Receiver (PC): Receives encrypted data, decrypts frames, displays video
- ChaCha20 Stream Cipher: Uses 32-byte key and 16-byte nonce per frame
- Real-time Processing: Optimized for live video streaming
- Performance Monitoring: Tracks encryption/transmission times and FPS
- Frame-by-frame Encryption: Each frame uses a unique nonce for security
- Automatic File Management: Saves encrypted frames and decrypted images
- Unique Nonce per Frame: Prevents replay attacks and ensures frame uniqueness
- Secure Key Management: 32-byte ChaCha20 key for strong encryption
- Frame Integrity: Maintains video quality while ensuring confidentiality
chacha20-video-encryption/
├── src/
│ ├── sender.py # Raspberry Pi video capture and encryption
│ └── receiver.py # PC video decryption and display
├── video_link.txt # Demonstration video links
└── README.md # This file
- Python 3.8+
- Project Python packages are listed in
requirements.txt:opencv-python- Video capture and processingcryptography- ChaCha20 encryption implementationnumpy- Array operations for image data
Install dependencies using requirements.txt (recommended to use a virtual environment):
pip install -r requirements.txt- Update IP addresses in both
sender.pyandreceiver.py - Ensure both devices are on the same network
- Configure camera settings (resolution, frame rate) as needed
-
Start the receiver (PC):
python src/receiver.py
-
Start the sender (Raspberry Pi):
python src/sender.py
- 'q' key: Quit the application
- Frame limit: Set to 100 frames by default (configurable)
The system tracks and displays:
- Encryption time per frame
- Transmission time per frame
- FPS (Frames Per Second) calculation
- Total processing time for performance analysis
Click the image above to watch the full demonstration
The video shows:
- Real-time video encryption and decryption
- Performance metrics and system operation
- Cross-platform communication between Raspberry Pi and PC
- Live encryption/transmission timing measurements
- Encryption Algorithm: ChaCha20 stream cipher
- Key Size: 32 bytes (256 bits)
- Nonce Size: 16 bytes (128 bits)
- Video Resolution: 640x480 (configurable)
- Network Protocol: TCP socket communication
- Port: 8080 (configurable)
- Forward Secrecy: Each frame uses a unique nonce
- Key Management: Secure key distribution assumed
- Network Security: Implement additional TLS/SSL for production use
- Nonce Generation: Uses cryptographically secure random generation
- Key Exchange Protocol: Implement secure key distribution
- Compression: Add video compression before encryption
- Error Handling: Improve network error recovery
- GUI Interface: Add user-friendly interface
- Multi-client Support: Support multiple receivers
This project serves as an excellent learning tool for:
- Understanding stream ciphers and their applications
- Real-time cryptographic system design
- Network programming and socket communication
- Performance optimization in cryptographic applications
- Cross-platform development and deployment
This project is part of ECE4301 coursework and is intended for educational purposes.
https://www.youtube.com/watch?v=ZtI_uvnqqgs
