Shift Cipher

Suggested experiment

  • Enter english text in the INPUT TEXT box.
  • Enter a key number from 0 to 25 in the SHIFT AMOUNT box.
  • Click ENCRYPT to encrypt the message with that key.
  • Click FREQUENCY
  • Use the slider to see the effect of decrypting with various keys
  • The highest point on the graph should correspond to the key you chose.
  • This works best if the plaintext is ordinary english, and is long.
  • Click SECRET, and try the above to decrypt a secret message chosen by the program.

Overview

In the shift cipher, every plaintext character is shifted forward in the alphabet an equal distance, wrapping around when it goes past "z". The key is the distance to shift. The particular case of a key of 3 is called a "Caesar cipher", after Julius Caesar, who was described by Suetonius as using it to encrypt military messages.

Enter the text to be encrypted in the INPUT TEXT box, and the key (the amount to shift, from 0 to 25) in the SHIFT AMOUNT box. Then click ENCRYPT to encrypt it. Or click SECRET to have the computer choose a message and key.

Frequency

Click on the FREQUENCY tab to break the cipher. The black bars give the frequency of each letter in standard english. The red bars give the frequencies for plaintext if the ciphertext is decrypted using the key in the lower box SHIFT AMOUNT. Use the slider to try different keys until the red bars seem aligned with the black bars. At that point, you've found the key. Type the key into the upper SHIFT AMOUNT box and click on DECRYPT to see if it will decrypt correctly to readable english text without spaces.

This cipher is trivial to break. A more useful one might be to use different shifts for different characters in the message. That is the Vigenère cipher.