Skip to content

About

A Python-based educational tool demonstrating how the Rivest-Shamir-Adleman (RSA) algorithm works under the hood, including prime generation, key creation, and block-based encryption/decryption.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

RSA Encryption Algorithm Simulator

A Python-based educational tool demonstrating how the Rivest-Shamir-Adleman (RSA) algorithm works under the hood, including prime generation, key creation, and block-based encryption/decryption.

Features

  • Extended Euclidean Algorithm
  • Modular inverse computation
  • Miller–Rabin probabilistic primality test
  • Random and strong prime generation
  • RSA key pair generation (1024-bit)
  • Block-based encryption and decryption

Security Note

This project is for learning and demonstration purposes only. It is not intended for securing real communications. In particular:

  • No padding scheme (e.g. OAEP) is used, making raw RSA encryption vulnerable to several attacks.
  • The generated pubKey.json and privKey.json files contain key material and are excluded from version control
  • 1024-bit keys are below modern security recommendations; production RSA uses 2048-bit or larger.

Requirements

Python 3.8+. No external packages required (see requirements.txt).

Installation

git clone https://github.com/colesjunge/rsaSimulator.git
cd rsaSimulator

No further setup is needed.

Usage

python rsaMain.py

You'll see an explanation of how RSA works, followed by a menu:

RSA Encryption - MAIN MENU

1. Generate New Key Pair
2. Encrypt a Message
3. Decrypt a Message
4. Show RSA Information
5. Exit

Generate a key pair first (option 1), then encrypt (option 2) and decrypt (option 3) freely. Copy the encrypted block output and paste it back in when decrypting.

How RSA Works

  1. Generate two large primes p and q
  2. Compute n = p * q and φ(n) = (p-1)(q-1)
  3. Choose public exponent e (typically 65537) where gcd(e, φ(n)) = 1
  4. Compute private exponent d such that e * d ≡ 1 (mod φ(n))
  5. Encrypt: c = m^e mod n
  6. Decrypt: m = c^d mod n

Project Structure

.
├── rsaMain.py                  # Entry point / interactive menu
├── rsaAlgorithmFunctions.py    # Core RSA math
├── rsaDisplayGenFunctions.py   # I/O and console display logic
├── pubKey.json                 # Generated at runtime - not tracked in git
├── privKey.json                # Generated at runtime - not tracked in git
├── requirements.txt
└── README.md

License

MIT — see LICENSE for details.

Author

Cole Junge

About

A Python-based educational tool demonstrating how the Rivest-Shamir-Adleman (RSA) algorithm works under the hood, including prime generation, key creation, and block-based encryption/decryption.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages