RSA Demonstrator

Educational RSA key generation, encryption, and decryption

Choose two prime numbers

A prime number, at most 1,000,000
A prime number, at most 1,000,000
An integer with 1 < e < φ(n), coprime to φ(n)
A whole number from 0 to n − 1
n = p·q · φ(n) = (p−1)(q−1) · e·d ≡ 1 (mod φ(n)) · c = mᵉ mod n · m = cᵈ mod n
Key pair
Public key (e, n)
(17, 3233)
Private key (d, n)
(2753, 3233)
Modulus n = p · q
3233
Totient φ(n) = (p − 1)(q − 1)
3120
Private exponent d ≡ e⁻¹ (mod φ(n))
2753
Ciphertext c = mᵉ mod n
2790
Decrypted cᵈ mod n
65
Round-trip check
✓ Decryption recovered the original message
RSA encryption and decryption flowA flow diagram: the message is encrypted with the public key into ciphertext, then decrypted with the private key back into the original message, with the derived modulus, totient, and key exponents shown.Key generationn = p·q = 3233φ(n) = 3120e = 17 d = 2753Messagem = 65Encryptc = mᵉ mod nCiphertextc = 2790Decryptm = cᵈ mod nRecoveredm = 65

Acerca de esta calculadora

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.

Ejemplos comunes

  • 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