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.
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.
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.
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.
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.
| Affine concept | Modern echo |
|---|---|
| Coprime requirement on a | RSA's coprime requirement on the public exponent e |
| Linear transformation in mod 26 | The Hill cipher generalises this to matrix multiplication |
| Tiny key space | The reason modern keys are 128–256 bits, not 9 bits |
| Invertibility requires gcd(a, 26) = 1 | Many modern block ciphers combine nonlinear and linear operations |
| Origin | Generalisation of Roman shift ciphers |
| Year | No single historical formalization date established here |
| Key Type | Pair (a,b) — a coprime to 26 → 12·26 = 312 keys |
| Property | Caesar: a=1; Atbash: a=25, b=25; ROT13: a=1, b=13 |
| Modern Lesson | This small affine keyspace and visible language patterns are insecure |