How the Caesar Cipher Works

The Caesar cipher is one of the simplest and most widely known encryption methods. It works by shifting each letter in a message forward through the alphabet by a fixed number of places.

Quick facts: Caesar cipher
Invented by Julius Caesar
Era Roman Republic / ancient Rome
Cipher type Substitution cipher
Key space 25 meaningful non-zero shifts
Security level Very weak by modern standards

Background

The Caesar cipher is a substitution cipher. That means each letter in the original message is replaced by another letter according to a rule. In this case, the rule is simple: every letter is shifted by the same amount.

Diagram showing a Caesar cipher wheel
A cipher wheel makes it easier to visualise the repeated letter shift.

For example, with a shift of 3, A becomes D, B becomes E, and so on. When the shift reaches the end of the alphabet, it wraps back to the beginning again.

How it works

Start with a normal readable message, called the plaintext. Then choose a shift value, such as 3. Move each letter forward by that amount to create the ciphertext.

Key idea

In a Caesar cipher, the key is simply the size of the shift. A key of 3 means every letter moves forward by three places.

Encryption

To encrypt a message, shift each letter forward by the chosen amount.

Decryption

To decrypt the message, shift each letter backward by the same amount.

Worked example

Suppose we want to encrypt the word HELLO using a key of 3.

H → K
E → H
L → O
L → O
O → R

So the encrypted result is KHOOR.

Why it is weak

The Caesar cipher is not secure for real-world protection. One reason is that there are only a small number of possible shifts. In the English alphabet, there are only 25 meaningful non-zero keys.

Vulnerability

Because there are so few possible keys, an attacker can simply test every shift very quickly. This is called a brute-force attack.

This is why the Caesar cipher is useful today mainly for learning, not for actual secure communication.

See also