project / 07Cryptography
File Encryption Tool
A small Flask app that encrypts uploaded files with AES-256-CBC and decrypts them on download.
View source updated
- Stack
- Python
- Flask
- PyCryptodome
- AES-256
Overview
Files uploaded through the web form are encrypted with AES-256 in CBC mode (PyCryptodome) using a random IV per file, stored under a UUID-prefixed name, and decrypted when downloaded.
Implementation
- A 32-byte key is generated once with a cryptographically secure random source and stored in a key file.
- Each encryption creates a new CBC cipher; the IV is prepended to the ciphertext so decryption can recover it.
- Decryption splits the IV from the ciphertext, decrypts and removes padding before returning the file.
Key features
- AES-256-CBC with a fresh random IV prepended to each file
- PKCS#7 padding
- UUID-prefixed filenames to avoid collisions
Security concepts
- Symmetric encryption
- Initialisation vectors
- Key handling