A Streamlit-based interactive application that demonstrates how prime numbers form the backbone of modern cryptography.
The web app allows you to generate large primes, compare primality testing algorithms (AKS vs Miller–Rabin), and simulate RSA encryption & decryption.
- Uses the Sieve of Eratosthenes to generate all primes up to a given limit.
- Performs Miller–Rabin probabilistic testing to verify large primes.
- Supports:
- Single-number testing
- Range-based prime searching
- Random number testing
- Stores all probable primes in memory for later use (in RSA).
- Compare execution times between deterministic (AKS) and probabilistic (Miller–Rabin) primality tests.
- Visual bar chart showing performance differences.
- Adjustable repetitions for accurate timing averages.
- Demonstrates real-world usage of generated primes in RSA cryptography.
- Select any two stored primes (or auto-select) to generate RSA keys.
- Displays:
- Public key
(e, n) - Private key
(d, n)
- Public key
- Encrypt and decrypt messages directly within the app.
- Encrypted ciphertext is automatically stored and reused for decryption.
📂 Cryptographic-Prime-Toolkit/
├── app.py # Main Streamlit app (UI and navigation)
├── daa_project.py # Sieve + Miller–Rabin logic
├── daa_1.py # AKS vs Miller–Rabin comparison logic
├── rsa_simulation.py # RSA class (encryption/decryption)
├── requirements.txt # Dependencies
└── README.md # Project documentation
git clone https://github.com/abds059/Cryptographic-Prime-Analysis-With-RSA-Simulation
cd Cryptographic-Prime-Analysis-With-RSA-Simulationpip install -r requirements.txtIf requirements.txt is missing, install manually:
pip install streamlit matplotlib sympystreamlit run app.py| Algorithm | Purpose | Complexity | Type |
|---|---|---|---|
| Sieve of Eratosthenes | Generate small primes | O(n log log n) | Deterministic |
| Miller–Rabin Test | Large prime testing | O(k · log³ n) | Probabilistic |
| AKS Algorithm | Primality proof | O(log⁶ n) | Deterministic |
| RSA | Public-key encryption | Depends on key size | Cryptographic |
-
Navigate to Large Prime Generation
- Generate primes using Sieve
- Test large numbers using Miller–Rabin
- Save probable primes in memory
-
Move to RSA Simulation
- Select two primes (p and q)
- Generate RSA keys
- Encrypt and decrypt text messages
-
Explore AKS vs Miller–Rabin Comparison
- Test performance for any prime number
- View time comparison graph
| Feature | Description |
|---|---|
| Prime Generation | Generate & test primes interactively |
| AKS vs MR | Compare performance visually |
| RSA Simulation | Encrypt/Decrypt using selected primes |
This project is designed for students and researchers studying:
- Design & Analysis of Algorithms (DAA)
- Cryptography and Network Security
- Computational Number Theory
It bridges theoretical algorithms with real-world cryptographic applications.
- Add Fermat or Lucas-Lehmer primality tests
- Visualize modular exponentiation steps
- Enable key export and message file encryption
- Integrate with cryptographic libraries like
PyCryptodome
This project is released under the MIT License. Feel free to fork, modify, and use it for academic or personal projects.