Omni Calculator logo

How to break the Caesar cipher

Recall the original Caesar cipher is a shift code, where encoding happens by replacing each letter of the message with the letter that stands three places to the right.

As a consequence, to decode the cipher, you do the opposite: replace each letter with the letter that stands three places to the left. Knowing that, everyone can become a very efficient Caesar cipher code breaker.

Let us see an example. Suppose you've just received a message saying:

RPQL FDOFYODWRU

Let us do one letter at a time. To decrypt the initial R, take the alphabet and look 3 letters before: O. Then P stands for M, and so on. Once you do all the letters (or use Caesar cipher solver if you are in a hurry), you get the solution:

OMNI CALCVLATOR

Yay! We have decoded the Caesar cipher​!

But wait, did the sender make a mistake in the word "calculator"? Not necessarily! If the sender is a Roman citizen, it makes perfect sense that they would not distinguish between the letters that we nowadays know as "U" and "V". In fact, if you take a look at ancient Roman inscriptions, you will see V's all over the place, but no U's!

In the case of a shift cipher that uses a different key, the technique to break Caesar cipher is the same as above: you always decode Caesar cipher​ by moving in the alphabet to the right or to the left and the number of steps (the length of the shift) is exactly equal to the key of the cipher. Importantly, if the key is negative, you move to the left. Otherwise, move to the right, as in the original Caesar cipher.

Let us see an example. Imagine you want to send a message to your friend Robertus about the perfect holiday destination next summer. However, you don't want anybody else to know about it and book the tickets before you. The last time you spoke to Robertus, you agreed to use the shift cipher with key L=13L=13 (people are too superstitious to ever try to break the Caesar cipher's security with this ominous key!). The message you send to Bob reads:

NYCUN PRAGNHEV

Bob carefully decodes the Caesar cipher​, moving each letter 13 places to the left. He replaces N with A, Y with L, etc. (It helps to write down the whole alphabet...)

When he's done, he sees....

ALPHA CENTAURI

Wow, that's going to be an unforgettable journey! Omni's space travel calculator can help you plan it properly.

After you're back home, you may want to learn more about the shift code you've just applied, which is known as ROT13.

ROT13 is a particular case of shift cipher: it has key L = 13. Using ROT13 means, therefore, that we move in the alphabet 13 places to the right. Why is this cipher so exceptional?

For every shift cipher, we decode by moving to the left. However, since there are 26 letters, ROT13 has the advantage that applying another round of encryption to a text already encoded with ROT13 acts as decryption! This is how you break the Caesar cipher by... applying it again!

On the other hand, it means that if Robertus tried to tell yet another friend about your holiday plans and decided to encode:

NYCUN PRAGNHEV

Once again, using the shift cipher with L = 13, he would completely compromise the secrecy! As you can see, the shift cipher itself can break the Caesar cipher security.

It is actually very easy to break the Caesar cipher security. If you know the key, just follow the standard decryption procedure for shift ciphers.

If you wonder how to break Caesar cipher if the key remains unknown, there are some well-known techniques you can:

  • Decode Caesar cipher​ by brute force;
  • Make a smart guess, based on the most frequent words like "a" in English or "et" in Latin/French; or
  • Compare the frequency of letters in the message vs. the target language.

To master these techniques and become an efficient Caesar cipher code breaker, go and read our article on How to decrypt a shift cipher without the key?.

One of the most sophisticated techniques to break a Caesar cipher is performing a frequency analysis of the letters in the encrypted message. Knowing the frequency of letters in a given language, you can recover the shift length of the cipher.

However, if you wonder how to break a Caesar cipher most efficiently, very often the quickest method is just to try all 25 potential keys until you find the right one.

The standard technique to break a Caesar cipher with the key L is to:

  1. Carefully write down the ciphertext.
  2. Substitute each letter with the letter that stands:
    • L places to the left in the alphabet if L>0; or
    • L places to the right if L<0.
  3. You have just decoded the Caesar cipher​ , and you can read the secret message.

This article was written by Anna Szczepanek and reviewed by Steven Wooding.