A comprehensive Python-based cryptography toolkit implementing various classical and modern encryption algorithms, cryptanalysis techniques, and key exchange protocols.
Author:Abood Al Hajjaj - @alhajjajabood,Mohammad Nakhleh - @Moevo
Date: December 2025
This project is a complete cryptography suite that allows users to:
- Encrypt and decrypt messages using various ciphers
- Perform cryptanalysis through brute force and frequency analysis
- Generate cryptographic keys for asymmetric algorithms
- Simulate attacks like MITM (Man-in-the-Middle) on key exchange protocols
- Caesar Cipher - Simple substitution cipher
- Multiplicative Cipher - Affine cipher without addition
- Affine Cipher - Combination of multiplicative and Caesar ciphers
- Playfair Cipher - Digraph substitution cipher
- Hill Cipher - Polygraphic substitution using linear algebra
- DES (Data Encryption Standard) - Block cipher with Feistel structure
- AES (Advanced Encryption Standard) - Modern block cipher
- RSA - Public-key cryptosystem
- Diffie-Hellman Key Exchange (DHKE) - Secure key exchange protocol
- ElGamal Encryption - Public-key cryptosystem based on discrete logarithms
- Brute Force Attacks - Exhaustive key search
- Frequency Analysis - Statistical analysis of ciphertext
- Known Attacks - BSGS (Baby-Step Giant-Step), Pollard's p-1, etc.
- Interactive Menu System - Easy navigation through different algorithms
- Educational Focus - Shows step-by-step encryption/decryption processes
- Attack Simulations - Demonstrates real cryptographic attacks
- File Output - Saves analysis results to text files
- Error Handling - Validates inputs and prevents common mistakes
The main file cryptography.py contains:
- Algorithm implementations (37 different tasks/functions)
- Menu system for user interaction
- Helper functions for common operations
- Python 3.x
- No external dependencies required (uses only built-in Python libraries)
python cryptography.py- Run the script to see the main menu
- Select a cipher category (1-10)
- Choose specific operation within that category
- Follow prompts to input text, keys, and parameters
- View results and choose next action
- Caesar Cipher - Basic shift cipher operations
- Multiplicative Cipher - Multiplication-based encryption
- Affine Cipher - Combined multiplication and addition
- Playfair Cipher - Matrix-based digraph cipher
- Hill Cipher - Linear algebra-based encryption
- DES - Classic 64-bit block cipher
- AES - Modern 128-bit block cipher
- RSA - Public-key encryption and attacks
- DHKE - Key exchange protocol
- ElGamal - Discrete logarithm-based encryption
- These implementations are simplified for learning
- DO NOT USE for securing real-world sensitive data
- Real cryptographic applications require professionally vetted libraries
- DES uses 64-bit keys (obsolete for real security)
- AES implementation is simplified for education
- RSA uses small keys suitable for demonstration only
1. Select "Caesar Cipher" from main menu
2. Choose "Encryption"
3. Enter plaintext: "HELLO"
4. Enter key: 3
5. Output: "KHOOR"
1. Select "Caesar Cipher"
2. Choose "Frequency Attack"
3. Enter ciphertext
4. View all possible decryptions ranked by likelihood
1. Select "RSA"
2. Choose "Key Generation"
3. Enter prime numbers p and q
4. Get public key (e, n) and private key (d, n)
This project is ideal for:
- Computer science students learning cryptography
- Understanding how different encryption algorithms work
- Visualizing cryptographic attacks in action
- Comparing classical vs. modern encryption techniques
The tool generates several analysis files:
all_candidates.txt- Hill cipher brute force resultsplayfaier_brutN!_attack.txt- Playfair exhaustive key searchhill_cipher_attack_results_*.txt- Frequency analysis resultsplayfair_results_*.txt- Playfair cryptanalysis
This is primarily an educational project, but suggestions for:
- Code improvements
- Additional algorithms
- Better documentation
- Bug fixes
are always welcome.
To better understand these algorithms:
- "Cryptography and Network Security" by William Stallings
- "The Code Book" by Simon Singh
- Coursera/edX cryptography courses
- Cryptopals challenges
This project is completely free to:
- Use for educational and personal purposes
- Modify and customize for your needs
- Upgrade with new features and algorithms
- Share with others for learning
You are encouraged to:
- Add new cryptographic algorithms
- Improve existing implementations
- Create better user interfaces
- Fix bugs and optimize performance
- Translate to other programming languages
- Use as a teaching tool in classrooms
No permission required - feel free to fork, modify, and enhance this project!
Remember: Real-world cryptography requires expert implementation, proper key management, and continuous security assessment. This tool demonstrates concepts but doesn't replace professional cryptographic libraries.
Happy learning! π