How to break the Caesar cipher using letter distances

Kapitoly: Caesar's cipher, How to break the Caesar cipher by brute force, How to break the Caesar cipher using letter distances

Attack using minimum letter spacing

The Caesar cipher has one interesting property arising from its definition. Because it only shifts the letters, always by the same distance, the distances of the letters in the plaintext and ciphertext remain the same.

For example, if the plaintext were "abe" and we encrypted it with the key "g", we would get the ciphertext "ghk". In doing so, the distance between the letters "a", "b", denoted by |a, b|, is equal to one: |a,b| = 1 and for the letters in the ciphertext, |g, h| = 1. Similarly for the pair |b,e| = 3 and |h,k| = 3 and finally for the pair |a,e| = 4 and |g,k| = 4.

The only problem arises if we go over the last letter, the "z". Then it doesn't fit. If we encrypted "xz" with the key "c", we would get the ciphertext "zb". Not |x,z| = 2, but |z,b| = 24.

To make it fit, we must always count the shorter of the paths. That is, we can get from "b" to "z" either in the direction "bcd...xyz", which would return a distance of 24, or in the opposite direction "baz", which would return a distance of 2 - the correct distance. So we will always take the shorter of the two distances. We'll call this distance the minimum distance of the letters.

The idea of the attack

In the tables we find the three most frequently used letters in the Czech text. These are "e, a, o". Now in the cipher text we find the six most frequent letters. (Why six and why three? It doesn't really matter, but this combination gives pretty good results.) In the six most frequent letters, we now find a triplet of letters that have the same minimum distances between them as the triplet of letters "e, a, o". If we find such a triplet, we have probably found a triplet of letters to which the triplet of letters "e, a, o" has been encrypted. From this information we can easily derive the cipher key.

Again, a tool is provided that performs this algorithm. Insert the Caesar cipher encrypted text into the text box and the tool will attempt to break and decrypt the text.

Ciphertext: