Unbreakable Cipher

Secret Writing: A History of Codes, Ciphers and Codebreaking

Course 1 · Chapter 5 · Unbreakable Cipher

Chapter 4 ended with Alberti's big idea: change the alphabet partway through a message so that letter counting stops working. This chapter follows that idea to its most famous form, a cipher so respected that it was called unbreakable for about three hundred years, and then to the two men who showed, independently, that it was not.

From Alberti to a Keyword

Alberti's disk needed the secretary to turn the dial at the right moments, which was slow and easy to get wrong. Later writers on ciphers found a neater way: agree on a keyword and let each letter of the keyword choose the shift for the matching letter of the message. Repeat the keyword as often as needed. The result is a series of Caesar shifts (Chapter 2) taken in rotation, which makes it polyalphabetic without any moving parts.

Key figures Giovan Battista Bellaso (born 1505): Italian writer who published a keyword-driven polyalphabetic scheme in 1553.
Blaise de Vigenere (1523 to 1596): French diplomat whose treatise on ciphers (1586) gave the method the name it still carries.
Charles Babbage (1791 to 1871): English mathematician and inventor of mechanical calculating engines, who broke the cipher privately in the 1850s.
Friedrich Kasiski (1805 to 1881): Prussian army officer who published a general method for breaking it in 1863.
Not Yet Verified The names, dates and roles above are written from general knowledge and were not checked against a source for this chapter. In particular, the cipher is named after Vigenere although the keyword idea is usually credited to Bellaso, and Babbage's earlier break is known mainly from his unpublished notes. Treat these as pointers for your own search.

How the Keyword Cipher Works

Number the alphabet A = 0, B = 1 and so on to Z = 25. To encipher, add the keyword letter's number to the message letter's number and wrap around after Z. To decipher, subtract. Spaces and punctuation are skipped, and the keyword does not advance over them.

Message ATTACK AT DAWN with the keyword LEMON Message : A T T A C K A T D A W N Keyword : L E M O N L E M O N L E Cipher : L X F O P V E F R N H R Check two letters: A (0) + L (11) = 11 = L. T (19) + E (4) = 23 = X.

Look at the three As in the message. They became L, O and E. The two Ts became X and F. This is exactly what Chapter 4 promised: a single plain letter no longer maps to a single cipher letter, so the frequency peak that Al-Kindi's method (Chapter 3) depends on is flattened out.

Le Chiffre Indechiffrable

A cipher that defeats letter counting looked, to its users, like a cipher that defeats everything. For roughly three centuries it carried the reputation of being le chiffre indechiffrable, French for "the indecipherable cipher". It still spread slowly: like Alberti's disk it was fiddly by hand, one slipped letter spoils everything after it, and nomenclators (Chapter 4) were quick and good enough. But for anyone who wanted real strength it was the cipher to use, and its reputation outlived its security.

CipherAlphabets usedLetter counting works?What breaks it
Caesar shiftOne (fixed shift)Yes, immediatelyTrying all 25 shifts
Simple substitutionOne (scrambled)Yes (Al-Kindi)Frequency analysis
NomenclatorOne plus a code listPartlyStolen code list, probable words
Keyword (Vigenere)As many as the keyword has lettersNo, not directlyFind the key length, then count each column

The Weakness Hidden in the Repeat

The keyword has to repeat, and repetition is a pattern. Suppose the same word appears twice in the message and the two copies sit a whole number of keyword-lengths apart. Then both copies meet the same keyword letters and turn into the same cipher text. An analyst who spots a repeated group of letters in the cipher text has found a clue about the key.

Keyword CAT (length 3). THE appears at letter positions 0, 12 and 30. 12 and 30 are both multiples of 3, so each THE meets C, A, T again. Message : THE KING SENDS THE GOLD AND THE SHIPS ... Cipher : VHX MIGI SXPDL VHX IOEF AGF TAG SAKPL VHX ... VHX appears three times, at gaps of 12, 18 and 30 letters.

The Breakers: Babbage and Kasiski

The break comes in two steps.

  1. Find the key length. Note the gaps between repeated groups of three or more letters. The key length must divide most or all of those gaps. Gaps of 12, 18 and 30 share the factors 2, 3 and 6, so the key is probably 3 or 6 letters long. This is the Kasiski examination.
  2. Split and count. If the key has 3 letters, every third letter of the cipher text was enciphered with the same shift. So the cipher text splits into three separate Caesar-shifted texts, and each one yields to ordinary letter counting. The commonest letter in each column is probably E, which reveals that column's shift and therefore the keyword letter.

Babbage is reported to have solved it in the 1850s, apparently after a challenge about the cipher was put to him, but he did not publish. Kasiski published a general method in 1863 and his name stuck to it. The moral for this course is that the cipher stood unchallenged less because it was strong than because few people seriously attacked it, and because the attackers who succeeded did not always say so.

Not Yet Verified Why Babbage did not publish, and whether military reasons were involved, is discussed in popular accounts but I did not check a source here. The step-by-step method above is a standard teaching outline, not a record of what either man actually did.

What the Break Teaches

A cipher is only as strong as the weakest pattern it leaves behind. The keyword cipher hid letter frequencies but left the keyword's period visible. Once the period is known, the cipher collapses into several easy ones. The longer the key, the fewer repeats there are and the harder they are to find, which points toward a limit: if the key were as long as the message and never reused, there would be no period at all. Chapter 10 returns to that idea.

Try it yourself: lift the keyword Decipher this message, which was enciphered with the keyword LEMON (subtract each keyword letter's number from the cipher letter's number):

LXFOPV EF RNHR

What does it say?
Show the worked answer

L (11) minus L (11) is 0, an A. X (23) minus E (4) is 19, a T. F (5) minus M (12) is minus 7, which wraps to 19, another T. Carry on in the same way and the message is ATTACK AT DAWN. Notice that the first three cipher letters L, X, F stand for A, T, T: the two Ts came out as different letters, which is why counting alone would not have helped you.

Where This Leaves the Secret Writer

By the nineteenth century the keyword cipher was both famous and broken, and a lesson was set: strength claims need testing by determined opponents. The next chapter turns from the method to the people, with spymasters, plots and the ciphers that sent a queen to the scaffold.

Exercises

Exercise 1

Encipher RETREAT AT MIDNIGHT with the keyword BAD (B = 1, A = 0, D = 3), skipping spaces without advancing the keyword. (a) Write the cipher text. (b) Which plain letters in RETREAT became the same cipher letters as each other, and why?

Exercise 2

Decipher DLC PPCOX QKMJC ER XSMX, which was enciphered with the keyword KEY (K = 10, E = 4, Y = 24). Then look at the two Ps at the start of PPCOX: do they stand for the same plain letter?

Exercise 3

Here is a cipher text with spaces kept for reading: VHX MIGI SXPDL VHX IOEF AGF TAG SAKPL VHX PEQV MHTNBPG. (a) Find the group VHX and count the letters between its first and second appearances. (b) Find the gaps for the other appearances and decide what key lengths fit. (c) Given the key is CAT, decipher the message.

Quick Reference

  • Keyword cipher: each keyword letter gives the shift for the matching message letter, repeated in rotation
  • Encipher: add the numbers (A = 0 to Z = 25) and wrap around; decipher by subtracting
  • Why it lasted: it flattens letter frequencies, so simple counting fails
  • Kasiski examination: gaps between repeated groups reveal the key length
  • Then: split into columns by key length and count letters in each
  • Check: the names, dates and roles, and why Babbage did not publish

Next chapter: Mary, Queen of Scots and Spymasters, with the Babington plot, Walsingham's phasing and the Great Cipher of Louis XIV.