A command-line Python tool for learning and applying standard cryptographic algorithms: AES, RSA, and Hybrid (RSA + AES) encryption.
Symmetric encryption using AES-256-GCM. A single secret key is used to both encrypt and decrypt files. Fast and suitable for files of any size.
Asymmetric encryption using a 2048-bit RSA key pair. The public key encrypts data and the private key decrypts it. Limited to small data (up to 190 bytes) due to RSA's block size constraint.
Combines both algorithms. A random AES key encrypts the file, and the RSA public key encrypts that AES key. The recipient uses their RSA private key to recover the AES key and decrypt the file. Supports files of any size.
Encryption-Decryption-Tool/
├── app.py # Main CLI entry point
├── aes_handle.py # AES key generation, file encryption/decryption
├── rsa_handle.py # RSA key generation, data encryption/decryption
├── hybrid_handle.py # Hybrid (RSA + AES) file encryption/decryption
├── test_rsa.py # Automated unit tests for the RSA module
├── requirements.txt # Python dependencies
└── Dockerfile # Docker container setup
- Python 3.11+
cryptography >= 42.0.5
Install dependencies:
pip install -r requirements.txtRun the tool:
python app.pyA menu will prompt you to choose an algorithm and operation. Follow the on-screen instructions to generate keys, encrypt, or decrypt.
- Select AES from the main menu.
- Generate a key (saved as
.keyfile). - Encrypt a file (output:
<filename>.enc). - Decrypt a file (output:
<filename>.dec).
- Select RSA from the main menu.
- Generate a key pair (saved as
private_key.pemandpublic_key.pem). - Encrypt text using the public key (output saved as a
.binfile). - Decrypt using the private key.
- Select Hybrid (RSA + AES) from the main menu.
- Provide the file to encrypt and the RSA public key path.
- Output is saved as
<filename>.henc. - Decrypt using the RSA private key to recover the original file (output:
<filename>.hdec).
Build the image:
docker build -t encryption-tool .Run interactively:
docker run -it --rm -v "${PWD}:/data" encryption-toolpython -m unittest test_rsa -vKeep your .key and .pem files secure and do not commit them to version control. Add the following to your .gitignore:
*.key
*.pem
*.enc
*.henc
*.dec
*.hdec
*.bin