numbers background picture of Bill

Caesar's Shift Code

Who hasn't had the need to pass some secret information to a friend? That's what secret codes are all about. There are many kinds of codes, but we are only going to learn about one in this experiment. Sometimes this code is called the shift code, and sometimes it is called Caesar's code. Of its two names, I like the first one best because it describes how its coding and decoding process works.

Let's get started. Imagine two lines, each containing the alphabet and both lined up letter for letter like this:

Line 1: 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
Line 2: 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

Next, let's shift Line 1 one place to the right:

Line 1:    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
Line 2: 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

Oops! The first space in Line 1 is now blank, and there is an extra letter hanging over the end. We need to fix both problems. Here is how. We simply move any letters hanging over on the right to the blank spaces on the left side. In this case there is only one letter hanging over, the Z, and one space to fill. Moving it to the left we have:

Line 1: Z 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
Line 2: 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

Now we are ready to code a secret message, but before we do we should make a note of the key. What's a key? Well, the key is what will let your friend in on how to decipher, or decode your message, once he or she gets it. In the example above the key is B. When we tell our friend the key is B we are telling him or her to line up the A in line 1 with the B in line 2, and fill in the blanks before the A with any letters that overhang on the right.

Let's encipher or code the name, JOHN with the key of B, as above. First find each letter in JOHN on Line 1,and write down the letter on Line 2 that is directly below it. Starting with J we see that K is directly below, so we write down K. Continuing in the same way for all the letters in JOHN you should get KPIO.

To decipher KPIO, or turn it back into JOHN, your friend would either have to do a lot of guessing, or know ahead of time that you were using B as your key. Let's assume for now that your friend knows that you will be using B as your key and that he or she is able to produce the shifted alphabet exactly like you did. To decode or decipher your message, your friend would only have to look up every letter of your coded message in Line 2 and write down the letter above it in Line 1. In this way, KPIO becomes JOHN. This is just the reverse of the procedure you used to code the message in the first place.

This is a lot of work, especially if you don't know the key, or number of letters your friend shifted the alphabet by. The good news is your computer can make this job a lot easier


Type in a word or a short phrase in the top box
Select Encipher to change Plaintext to Ciphertext
Select Decipher to change Ciphertext to Plaintext
Select the desired KEY (by "clicking" a letter button)
See the results in the bottom box
(Your Browser must be JavaScript Enabled for this Cipher to work!)

To "Break" a secret message that was enciphered using a Caesar Cipher,
place the secret message in the top space, click Decipher, and then
click each Key button in turn. One Key button will reveal the secret

Try this secret message - TY QVOUZVU DPSS IL OLYL AVKHF

Encipher Decipher



(JavaScript program written by Jim Hannon for Secret Code Breaker)

Copyright 2021, William Johnson