Caesar cipher and how to break it

Julius Caesar hid messages by sliding every letter three places along the alphabet. Slide them back and the message returns. The trouble is that letters have habits, and habits give you away.

1. Make a secret message

A → D. To decode, shift by 26 minus the key: a shift of 23 undoes a shift of 3.

2. Break one

Paste any Caesar-shifted text here. The bars show how often each letter appears in it (indigo) next to how often it appears in ordinary English (outline). Look for the tallest indigo bar: it is probably E, T or A in disguise.

What's going on

A Caesar cipher has only 25 possible keys, so you could just try them all, and the button does. But the frequency bars show something deeper that works even for harder ciphers. In English about one letter in eight is an E, and T, A, O, I, N follow close behind. Z, Q, X and J barely appear.

Shifting the alphabet does not change those habits, it only moves them. If the most common letter in the secret text is H, the shift is probably 3, because H is three past E. Check the next few tallest bars and the guess becomes a certainty. Arab scholars worked this out over a thousand years ago, and it is the start of the whole science of codebreaking.

Sheet: Secret codes and how to break them.