Read this lesson as text

Complete RSA Example

Cryptography · Axiom Academy

Full walkthrough of RSA key generation, encryption, and decryption with real numbers Excellent work! You've completed a full RSA encryption and decryption cycle. Here's what we learned: Key Generation: RSA relies on choosing two primes (p and q), computing n = p × q and φ(n) = (p-1)(q-1), then finding e and d such that e × d ≡ 1 (mod φ(n)) Public vs Private Keys: The public key (n, e) is used for encryption, while the private key (n, d) is used for decryption. Only the holder of d can decrypt messages Modular Arithmetic: Both encryption (c = m e mod n) and decryption (m = c d mod n) use modular exponentiation to ensure the result stays within a fixed range Security Foundation: The security of RSA depends on the difficulty of factoring large numbers. While our example uses small primes for clarity, real RSA uses primes with hundreds of digits Mathematical Correctness: Thanks to Euler's theorem, raising to the e th power and then the d th power (mod n) returns the original message, making encryption reversible This complete example demonstrates why RSA is called "asymmetric" encryption - different keys are used for encryption and decryption!

This is the written version of the interactive lesson above. See the full Cryptography course.