RSA Demonstrator

Educational RSA key generation, encryption, and decryption

About this calculator

The RSA Demonstrator is an educational tool that walks through the RSA public-key cryptosystem from end to end. Pick two primes p and q; it derives the modulus n = p·q, Euler's totient φ(n) = (p−1)(q−1), a public exponent e coprime to φ(n), and the matching private exponent d = e⁻¹ mod φ(n). It then encrypts a message as c = mᵉ mod n and decrypts it back as cᵈ mod n, showing the full key pair and the round-trip. All arithmetic is exact. Useful for learning how public-key encryption, modular exponentiation, and modular inverses fit together.

Common examples

  • p=61, q=53, e=17 → n=3233, φ=3120, d=2753; encrypt 65 → 2790, decrypt 2790 → 65
  • p=11, q=13, e=7 → n=143, φ=120, d=103; encrypt 9 → 48, decrypt 48 → 9
  • p=17, q=23, e=3 → n=391, φ=352, d=235; encrypt 100 → 213, decrypt 213 → 100
  • p=61, q=53, e=15 → e shares the factors 3 and 5 with φ=3120, so no private key exists
  • p=4 is not prime, so RSA cannot start — the modulus would not be a product of two primes