Jump to:

Alice Sends "go umass!" to Bob

A complete, step-by-step walkthrough of RSA encryption — from key generation to decryption — using a real message over a public channel where Eve is listening.

👩
Alice
sender
😈
Eve (eavesdropper)
👨
Bob
receiver

1 Bob Generates His Key Pair

Before anything else, Bob generates his keys. He does this once and keeps the private parts secret forever.

📐 Theory recap: RSA key generation relies on Euler's totient φ(n) and the Extended Euclidean Algorithm. See φ(n) →   See Extended GCD →

Bob's Key Generation

Choose two distinct primes. Bob does this secretly — Eve will never see them.

Why pick primes? φ(p·q) = (p−1)(q−1) only works cleanly when p and q are prime. For large RSA (2048-bit), p and q each have ~600 digits — they're generated randomly with primality tests.

2 Bob Publishes His Public Key

Bob posts his public key online — a directory, a website, an email header. Everyone sees it. That's fine.

⚠ Complete Bob's key generation in Phase 1 first.
What can Eve do with (n, e)? She can encrypt a message to Bob — but she can't decrypt messages sent to him, because she doesn't have d. Without knowing p and q she can't compute φ(n), and without φ(n) she can't find d. Why? See RSA security →

3 Alice Writes Her Message

Alice wants to send Bob a message. She looks up his public key and gets ready to encrypt.

Alice's plaintext message

Constraint: In this demo, each character is encoded as its ASCII value, and we encrypt each separately. This requires each ASCII value to be less than n (the modulus). Real RSA groups characters into large blocks and uses padding schemes (PKCS#1, OAEP). Why mod n? →

4 Alice Converts the Message to Numbers

Computers work with numbers. Alice converts each character to its ASCII code — a universally agreed integer representation.

💡 ASCII (American Standard Code for Information Interchange) maps every printable character to an integer 0–127. 'A'=65, 'a'=97, '!'=33, space=32.
⚠ Complete Phases 1–3 first.

5 Alice Encrypts with Bob's Public Key

Alice uses Bob's public key (n, e) to encrypt each number. She applies the RSA formula to every character.

\( C_i = M_i^{\,e} \bmod n \)
📐 Why does raising to the power e create a "lock"? Because without knowing d, you can't invert it. This is the one-way trap. Euler's theorem makes this reversible →
⚠ Complete Phases 1–4 first.

6 The Ciphertext Travels the Network

Alice sends the sequence of encrypted numbers. Eve intercepts every bit — but all she sees is a list of big integers that mean nothing without d.

⚠ Complete Phases 1–5 first.

7 Bob Decrypts with His Private Key

Bob receives the ciphertext. He applies his secret exponent d to each number — and gets back the original ASCII values.

\( M_i = C_i^{\,d} \bmod n \)
📐 This works because e·d ≡ 1 (mod φ(n)), so Cd = (Me)d = Me·d ≡ M (mod n). Euler's theorem proof →
⚠ Complete Phases 1–6 first.

8 Bob Reads the Message

⚠ Complete all previous phases first.

+ Eve's Perspective

Eve intercepts everything on the wire. Let's tally what she knows vs. what she'd need to break RSA.

⚠ Complete all previous phases to see Eve's view.
The Integer Factorization Problem: Eve knows n = p·q. To find φ(n) = (p−1)(q−1) she needs p and q. Factoring a 2048-bit n with the best algorithms (General Number Field Sieve) would take more compute than the world's fastest supercomputers could do in millions of years.