A versatile, interactive command-line tool built in Python for encrypting and decrypting text using a variety of standard cryptographic algorithms. This tool serves as a practical demonstration of symmetric (AES, DES) and asymmetric (RSA) encryption within a single, easy-to-use interface.
- Multiple Algorithms: Supports three widely recognized encryption standards:
- AES (Advanced Encryption Standard): A modern, secure symmetric algorithm.
- DES (Data Encryption Standard): A legacy symmetric algorithm (specifically TripleDES).
- RSA: A powerful asymmetric (public-key) algorithm.
 
- Flexible Key Management:
- Symmetric Keys (AES/DES):
- Generate cryptographically secure random keys.
- Derive fixed-length keys from any user-provided password or phrase using a SHA-256 hash function.
 
- Asymmetric Keys (RSA):
- Automatically generates a 2048-bit RSA public/private key pair for the duration of the session.
 
 
- Symmetric Keys (AES/DES):
- Interactive CLI: A user-friendly menu-driven interface guides you through the process of encryption and decryption.
- In-Session Key Memory: The tool remembers the last-used AES/DES key and the session's RSA key pair, simplifying the process of encrypting and then immediately decrypting a message.
This tool demonstrates two fundamental types of cryptography:
In symmetric encryption, the same key is used for both encrypting and decrypting the data.
- Key Generation: You can either have the system generate a random binary key or provide your own password. The user-provided password is not used directly; instead, it's hashed using SHA-256 to produce a secure, fixed-length key suitable for the chosen algorithm (32 bytes for AES, 8 bytes for DES).
- Encryption: The plaintext is encrypted using the key and an initialization vector (IV) in CBC (Cipher Block Chaining) mode. The IV ensures that encrypting the same text multiple times produces different ciphertexts.
- Decryption: The ciphertext can only be decrypted back to the original plaintext using the exact same key that was used for encryption.
Asymmetric encryption uses a key pair: a public key and a private key.
- Key Generation: The first time you use RSA in a session, the tool generates a new public/private key pair.
- Encryption: Text is encrypted using the public key. The public key can be shared freely without compromising security.
- Decryption: The resulting ciphertext can only be decrypted using the corresponding private key. This private key must be kept secret. In this tool, the private key is held in memory for the session to allow for decryption.
- Python 3.7+
- cryptographylibrary
- 
Clone the repository: git clone [https://github.com/your-username/Multi-Algorithm-Text-Encryptor.git](https://github.com/your-username/Multi-Algorithm-Text-Encryptor.git) cd Multi-Algorithm-Text-Encryptor
- 
Set up a virtual environment (recommended): python -m venv venv source venv/bin/activate # On Windows, use: venv\Scripts\activate 
- 
Install the required package: pip install -r requirements.txt 
Run the script from your terminal:
python text_encryption.pyYou will be presented with a menu. Follow the on-screen prompts to select an action (encrypt/decrypt) and an algorithm.
Text Encryption System
1. Encrypt
2. Decrypt
3. Exit
Select an option (1-3): 1
Encryption Algorithms
1. AES Encryption
2. DES Encryption
3. RSA Encryption
Select an algorithm (1-3): 1
Enter text to encrypt: This is a secret message.
Use system-generated key? (y/n): n
Enter your key (any length or type): mySuperSecretPassword
Derived AES Key (base64): GSc+u4vCft2E7t4p17yR1g6pGLs/j7PZl3PEYRk3SGE=
Encrypted: fT4i2jP5hG88jY3kLq9wR... (example output)
Text Encryption System
...
Select an option (1-3): 2
Decryption Algorithms
1. AES Decryption
...
Select an algorithm (1-3): 1
Enter ciphertext to decrypt (base64): fT4i2jP5hG88jY3kLq9wR...
Use the key from last AES encryption? (y/n): n
Enter your key (any length or type): mySuperSecretPassword
Derived AES Key (base64): GSc+u4vCft2E7t4p17yR1g6pGLs/j7PZl3PEYRk3SGE=
Decrypted: This is a secret message.
- Educational Purpose: This tool is intended for educational purposes to demonstrate how different cryptographic algorithms work. It is not recommended for securing sensitive production data without further auditing and robust key management practices.
- Key Management:
- For AES/DES, if you use a derived key, you must remember the exact password to decrypt your data. Losing the password means the data is permanently lost.
- The RSA key pair is ephemeral, meaning it only exists for the current session. You cannot decrypt a message in a new session, as the private key will be gone.
 
- Algorithm Strength: TripleDESis a legacy algorithm and is considered much weaker than modern standards likeAES-256. Use AES for any serious application.
This repository includes a launch.json file in the .vscode directory for easy debugging in Visual Studio Code. You can use the "Python Debugger: Current File" configuration to run and debug the script.
This project is licensed under the MIT License - see the LICENSE file for details.