Skip to content

A Streamlit-based interactive app that generates large primes, compares primality algorithms, and demonstrates real-world RSA encryption and decryption using those primes.

Notifications You must be signed in to change notification settings

abds059/Cryptographic-Prime-Analysis-With-RSA-Simulation

Repository files navigation

Cryptographic Prime Analysis With RSA Simulation

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.


Features Overview

1. Large Prime Generation

  • 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).

2. AKS vs Miller–Rabin Comparison

  • Compare execution times between deterministic (AKS) and probabilistic (Miller–Rabin) primality tests.
  • Visual bar chart showing performance differences.
  • Adjustable repetitions for accurate timing averages.

3. RSA Simulation

  • 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)
  • Encrypt and decrypt messages directly within the app.
  • Encrypted ciphertext is automatically stored and reused for decryption.

Project Structure


📂 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


Installation & Setup

1. Clone the Repository

git clone https://github.com/abds059/Cryptographic-Prime-Analysis-With-RSA-Simulation
cd Cryptographic-Prime-Analysis-With-RSA-Simulation

2. Install Dependencies

pip install -r requirements.txt

If requirements.txt is missing, install manually:

pip install streamlit matplotlib sympy

3. Run the App

streamlit run app.py

Algorithms Used

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

Example Workflow

  1. Navigate to Large Prime Generation

    • Generate primes using Sieve
    • Test large numbers using Miller–Rabin
    • Save probable primes in memory
  2. Move to RSA Simulation

    • Select two primes (p and q)
    • Generate RSA keys
    • Encrypt and decrypt text messages
  3. Explore AKS vs Miller–Rabin Comparison

    • Test performance for any prime number
    • View time comparison graph

UI Preview

Feature Description
Prime Generation Generate & test primes interactively
AKS vs MR Compare performance visually
RSA Simulation Encrypt/Decrypt using selected primes

Educational Focus

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.


Future Enhancements

  • Add Fermat or Lucas-Lehmer primality tests
  • Visualize modular exponentiation steps
  • Enable key export and message file encryption
  • Integrate with cryptographic libraries like PyCryptodome

License

This project is released under the MIT License. Feel free to fork, modify, and use it for academic or personal projects.


About

A Streamlit-based interactive app that generates large primes, compares primality algorithms, and demonstrates real-world RSA encryption and decryption using those primes.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages