- Overview
- Architecture
- Project Structure
- Features
- Setup
- Run with Streamlit Application
- Usage
- Technical Implementation
This project implements a web-based image encryption system using cryptographically secure Linear Feedback Shift Register (LFSR) techniques. Users can upload images, configure encryption parameters, and receive encrypted and decrypted versions in real-time.
The project follows a client-server architecture with:
- A core encryption/decryption module
- Backend API (FastAPI): Handles encryption/decryption operations
- Frontend UI (Streamlit): Provides user interface for image upload and parameter configuration
LFSR_Image_Encryption_System/
│
├── LFSR_Encryption.py # Core encryption & decryption logic
│
├── backend/
│ └── app.py # FastAPI application
│
├── frontend/
│ └── app.py # Streamlit application
│
├── test_images/
│ ├── lena.jpg
│ ├── test2.jpg
│ └── test5.jpg
│
├── notebook/ # Jupyter notebook
│ └── LFSR_Encryption.ipynb
│
└── README.md # Project documentation
- LFSR-based encryption: Implements confusion and diffusion principles for strong image encryption
- Configurable parameters: Adjustable seed values and tap positions for different security levels
- Interactive web interface: User-friendly Streamlit frontend
- Real-time processing: Immediate encryption/decryption visualization
- Downloadable results: Save encrypted and decrypted images
-
Clone the Repository
git clone https://github.com/Abdelrahman-Elshahed/LFSR_Image_Encryption_Project.git
-
Create and activate a virtual environment:
python -m venv venv source venv/bin/activate # On Windows use: venv\Scripts\activate
-
Set up dependencies
Install Python dependencies: To install all the required Python packages for the project, run the following command:
pip install -r requirements.txt
- Start the backend server:
cd backend uvicorn app:app --reload --port 8000
- Start the frontend (in a new terminal):
cd frontend streamlit run app.py
- The application will be available at http://localhost:8501.
- Upload an image using the file uploader in the left column
- Configure encryption parameters:
- Seed Value: Initial state for the LFSR (hexadecimal format)
- Tap Positions: Comma-separated positions for LFSR feedback
- Click "Process Image" to encrypt and decrypt
- View the encrypted and decrypted images
- Download results using the download buttons
- Recommended Parameters Seed Values:
- 16-bit LFSR: 0xACE1
- 32-bit LFSR: 0xB7E15163
- 64-bit LFSR: 0x3A7D95C2F168B4E0
Tap Positions:
- 16-bit LFSR: 16,15,13,4
- 32-bit LFSR: 32,22,2,1
- 64-bit LFSR: 64,63,61,60
- Confusion Layer:
- Generates a keystream using LFSR
- Applies XOR operation between image pixels and keystream
- Diffusion Layer:
- Permutes pixel positions using Fisher-Yates shuffle
- Uses LFSR values for randomization
- Reverse Diffusion:
- Applies inverse permutation using stored indices
- Reverse Confusion:
- Applies XOR with the same keystream (XOR is its own inverse)