A simple and educational Python implementation of the RSA public-key cryptography algorithm.
This project demonstrates RSA key generation, encryption, and decryption using basic number theory concepts.
It is created as a learning and academic project to understand how public-key cryptography works internally, not as a production-ready security system.
rsa-algorithm-python/
│
├── app.py # Clean CLI Version
├── interactive.py # Rich CLI Version
├── requirements.txt # Project Dependancies
├── LICENSE # Project license
└── README.md # Project documentation- Accepts two prime numbers as input
- Computes modulus (n) and Euler’s Totient (φ)
- Automatically selects a valid public exponent (e)
- Computes private exponent (d) using modular inverse
- Encrypts a numeric message using the public key
- Uses efficient modular exponentiation
- Decrypts the encrypted message using the private key
- Verifies correctness of the RSA algorithm flow
- Clear, readable logic
- Minimal dependencies
- Ideal for students and beginners in cryptography
- Colored terminal output
- Structured key display tables
- Styled panels for encryption/decryption results
- Better user experience and readability
- 🧼 Basic CLI → Lightweight, no dependencies
- 🎨 Rich CLI → Enhanced UI with colors and panels
| Technology | Role |
|---|---|
| Python 3 | Core programming language |
| math.gcd | Valid public key selection |
| Rich | Interactive CLI interface |
| Modular Arithmetic | RSA operations |
This project is built to:
- Understand RSA public-key cryptography
- Learn Euler’s Totient function
- Practice modular arithmetic
- Demonstrate encryption and decryption flow
- Strengthen fundamentals of computer security
⚠️ This project is intended strictly for learning and demonstration purposes.
git clone https://github.com/ShakalBhau0001/rsa-algorithm-python.gitcd rsa-algorithm-pythonpip install richOR
pip install -r requirements.txtpython app.pypython interactive.py- Enter two prime numbers
- Enter a numeric message smaller than
n - View generated keys, encrypted message, and decrypted output
- Uses small prime numbers (not secure)
- No prime number validation
- No padding schemes (e.g., OAEP)
- CLI-based interaction only
- Not suitable for real-world cryptographic use
- Add prime number validation
- Support larger primes
- Implement padding schemes
- Add file encryption support
- Support text message encryption
- Export generated keys to files
- Support larger key sizes
This implementation is created for educational and learning purposes only. It does not provide real-world cryptographic security and must not be used in production systems or for protecting sensitive data.
Developer: Shakal Bhau
GitHub: ShakalBhau0001
If you like this project, consider giving it a ⭐ on GitHub!
