A cipher is safe only if breaking it takes too much work. This lesson breaks the shift cipher twice: once by trying every key, once by counting letters. Both ideas still matter today.
Try every key
A shift cipher on 26 letters has only 25 useful keys (a shift of 0 changes nothing). An attacker can simply try all 25 and look for the one that makes sense. Trying every possible key is called a brute-force attack. It works whenever the number of keys is small.
Count the letters
Some ciphers have far too many keys to try. One example swaps each letter for a different letter in a mixed-up order, with about 4 × 10²⁶ possible keys (4 followed by 26 zeros). But it keeps a weakness: each plain letter always becomes the same cipher letter, so the most common letters stay the most common. Counting them reveals the key. This is frequency analysis.
intercepted
Here is an intercepted message, encrypted with an unknown shift. Without the key, it looks like nonsense.
What this teaches
A good cipher must leave no patterns: the ciphertext should look like random letters whatever the message says. Modern ciphers are built to do exactly that.
Lab: the cipher wheel
First encrypt and decrypt your own message with any shift. Then break a message whose key you do not know, by trying every key.
1. Use the wheel
PHHW PH DW WKH OLEUDUB
2. Break this message without the key
ESP WTMCLCJ NWZDPD PLCWJ ZY QCTOLJ
CIPH-2 counts as completed once you step through the figure to its last step.