Skip main navigation

Hurry, only 10 days left to get one year of Unlimited learning for £249.99 £174.99. New subscribers only. T&Cs apply

Find out more

The Caesar cipher

In this article we describe in detail how the Caesar cipher worked.
A bust of Julius Caesar
© University of York

The Caesar cipher is the simplest example of a substitution cipher, in which we replace one letter in our text with another letter, in order to confuse the reader by jumbling up the letters.

The historian Suetonius, writing in AD121, said this of Julius Caesar (see Section 56 of his book Vita Divi Julii (Life of Julius Caesar)):

There are also letters to Cicero, and other confidants. If he had anything confidential to say, he wrote it in cipher, so that by changing the order of the letters of the alphabet, not a word could be made out. If anyone wishes to decipher these, so as to get to their meaning, they must substitute the fourth letter of the alphabet, namely D, for A, and so with the other letters.

In other words, what Caesar did was to replace each letter of the message that he wanted to send by the letter three places along in the alphabet. As we saw in the video, this means replacing each occurrence of the letter (A) by the letter (D), each (B) by the letter (E), and so on. Let’s write (Ato D), (Bto E) etc as shorthand for this replacement rule. When we reach the end of the alphabet, we go back to the beginning: so (Wto Z), (Xto A), (Yto B) and (Zto C). So if we want to encipher the word CODE, it would become FRGH.

Your turn!

Try the following exercises, to check your understanding; use the comments to report how you’re getting on, but be careful not to give away the answers!

  1. What does the word CAESAR become, when encrypted using the Caesar cipher?
  2. A message was encrypted using the Caesar cipher, giving the result KHOOR EUXWXV: what was the original message?

Even with our (Ato D) notation, it’s still quite cumbersome to have to write out what each letter gets replaced by in the Caesar cipher. It’s much simpler to refer to each letter by its position in the English alphabet (so (A=1), (B=2), etc), and to say that Caesar’s rule is to add 3 to each number. (So (S=19 to 19+3 = 22 = V), etc.)

However, we again hit the problem of what to do when we reach the end of the alphabet. We know that we want (Xto A), but that doesn’t seem to work when using numbers: (X=24), so adding 3 gives 27, not 1. So, for this to work, we need a way of making 27 equivalent to 1, 28 equivalent to 2, and 29 equivalent to 3. The trick is to use something called modular arithmetic.

© University of York
This article is from the free online

The Mathematics of Cryptography: From Ancient Rome to a Quantum Future

Created by
FutureLearn - Learning For Life

Reach your personal and professional goals

Unlock access to hundreds of expert online courses and degrees from top universities and educators to gain accredited qualifications and professional CV-building certificates.

Join over 18 million learners to launch, switch or build upon your career, all at your own pace, across a wide range of topic areas.

Start Learning now