🔐 RSA Algorithm Explorer

Discover the mathematics behind one of the most important cryptographic algorithms in modern computing

What is RSA?

RSA (Rivest-Shamir-Adleman) is a public-key cryptosystem that enables secure communication over an insecure channel. It's widely used for secure data transmission and digital signatures.

1

Key Generation

Generate two large prime numbers and calculate the public and private keys

2

Encryption

Use the public key to encrypt messages that only the private key can decrypt

3

Decryption

Use the private key to decrypt messages encrypted with the public key

🚀 Interactive RSA Demo

🔢 Mathematical Foundation

RSA security is based on the mathematical difficulty of factoring large integers. Here's how it works:

Key Generation:
1. Choose two distinct prime numbers: p and q
2. Calculate n = p × q (modulus)
3. Calculate φ(n) = (p-1) × (q-1) (Euler's totient)
4. Choose e such that gcd(e, φ(n)) = 1 (public exponent)
5. Calculate d such that d × e ≡ 1 (mod φ(n)) (private exponent)
Encryption: C = M^e mod n
Decryption: M = C^d mod n

🛡️ Security Considerations

The security of RSA depends on key length and proper implementation:

Key Lengths

512 bits - Broken

1024 bits - Deprecated

2048+ bits - Secure

Common Attacks

  • Factorization attacks
  • Timing attacks
  • Chosen plaintext attacks
  • Mathematical attacks on weak keys