A comprehensive encryption service featuring a FastAPI backend and React frontend, supporting multiple encryption algorithms including AES-128, AES-256, Blowfish, and RSA. The service provides a modern web interface for file encryption with real-time processing and secure file downloads.
- RESTful API for file encryption/decryption
- File upload support with multipart/form-data handling
- Multiple encryption algorithms: AES-128, AES-256, Blowfish, RSA
- Key generation endpoint with cryptographically secure random keys
- File download system for encrypted files
- CORS enabled for frontend communication
- Swagger UI documentation at
/docs - Health check endpoint for service monitoring
- Modern, responsive web interface with Material UI components
- File upload with drag-and-drop functionality
- Real-time encryption status and progress feedback
- Download encrypted files directly from the browser
- Key generation interface with algorithm selection
- Multi-page navigation: Encrypt, Decrypt, Key Generation, Health Check
- API documentation access via integrated link
- Python 3.10+
- Node.js 16+ and npm/yarn
- Docker (optional, for containerized deployment)
# Start the backend service
docker-compose up --build -d
# Install and start frontend
cd frontend
npm install
npm run dev- Create a virtual environment:
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies:
pip install -r requirements.txt- Start the backend server:
uvicorn main:app --reload --host 0.0.0.0 --port 8000- Navigate to frontend directory:
cd frontend- Install dependencies:
npm install- Start the development server:
npm run dev- Open your browser:
- Frontend: http://localhost:5173
- Backend API: http://localhost:8000
- API Documentation: http://localhost:8000/docs
| Method | Endpoint | Description |
|---|---|---|
GET |
/ |
Welcome message and endpoint overview |
POST |
/encrypt |
Encrypt a file (multipart/form-data) |
POST |
/api/encrypt |
Alternative encrypt endpoint |
POST |
/decrypt |
Decrypt a file (not yet implemented) |
GET |
/generate-key |
Generate encryption key |
GET |
/health |
Health check endpoint |
GET |
/download/{temp_id}/{filename} |
Download encrypted files |
GET |
/docs |
Swagger UI Documentation |
curl -X POST "http://localhost:8000/encrypt" \
-F "file=@your-file.txt" \
-F "algorithm=aes256" \
-F "key=your-encryption-key"| Algorithm | Key Size | Type | Description |
|---|---|---|---|
| AES-128 | 128-bit | Symmetric | Advanced Encryption Standard |
| AES-256 | 256-bit | Symmetric | Advanced Encryption Standard (stronger) |
| Blowfish | Variable | Symmetric | Fast block cipher with variable key length |
| RSA | 2048-bit+ | Asymmetric | Public-key cryptography |
├── main.py # FastAPI backend server
├── requirements.txt # Python dependencies
├── Dockerfile # Docker configuration
├── docker-compose.yml # Docker Compose setup
├── test_encryption_simple.py # Test script
├── .gitignore # Git ignore rules
├── Process/ # Encryption algorithm implementations
│ ├── Symmetric_algo/ # Symmetric encryption algorithms
│ │ ├── Encryption_algo/ # Encryption implementations
│ │ │ ├── aes128.py # AES-128 encryption
│ │ │ ├── aes256.py # AES-256 encryption
│ │ │ └── blowfish.py # Blowfish encryption
│ │ └── Decryption_algo/ # Decryption implementations
│ │ ├── aes128_dec.py # AES-128 decryption
│ │ ├── aes256_dec.py # AES-256 decryption
│ │ └── blowfish_dec.py # Blowfish decryption
│ └── Asymmetric_algo/ # Asymmetric encryption algorithms
│ ├── Encryption/ # RSA encryption
│ │ └── rsa/
│ │ └── rsa.py
│ └── Decryption/ # RSA decryption
│ └── rsa/
│ └── rsa_dec.py
└── frontend/ # React frontend application
├── package.json # Node.js dependencies
├── vite.config.js # Vite configuration with proxy
├── index.html # HTML entry point
└── src/ # React source code
├── App.jsx # Main application component
├── main.jsx # React entry point
└── pages/ # Page components
├── EncryptPage.jsx # File encryption interface
├── DecryptPage.jsx # File decryption interface
├── KeyGenPage.jsx # Key generation interface
└── HealthPage.jsx # Health check interface
- FastAPI[all] 0.109.0 - Modern web framework
- uvicorn 0.27.0 - ASGI server
- python-multipart 0.0.9 - File upload support
- cryptography 42.0.2 - Cryptographic operations
- pydantic 2.6.1 - Data validation
- python-jose[cryptography] 3.3.0 - JWT handling
- passlib[bcrypt] 1.7.4 - Password hashing
- React 18.2.0 - UI framework
- Material UI 5.14.0 - Component library
- Axios 1.6.0 - HTTP client
- Vite 4.4.0 - Build tool and dev server
Run the encryption test to verify functionality:
python test_encryption_simple.pyThe project includes Docker support with:
- Multi-stage build for optimized production images
- Volume mounts for development
- Environment variables for configuration
- Port mapping (8000:8000) for API access
- Strong key generation using cryptographically secure random number generation
- Secure file handling with temporary file cleanup
- CORS configuration for controlled frontend access
- Input validation for all API endpoints
- Secure key derivation using SHA-256 hashing
- Frontend uses Vite proxy to handle API requests during development
- Backend supports hot reload with uvicorn's
--reloadflag - CORS middleware configured for development (restrict origins in production)
- Temporary file management for secure file processing
-
"Encryption failed" error:
- Ensure both backend and frontend are running
- Check that the backend is accessible at
http://localhost:8000 - Verify file upload size limits
-
CORS errors:
- Backend includes CORS middleware configuration
- Frontend proxy is configured in
vite.config.js
-
Module not found errors:
- Install Python dependencies:
pip install -r requirements.txt - Install Node.js dependencies:
npm install - Use Docker setup for isolated environment
- Install Python dependencies:
-
Port conflicts:
- Backend runs on port 8000
- Frontend runs on port 5173
- Ensure these ports are available
-
Frontend black screen or reload issues:
- If you see a black screen on
http://localhost:5173/, check the browser console for errors. - Make sure you do not have invalid React code (e.g., hooks outside components).
- If you reload and get a 404, ensure your Vite config and deployment support client-side routing (see Vite docs for SPA fallback).
- For production, use a proper static file server or configure your backend to serve the frontend's
index.htmlfor unknown routes.
- If you see a black screen on
-
File download 404 or not found:
- Ensure the backend is returning a valid download URL and the file exists on the server.
- The frontend should use the backend's
/download/...endpoint, not try to serve files directly.
-
Deprecation warnings (Node.js):
- These are usually safe to ignore for development, but keep dependencies up to date.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is open source. Please specify your license terms.
This project is designed for educational and development purposes. Always follow security best practices and conduct thorough testing before using in production environments. Ensure proper key management and secure storage of sensitive data.