Caesar Cipher and the frequency analysis attack

by Jerome Bradenbaugh
Courtesy of Fravia's pages of reverse engineering
The Caesar cipher is a substitution cipher based on shifting the letters of the alphabet by a integer key. Julius Caesar made this cipher famous, and used it to communicate with his cohorts.

a  b  c  d  e  f  g  h  i  j  k  l  m  n  o  p  q  r  s  t  u  v  w  x  y  z

In an ordinal sense, the letter a currently corresponds to 1, b to 2, c to 3, ... up to z at 26. Therefore, the default key is 1. Suppose you change the key to 4. Now d is 1, and the alphabet appears as follows:

d  e  f  g  h  i  j  k  l  m  n  o  p  q  r  s  t  u  v  w  x  y  z  a  b  c

To cipher the following message: The King brings things that cling to the Ring, just shift each letter in the message four places and substitute it with the new letter. The word The becomes Wkh. See for yourself:

a  b  c  d  e  f  g  h  i  j  k  l  m  n  o  p  q  r  s  t  u  v  w  x  y  z

d  e  f  g  h  i  j  k  l  m  n  o  p  q  r  s  t  u  v  w  x  y  z  a  b  c

And the entire message becomes

Wkh nlqj eulqjv wkdw folqj wr wkh ulqj

Of course you might want to make all letters uppercase and group the letters in twos or threes to make the word structure less obvious. Maybe like this:

wk hn lq je ul qj vw kd wf ol qj wr wk hu lq j

All the receiving party needs is the cipher text and the key. Here's the application:


To cipher enter the plaintext in the text area, select a key, then choose the Cipher button. It's that easy. This application will handle as much as 8-9K of text. After that, you run the risk of sucking up all your system's resources.

To decipher enter your ciphertext in the textarea, select the key with which the plaintext was ciphered, then choose the Decipher button.

The Crack

The crack for this cipher is more difficult than it is for the reversal, but not much. You need only try the remaining 25 (Actually 26 for this app; the space " " is included) letter shifts. One of them reveals the plaintext. Attacks such as these are known as frequency analysis.