RSA (Rivest–Shamir–Adleman, 1977) secures web traffic, e-mail and digital signatures. Its security rests on the difficulty of factoring N = p·q when p and q have hundreds of digits. This calculator uses small numbers to show the mechanics.
How to use the RSA Calculator
- Prime p
- Prime q
- Public exponent e
- Message M (number smaller than N)
- Received ciphertext C to decrypt
Everything is calculated in your browser, so results appear instantly and nothing you type is sent to a server.
How it works
Enter two different primes, a public exponent coprime to λ(N) (65537 is standard; small values like 17 work for small primes), a message M smaller than N and a ciphertext C to decrypt. Exact big-integer arithmetic is used.
Formula
N = p·q, λ(N) = lcm(p − 1, q − 1), d = e⁻¹ mod λ(N)
C = Mᵉ mod N, M = Cᵈ mod N
Worked example
Inputs: Prime p: 61; Prime q: 53; Public exponent e: 17; Message M (number smaller than N): 65; Received ciphertext C to decrypt: 2,790.
Results: Modulus N = p·q = 3233; λ(N) = lcm(p − 1, q − 1) = 780; Private exponent d = 413; Encrypted message Mᵉ mod N = 2790; Decrypted ciphertext Cᵈ mod N = 65.
Key terms
- Public key
- (N, e), shared openly.
- Private key
- d, kept secret.
Frequently asked questions
Is this secure?
No. Real RSA uses primes of 1,024 bits or more, plus padding.
Why 65537?
It is prime, and its binary form 10000000000000001 makes encryption fast.
What is λ(N)?
Carmichael's function; φ(N) = (p − 1)(q − 1) also works.
Why must M be smaller than N?
Arithmetic is mod N, so larger messages would wrap around.