Caesar cipher

From TheAlmightyGuru
Jump to: navigation, search

A Caesar cipher, or shift cipher is a primitive form of encryption named after Julius Caesar who used the algorithm to encrypt his letters. The algorithm turn plaintext into ciphertext by shifting the letters of the plaintext forward along the alphabet. The cipher can be adjusted to work with any alphabet for any language. When used in English, the cipher is commonly called "ROT13" or "rotate 13," which shifts each letter in the plaintext forward 13 values in the alphabet.


To encrypt text using the Caesar cipher, first, choose the number of letters in you will be shifting the alphabet. Next, simply rotate each letter in the plaintext forward in the alphabet that number of letters. If you reach the end of the alphabet, rotate back to the beginning. For example, using a Caesar cipher with a shift of 1, A becomes B, B becomes C, C becomes D, and so forth until you get to Z, which rotates back to the beginning of the alphabet and becomes A. The example below uses a shift of 13.

 plaintext: ATTACK TONIGHT
       key: 13
ciphertext: NGGNPX GBAVTUG


To decrypt ciphertext that has been encrypted with the Caesar cipher, you need only to rotate the letters in reverse the name number they were reversed forward. If the letters were encrypted with a shift of 1, then, to decrypt the ciphertext, C becomes B, B becomes A, and A becomes Z again.

ciphertext: TLLA HA AOL SHRL
       key: 7
 plaintext: MEET AT THE LAKE


  • The biggest benefit of the Caesar cipher is how easy it is to use. A short message can be encrypted and decrypted in your head, and even longer messages only need a paper and pencil. The cipher doesn't require a computer, rely on complex mathematics, or use random values.
  • The ciphertext is well enough obfuscated that it is unreadable to most people at a glance.


  • Unfortunately, the simplicity of the Caesar cipher is its downfall. The encryption is trivial to decrypt without the key. Even without a computer, a brute force attack can be made of all possible shifts in a short period of time, and since the shift is constant throughout the entire message, only the correct key will produce an intelligible plaintext.