Each number has one job, and one color it keeps everywhere. Watch out for one trap: the digit 5 shows up twice in two different roles — as the prime p and as the encryption exponent e — so they get different colors.
| Color | Symbol | Value | Job | Public or secret? |
|---|---|---|---|---|
| p | 5 | First secret prime | Secret | |
| q | 7 | Second secret prime | Secret | |
| n | 35 | Modulus = p×q (the "mod 35") | Public | |
| e | 5 | Encryption exponent (the power to encode) | Public | |
| d | 29 | Decryption exponent (the power to decode) | Secret | |
| φ | 24 | Helper to find d, = (p-1)(q-1) | Secret |
| Step | Formula | Result |
|---|---|---|
| Pick two primes | p = 5, q = 7 | secret |
| Multiply them | n = p × q = 5 × 7 | 35 |
| Totient (helper) | φ = (p-1)(q-1) = 4 × 6 | 24 |
| Choose enc exponent | e = 5 (shares no factor with 24) | 5 |
| Find dec exponent | e×d ≡ 1 (mod 24) → 5×d = 145 | 29 |
Encoding — raise each letter's number to the e=5 power, then take mod 35:
| Letter | m (A=1…Z=26) | m ^ 5 | mod 35 | Cipher letter |
|---|---|---|---|---|
| E | 5 | 3,125 | 10 | J |
| V | 22 | 5,153,632 | 22 | V (maps to itself) |
| E | 5 | 3,125 | 10 | J |
EVE → JVJ
Decoding — raise each cipher number to the d=29 power, then mod 35 (done by modular exponentiation, not by writing the giant number):
| Cipher | c | c ^ 29 mod 35 | Plain letter |
|---|---|---|---|
| J | 10 | 5 | E |
| V | 22 | 22 | V |
| J | 10 | 5 | E |
JVJ → EVE
The eavesdropper sees the public key 35 and 5, and the scrambled JVJ. To read it, they need d=29 — and the only way to get d is to know φ=24, which means knowing the secret primes 5 and 7 that multiply to 35.
Factoring 35 back into 5×7 is trivial here. But for a 600-digit n, factoring it would take classical computers longer than the age of the universe. That factoring step is exactly what Shor's algorithm on a quantum computer would shortcut — the thread we were pulling on.