RSA Calculator
Explore how RSA encryption works using small prime numbers. This educational calculator generates public and private keys, encrypts a message, and decrypts it back to demonstrate the complete RSA process.
RSA (Rivest-Shamir-Adleman) is one of the first public-key cryptosystems and is widely used for secure data transmission. This calculator demonstrates the algorithm with small numbers so you can see every step.
How RSA Works:
- Choose two primes p and q. Compute n = p x q.
- Compute Euler's totient: phi(n) = (p-1)(q-1).
- Choose public exponent e such that 1 < e < phi(n) and gcd(e, phi(n)) = 1. The value 65537 is a common choice.
- Compute private exponent d such that e x d = 1 (mod phi(n)).
- Encrypt: ciphertext c = m^e mod n.
- Decrypt: plaintext m = c^d mod n.
Why It Works:
The security relies on the difficulty of factoring n back into p and q. Multiplying two primes is fast, but reversing that multiplication (factoring) is computationally hard for very large numbers. Real RSA uses primes with hundreds of digits.
Important Note:
This calculator uses small numbers for educational purposes. Real RSA implementations use 2048-bit or larger keys, which involve primes with over 300 digits each.