Read this lesson as text

RSA Encryption

Discrete Math · Axiom Academy

REAL WORLD RSA Encryption: Breaking Weak Keys Discover how RSA encryption works from key generation to encryption/decryption. Then crack weak encryption to understand why large prime numbers are essential for security. RSA encryption protects your credit card numbers, passwords, and private messages online. It's named after its inventors: Rivest, Shamir, and Adleman. The security of RSA depends entirely on a mathematical fact: multiplying two large prime numbers is easy, but factoring their product back into those primes is extremely difficult. Today you'll learn how RSA works by implementing it yourself with small numbers. Then you'll become an attacker and break weak RSA encryption by factoring small keys. This will reveal exactly why modern RSA uses huge prime numbers (typically 2048 bits or larger). RSA starts by generating a public key (for encryption) and a private key (for decryption). Let's generate a key pair using small prime numbers so you can see every step. Anyone can use this to encrypt messages Only you have this to decrypt messages Choose two prime numbers: p and q Calculate n = p × q (this is your modulus) Calculate φ(n) = (p-1) × (q-1) Choose e (public exponent) that is coprime with φ(n) Calculate d (private exponent) where e × d ≡ 1 (mod φ(n)) Now let's encrypt a message using the public key. We'll encrypt the word "HELLO" by converting each letter to a number and applying RSA encryption.

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