The Shift Cipher: Classic Cryptosystem Analysis

The Dude
Classic Cryptosystem Analysis: Shift Cipher

The shift cipher, also known as the caesar cipher, is one of the oldest cryptosystems known to man. It is very simple, and rather uneffective, however for anyone interested in cryptography, it is important to understand the classic cryptosystems, why they are weak, and how to make them better. This article assumes a basic understanding of cryptology terminology, but will tell you everything you need to know about this simple cryptosystem.

The Cryptography

The shift cipher is really beautiful in its simplicity, which is unfortunately what makes it a weak cryptosystem. To start, you need to map all the letters of the English alphabet to numbers, starting with 0. So, a is 0, b is 1, all the way to z is 25. Once you have obtained your alphabet mapping, you need to pick a number. Now you can pick any number you want, however all arithmetic in this cryptosystem, and indeed most others, are done modulo 26, which means any number over 26 will just wrap around to n (mod 26). Once you have chosen your key, you begin to transform each letter of your plaintext by that number. For instance, if your key was 2, a becomes C, b becomes D, etc. To decrypt, simply do the transformation in reverse. C becomes a, D becomes b, etc. That's it.

The Cryptanalysis

Breaking the shift cipher is really easy, because of the fact that there are only 26 possible keys. It would be entirely possible to just brute-force your way through it by hand, it would just be really tedious. A computer program could brute force the cipher in literally mili-seconds, and this is what makes the shift cipher so weak. It is also possible to do frequency type attacks on this cipher, because it is both symmetric and one-to-one. To do a frequency-based attack on this, or indeed, any other primitive cipher like this, you need some background about the english language (or whatever other language your plain/ciphertext is in). Because this is beyond the scope of this article, just take my word for it that E is the most common letter in the english alphabet, followed by 4 other groups of letters ranked by frequency. These are:

T A O N I

R S H L D

C U P F M

Y B G V

K Q X J Z

So, what can you do with this information? Well, you look for the most frequent occuring letters in the ciphertext, whatever the most common letter is, assume that's e in plaintext. By simple subtraction (key = Most Common Letter - E) you get a very good guess as to the key. If that is not the key, proceed to the next common letter and continue until you find the plaintext that makes sense.

There are many other frequency-type attacks, as well as a ton of research into the english language and probability. You could examine digraphs,trigraphs, initial and final letters, vowel distribution, etc. For such a simple cipher this is really not necessary though.

Summary

C = ciphertext

p = plaintext

k = key

Encryption:

C ---> p + k (mod 26)

Decryption:

p ---> C - k (mod 26)

Number of Possible keys:

26

Strength:

Virtually none.

As you can see, the shift cipher, although it has no security applications in todays world, is interesting from a historical standpoint and provides insight into the evolution of modern cryptology.

Published by The Dude

The dude enjoys all things typical dudes do. Video Games, Cars, Humor, Girls, Legal and Illegal drugs, Computers. Ya know, the usual. The Dude has an awesome new site coming soon. Be sure to look for it. It'...  View profile

1 Comments

Post a Comment
  • Abasster2/17/2009

    I'm a fan of National Treasure movie so I find this article a good read.

To comment, please sign in to your Yahoo! account, or sign up for a new account.