Hall II · Substitution Antiquity → 1800s · math-age

Affine Cipher E(x) = a·x + b mod 26

A single linear formula generalises Caesar, Atbash, and ROT13 — and is broken by counting how often E appears.

OriginGeneralisation of Roman shift ciphers
YearNo single historical formalization date established here
Key TypePair (a,b) — a coprime to 26 → 12·26 = 312 keys
PropertyCaesar: a=1; Atbash: a=25, b=25; ROT13: a=1, b=13
Modern LessonThis small affine keyspace and visible language patterns are insecure

Why This Matters

The affine cipher is a mathematical generalization of shift substitution: E(x) = ax + b modulo 26. Caesar has a = 1; Atbash has a = 25, b = 25; ROT13 has a = 1, b = 13. This exhibit does not establish a single inventor or a nineteenth-century formalization date.

The two-parameter key makes the cipher useful for teaching keyspaces, modular inverses, and the requirement that a and 26 be coprime. It is a small example, not a uniquely “smallest” cipher with a multicomponent key.

How It Works

Number the alphabet A=0, B=1, …, Z=25. Pick two integers a and b. Encryption is

E(x) = (a·x + b) mod 26

Decryption uses the modular inverse of a:

D(y) = a⁻¹·(y - b) mod 26

Critical constraint: a must be coprime to 26 (no shared factor with 26 = 2·13). Only twelve values of a qualify: 1, 3, 5, 7, 9, 11, 15, 17, 19, 21, 23, 25. Pair each with one of 26 offsets and you get 12·26 = 312 keys — small enough to brute-force by hand.

How It Was Broken
Brute force
Complexity: Trivial (312 keys)

Try all 312 (a, b) pairs and pick the decryption that looks like English. A modern laptop does this in microseconds; an attentive teenager does it in an afternoon.

Frequency analysis
Difficulty depends on text length and language; the keyspace is small

Affine is a monoalphabetic substitution: each plaintext letter always maps to the same ciphertext letter. Letter frequencies survive intact, so the methods al-Kindi described in the ninth century apply unchanged.

What It Teaches Modern Cryptography
Affine conceptModern echo
Coprime requirement on aRSA's coprime requirement on the public exponent e
Linear transformation in mod 26The Hill cipher generalises this to matrix multiplication
Tiny key spaceThe reason modern keys are 128–256 bits, not 9 bits
Invertibility requires gcd(a, 26) = 1Many modern block ciphers combine nonlinear and linear operations
Quick Facts
OriginGeneralisation of Roman shift ciphers
YearNo single historical formalization date established here
Key TypePair (a,b) — a coprime to 26 → 12·26 = 312 keys
PropertyCaesar: a=1; Atbash: a=25, b=25; ROT13: a=1, b=13
Modern LessonThis small affine keyspace and visible language patterns are insecure