Contents

1. Color legend — who's who

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.

ColorSymbolValueJobPublic or secret?
p5First secret primeSecret
q7Second secret primeSecret
n35Modulus = p×q (the "mod 35")Public
e5Encryption exponent (the power to encode)Public
d29Decryption exponent (the power to decode)Secret
φ24Helper to find d, = (p-1)(q-1)Secret

2. Building the keys from 5 & 7

StepFormulaResult
Pick two primesp = 5,  q = 7secret
Multiply themn = p × q = 5 × 735
Totient (helper)φ = (p-1)(q-1) = 4 × 624
Choose enc exponente = 5  (shares no factor with 24)5
Find dec exponente×d ≡ 1 (mod 24) → 5×d = 14529
Public key = ( n=35, e=5 ) — anyone can have this to send you a message.
Private key = ( n=35, d=29 ) — only you keep this to read it.

3. The flow: encode → send → decode

SENDER — encoder
Input
EVE
Algorithm
m  ^ 5  mod  35
Output
JVJ
➞
public channel  JVJ
➞
RECEIVER — decoder
Input
JVJ
Algorithm
c  ^ 29  mod  35
Output
EVE
Anything traveling on the public channel is just JVJ. Without the secret d=29, that's noise — even though the eavesdropper can see 35 and 5.

4. Step-by-step math

Encoding — raise each letter's number to the e=5 power, then take mod 35:

Letterm (A=1…Z=26)m ^ 5mod 35Cipher letter
E53,12510J
V225,153,63222V (maps to itself)
E53,12510J

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):

Ciphercc ^ 29 mod 35Plain letter
J105E
V2222V
J105E

JVJ  →  EVE

Why does V stay V? With these tiny primes, 22 happens to be a "fixed point": 225 and 2229 both come back to 22 mod 35. Real RSA uses primes hundreds of digits long, so fixed points and look-alikes essentially never matter.

5. Why it's secret

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.