RSA (public key encryption)

Key generation:
1. Choose two primes p and q (61 and 53).
2. n = p * q = 3233
3. phi(n) = (p-1)(q-1) = 3120
4. Choose e with gcd(e, phi) = 1 (e = 17).
5. d = e^-1 mod phi  (e*d = 1 mod phi), d = 2753.
   Public key = (e, n), private key = (d, n).

Formula:
    Encryption: C = M^e mod n
    Decryption: M = C^d mod n

Example: M = 65 -> C = 65^17 mod 3233 = 2790 -> 2790^2753 mod 3233 = 65.
(Small primes only for demo. Real RSA uses 1024+ bit primes.)
