A tiny numerical example shows all the steps of RSA with computations you can do by hand.

Example — Toy RSA p=11p=11, q=13q=13

n=143n = 143, φ(n)=1012=120\varphi(n) = 10\cdot 12 = 120. We choose e=7e=7 (coprime with 120120). The inverse of 77 modulo 120120 is found with the extended Euclidean algorithm: 7103=721=6120+17\cdot 103 = 721 = 6\cdot 120 + 1, hence d=103d=103.

Encoding the message m=9m=9: c=97mod143c = 9^7\bmod 143. Computation: 92=819^2 = 81, 94=812=6561=45143+1261269^4 = 81^2 = 6561 = 45\cdot 143 + 126\equiv 126, hence 97=94929=126819(mod143).9^7 = 9^4\cdot 9^2\cdot 9 = 126\cdot 81\cdot 9 \pmod{143}. One finds c48(mod143)c \equiv 48\pmod{143}.

Decoding: 48103mod14348^{103}\bmod 143. One verifies numerically (fast exponentiation) that it returns 99. ✓

The message m=9\boxed{m=9} is encrypted into c=48c=48 with the public key (n,e)=(143,7)(n,e)=(143,7) and recovered with the private key d=103d=103: it is the whole mechanism of RSA on a toy scale.

Topics: Distribuzioni probabilita
Concepts: Aritmetica modulare · Crittografia rsa
Methods: Rsa cifratura
Skills: Calcolare · Usare formule