What is Caesar Cipher (with Example)

Caesar cipher is a substitution cipher where each letter of the plaintext is replaced with another letter that has been either shifted up or down the alphabet. For example, a Caesar cipher with a shift of 3, A would be replaced by D, B would become E, and so on.

caesar cipher

It also goes with other names like (Caesar’s cipher, the shift cipher, Caesar’s code, and Caesar shift).

A brief history of Caesar cipher:

It was invented by Julius Caesar with the aim of sending messages to his troops. He used a shift of 3 in the letters of the alphabet to encrypt messages.

Augustus also used Caesar cipher with a slight variation:

He shifted every letter with one space to the right to scramble the message.

Are you interested in finding out more about ciphers and codes?

The Codebreakers – The Story of Secret Writing book by David Kahn is what I would start with.

Caesar Cipher

In this guide I will be discussing the following:

  • How to solve the Caesar cipher.
  • Various Caesar cipher variants.

How to solve Caesar cipher

How to encrypt using Caesar cipher

For example, if I decide to use a shift of 3 to encode my message:

caesar cipher


“A” will become “D”, “B” will become “E”, “C” will become “F” and so on down the alphabet.

To encode a simple message is equally easy as all you have to do is match each letter of the plaintext to the corresponding shifted letter to come up with the ciphertext.

Here is an example:

Plaintext: Learning cryptography is fun.

Ciphertext: Ohduqlqj fubswrjudskb lv ixq

How to decrypt Caesar cipher

To decrypt a message encrypted with the Caesar cipher requires you to have the key used. The easy way to go about is to generate a table using the key that was used to encrypt the message.

The benefit of this step is to enable you to quickly decode the message.

After you have the table decryption process is as easy as match every letter of the ciphertext to the right letter on the table to get the original message.

Here are is an example (use shift 3) for you to decrypt:

Ciphertext: Vkliw flskhu lv dzhvrph

Plaintext: ?

Here is a tool to decrypt/encrypt Caesar automatically.

How to recognize Caesar ciphertext

Often messages encoded using the Caesar cipher have a shift in their frequency analysis diagram that is equal to the selected shift.

Also, the index of coincidence of ciphertext is the same as that of the plaintext.

How to decipher Caesar without knowing the shift

The best method involves testing all shifts, this depends on the alphabet used. For example, if the alphabet has 26 letters, then you only have 25 shifts to try.

How to encrypt digits and numbers using Caesar cipher

Normally Caesar cipher is only used with letters of the alphabet. But there are various ways it can be used to encrypt numbers.

  • Write the numbers in Roman numerals, thus the numbers become letters in order to encode them.

Here is an example:

Digit “9” becomes letters “IX” which becomes letters “LA” when a shift of 3 is applied.

  • Shift the numbers with the same shift as the letters.

Here is an example:

Digit “9” would become digit “12” when a shift of 3 is used.

  • You can also integrate numbers in the alphabet.

Here is an example:

Consider the alphabet “ABCDEF123”, the digit “21” would become letters “BA” when a shift of 3 is applied.

Why the name Caesar Cipher

Julius Caesar used this technique to send messages for military purposes. For instance with Cicerone using shift 3.

What are other Caesar Cipher names

Caesar cipher is also known as Shift Cipher.

Here are Caesar variants with hidden shifting property:

  • CD code, C = D, the shift is 1
  • Jail (JL) code, J = L, the shift is 2
  • Ellen (LN) code, L = N, the shift is 2
  • Cutie (QT) code, Q = T, the shift is 3
  • Eiffel (FL) code, F = L, the shift is 6
  • WC code, W = C, the shift is 6
  • Empty (MT) code, M = T, the shift is 7
  • Baden Powell (scouts founder), B = P, the shift is 14
  • Any (NE) code, N = E, the shift is 17
  • See You (CU) code, C = U, the shift is 18
  • I See (IC) code, I = C, the shift is 20
  • Easy (EZ) code, E = Z, the shift is 21
  • CEASAR (with a wrong spelling) where E=A or A=E, the shift is either +4 or -4 (=22)
  • Any 2-letter code that can give an association between an encrypted char and the plain one
  • ROT13 code, the shift is 13 and reversible
  • ROT5 code for digits, the shift is 5 and reversible
  • ROT47 code for ASCII printable characters, the shift is 47 and reversible
  • More generally ROT-N with N the shift, if N < 26 then the Latin alphabet is used, else it can be any other custom alphabet.

How to cipher CAESAR with the Caesar code

Here are 25 ways to cipher Caesar by itself:


How to crack a Caesar cipher

It is very easy to break this cipher considering that there are only 25 possible keys.

It should not be used today as it’s a weak (insecure) cipher and offers no security at all.

Caesar cipher is very vulnerable to attacks considering the power of modern computers that can evaluate a lot of combinations in just seconds.

Are you interested in learning how to break codes?

The Elementary Cryptanalysis – A Mathematical Approach book by Abraham Sinkov is what I would recommend.

Here are ways to crack this cipher:

  • Brute force attack: If you don’t have the key you easily decrypt a message by trying all the 25 possible combinations.
  • Frequency analysis: since the structure of the message doesn’t change that much, you can easily recognize patterns in the letters and with enough time you will be able to decode the message without even requiring a key.

For example, if the language used is English, you can start by replacing the most frequent letter in the message with the letter “e”.


Please enter your comment!
Please enter your name here