Built with Python, Flask, and Cryptography Library
- Overview
- Key Features
- Cryptography Implementation
- Tech Stack
- Project Structure
- Getting Started
- Benchmark Module
- License
This project is a secure web application developed for the FARO Assignment 2. It implements a Hybrid Encryption Scheme to secure file uploads and facilitate secure file sharing between two distinct user roles: Organizations (File Owners) and Consultants (Access Requesters).
Additionally, the application includes a Cryptography Benchmark Module that evaluates and compares the performance of symmetric encryption algorithms (AES, 3DES, RC4) in real-time.
- Secure Authentication: User registration and login with hashed passwords (
bcrypt). - Role-Based Access Control (RBAC):
- Organization: Can upload files, view requests, and approve access.
- Consultant: Can view available files, request access, and download shared files.
- Secure File Storage: Files are encrypted upon upload using AES-GCM.
- Hybrid Key Management:
- AES Keys are encrypted using the owner's RSA Public Key and stored in SQLite.
- RSA Private Keys are encrypted with the user's password and stored in a simulated NoSQL store (
JSON).
- Secure File Sharing:
- Implements a secure key exchange mechanism.
- When a request is approved, the file's AES key is decrypted and re-encrypted with the Consultant's Public Key.
- Crypto Benchmarking: Built-in tool to measure encryption/decryption speed and ciphertext size.
The system uses the cryptography Python library to implement the following standards:
- Symmetric Encryption (File Data):
- Algorithm:
AES-256-GCM - Purpose: High-speed encryption of large files.
- Algorithm:
- Asymmetric Encryption (Key Exchange):
- Algorithm:
RSA(2048-bit) - Padding:
OAEPwithSHA-256 - Purpose: Securing the symmetric keys for storage and sharing.
- Algorithm:
- Key Storage:
- Public Keys: Stored plainly in the SQL Database.
- Private Keys: Encrypted (AES) via user password and stored in a JSON file (Simulating NoSQL).
- Backend: Python 3.x, Flask
- Database: SQLite (Relational), JSON (Simulated NoSQL for Keys)
- Security:
cryptography(hazmat primitives),flask-bcrypt - Frontend: HTML5, CSS3 (Bootstrap)
- ORM: Flask-SQLAlchemy
FARO-Assignment-2-Private/
├── app.py # Main application logic & routes
├── requirements.txt # Python dependencies
├── instance/
│ ├── app.db # SQLite Database (Users, File Metadata)
│ └── keystore/
│ └── private_keys.json # Simulated NoSQL for Encrypted Private Keys
├── uploads/ # Encrypted file storage
├── templates/ # HTML Templates (Login, Dashboard, Benchmark, etc.)
└── static/ # CSS, Images, Profile Pics- Python 3.8 or higher
- pip (Python Package Installer)
git clone https://github.com/qyqystilllearning/FARO-Assignment-2-Private.git
cd FARO-Assignment-2-Privatepython -m venv venv
# Windows
venv\Scripts\activate
# Mac/Linux
source venv/bin/activatepip install -r requirements.txtpython app.pyThe app will run on http://127.0.0.1:8888 (debug mode enabled).
- Register a new account (Select Role: Organization).
- Upload a file (it will be auto-encrypted).
- Register another account (Select Role: Consultant).
- Request access to the organization's file.
- Log back in as Organization to approve the request (requires password for key decryption).
- Log back in as Consultant to download and decrypt the file.
The project includes a benchmarking feature accessible via the file dashboard. It compares the following algorithms on the uploaded file:
| Algorithm | Mode | Key Size | Metric Measured |
|---|---|---|---|
| AES | CTR | 256-bit | Speed (ms) & Size |
| 3DES | CBC | 192-bit | Speed (ms) & Size |
| RC4 | Stream | 128-bit | Speed (ms) & Size |
Note: Results are cached in the database to avoid redundant processing.