Free tool

RSA calculator

Enter two primes and watch the whole algorithm unfold — modulus, totient, public and private exponents, then a real encryption you can reverse.

This runs the textbook RSA algorithm at a scale you can verify by hand. Pick two primes, and every derived value is shown with the arithmetic behind it. Use small primes to follow along; the tool accepts large ones too.

Press the button to run the algorithm.

Primality is checked with Miller–Rabin. Everything runs in your browser — nothing is sent anywhere. This is for learning, not for protecting real data.

What each value does

n = p × q is the modulus, and it is public. Its security is the whole game: anyone who can factor n back into p and q recovers the private key immediately.

φ(n) = (p−1)(q−1) is Euler's totient. It must stay secret — it is the bridge from the public exponent to the private one.

d is the modular inverse of e modulo φ(n), found with the extended Euclidean algorithm. That inverse only exists when e and φ(n) share no common factor, which is why the tool rejects some values of e.

Real keys use primes of about 300 digits each and almost always e = 65537. The arithmetic is identical — only the size changes. For the full walkthrough see how RSA works.

Now break it

Factor n = 3233 back into 61 × 53 and recover the message — the attack, at readable scale.

Try the RSA boss battle →

Keep going

How RSA works

The full algorithm, explained step by step.

Open →

Prime numbers

Why the primes have to be enormous.

Open →

Modular exponentiation

The operation doing the actual work.

Open →