Classical ciphers
For most of history, cryptography meant pen, paper and clever tricks. These ciphers are easy to break today, but they introduce the two basic techniques every modern cipher still uses: transposition (rearranging) and substitution (replacing).
A short timeline
- c. 1900 BC
An Egyptian scribe uses non-standard hieroglyphs in a tomb inscription. It's the earliest known deliberate alteration of writing. - c. 600–500 BC
The Atbash cipher (A↔Z, B↔Y…) appears in Hebrew texts. - c. 5th century BC
Spartans are said to have used the scytale for military messages. - c. 50 BC
Julius Caesar uses a simple letter shift, now called the Caesar cipher. - 9th century AD
The Arab polymath Al-Kindi describes frequency analysis, the first systematic cryptanalysis. Simple substitution is never safe again. - 1467
Leon Battista Alberti invents the cipher disk and the idea of polyalphabetic substitution. - 1553 / 1586
Bellaso publishes a keyword polyalphabetic cipher, later misattributed to Blaise de Vigenère. It earns the nickname "le chiffre indéchiffrable". - 1700s
Freemasons popularise the pigpen cipher. - 1854
Charles Wheatstone invents the Playfair cipher, later used by the British in the Boer War and WWI. - 1863
Friedrich Kasiski publishes a general method for breaking Vigenère. Charles Babbage had found one earlier but never published it. - 1917–1918
Vernam's XOR teleprinter cipher (the basis of the one-time pad) and Scherbius's Enigma patent take cryptography into the machine age (Chapter 04).
The scytale (transposition)
A strip of leather or parchment was wound around a rod (the scytale) and the message written along its length. Unwound, the strip shows a jumble of letters. Only someone with a rod of the same diameter can line them up again. The rod's diameter is the key.
The letters themselves don't change. Only their positions do. That's pure transposition, and it's why the letter frequencies of the ciphertext match normal English, which gives the method away.
Message written along the rod (each row is one turn around it):
Unwound strip (ciphertext, read down the columns):
The Caesar cipher (substitution)
Each letter is replaced by the letter a fixed number of places further along the alphabet. Caesar reportedly used a shift of 3, so A→D, B→E and so on, wrapping around at Z. ROT13 is the same idea with a shift of 13, which makes encryption and decryption identical.
The key space is just 25 useful shifts, so an attacker can simply try them all.
Ciphertext
The pigpen cipher
The pigpen (or Freemason's) cipher replaces each letter with a symbol based on its position in two grids and two Xs. The shape of the "pen" around the letter, and whether it has a dot, becomes the symbol. It looks mysterious, but it's just a simple substitution with symbols instead of letters, so frequency analysis breaks it just as easily.
The rail fence cipher
Another transposition cipher. You write the message in a zig-zag across a number of "rails", then read each rail left to right. The number of rails is the key. It was reportedly used during the American Civil War.
Ciphertext (read rail by rail)
Breaking substitution: frequency analysis
In English, E makes up about 12.7% of letters, followed by T, A, O, I and N. A monoalphabetic cipher (Caesar, Atbash, pigpen, any one-to-one swap) changes the letters but keeps their frequencies. Count the symbols in the ciphertext, line up the peaks with English, and the key falls out. Al-Kindi described this over 1,100 years ago.
■ letter counts in the ciphertext, after your shift ■ normal English frequencies
Vigenère: polyalphabetic substitution
Vigenère uses a keyword to pick a different Caesar shift for each letter. With key LEMON, the first letter shifts by 11 (L), the second by 4 (E), and so on, repeating. The same plaintext letter turns into different ciphertext letters, which flattens the frequency peaks.
It held out for about 300 years. The weakness is the repeating key. Kasiski noticed that repeated chunks of ciphertext reveal the key length. Once you know the length, the message splits into several separate Caesar ciphers, and each one falls to frequency analysis. If you make the key random and as long as the message, you've reinvented the one-time pad.