What's New
Q & A
Tip Jar
Tutorial: Breaking Caesar Substitution
This tutorial explains how to break a Caesar substitution cipher.


Breaking Caesar Substitution

Caesar substitution ciphers may have been good enough in Caesar's day when noone knew what a cipher was, but today they're pretty simplistic. The problem is the possible key space contains only 26 values. You can easily break a Caesar substitution cipher by simply trying all of the possible offsets 0 through 25 and seeing which one gives you a meaningful result.

In fact, it's even easier than that. In normal Elglish text, the letter E appears most often. To quickly break a Caesar substitution cipher, simply calculate the percentage of times each letter appears in the message. The letter that appears most is probably E. Assuming it is E, you can compute the offset that must have generated it.

For example, suppose the letter J appears most often in the ciphertext. Then the key must be 5 since E + 5 = J.

The exact distribution of the letters in the plaintext is very important here. You need to adjust the statistics of your letters depending on the language you think used in the plaintext. We have assumed the plaintext is English so E is the most common letter in the plaintext. If the message is in French or German, that may not be the case. Even worse, the message might be C++ code. In that case the most common symbol might be the semi-colon.

Even if you don't correctly guess which letter is E, you can always try all 24 possible offsets.

Back to top


  1. Write a program that takes ciphertext encrypted using Caesar substitution. Count the number of times each character appears and guess which one has plaintext value E. From that guess what the Caesar substitution offset is and reproduce the plaintext. Let the user try other offsets in case the program guesses incorrectly.
Back to top
Back to main cryptography tutorial

Subscribe to the VB Helper newsletter
Copyright © 1997-2001 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
www.vb-helper.com/crypto3.htm Updated