How this calculator works
Multiply two distinct odd primes to form N. The public exponent must be coprime to λ(N), allowing the extended Euclidean algorithm to find its modular inverse d. Modular exponentiation transforms the message and reverses the transformation. This page intentionally uses small numbers and raw textbook RSA for learning. It has no padding, secure key generation or message encoding and is unsuitable for protecting data.
Formula
N = pq; λ(N) = lcm(p-1,q-1); ed ≡ 1 mod λ(N). Ciphertext c = m^e mod N; recovered m = c^d mod N, with 0 ≤ m,c < N.
Worked example
For p = 61, q = 53 and e = 17, N = 3233 and λ(N) = 780. The least positive inverse is d = 413. Message 65 encrypts to 2790 and decrypts back to 65.
Advertisement
Frequently asked questions
Why is d sometimes listed as 2753?
Using φ(N) = 3120 instead of λ(N) = 780 gives the inverse 2753. Both exponents satisfy the needed modular relationship for this example.
Can p and q be equal?
No. This two-prime model requires distinct odd primes; the λ(N) expression used here relies on that assumption.
Can I encrypt a sentence?
This educational tool accepts an integer representative only. Production RSA uses a vetted scheme with encoding, padding and much larger keys.