RSA Encryption Toy

Pick two primes, enter a message, and watch RSA encrypt then decrypt it.

Loading interactive simulation...

Modular arithmetic and prime factorization complexity 🖖

RSA encryption relies on the asymmetric mathematical difficulty of prime factorization. It generates keys using Euler's totient function φ(n) = (p-1)(q-1) and modular arithmetic: c = m^e mod n. Decryption is possible only using the private exponent d, where e * d ≡ 1 mod φ(n). The security bounds are based on the fact that finding d from public keys (e, n) is computationally infeasible without factoring n into its prime components p and q.

The padlock only you can open 🖖

RSA gives everyone an open padlock (your public key) that they can snap shut around a message, but only your private key can reopen it. Because locking and unlocking use different keys, you can publish the public one for the whole world to see without giving away how to decrypt. This tool lets you run the full lock-and-unlock cycle with tiny primes; real systems use the same steps with numbers hundreds of digits long.

Encryption run backwards is a signature 🖖

The very same RSA operation, run in the opposite direction, proves who sent a message instead of hiding it. If you "decrypt" a message with your private key, anyone can "encrypt" it back with your public key to check it really came from you - that is a digital signature. So one piece of math powers both confidentiality and authentication, just by swapping which key goes first.

Example problems