Stewdent.eu
▾

Caesar Cipher

The Caesar cipher is one of the oldest encryption methods, shifting each letter in a message by a fixed number of positions in the alphabet.

Last updated: 28 February 2026

★☆☆☆☆ Level 1computingDataencryptioncaesar-ciphercryptography3 min read

Report an error

What is a Caesar Cipher?

The Caesar cipher is named after Julius Caesar, who reportedly used it to send secret messages to his generals. It is a type of substitution cipher: each letter in the message is replaced with a different letter by shifting it a fixed number of positions along the alphabet.

The number of positions you shift is called the key.

How It Works

With a shift of 3:

PlainABCDE...XYZ
CipherDEFGH...ABC

So the letter A becomes D, B becomes E, and so on. When you reach the end of the alphabet, you wrap around (X→A, Y→B, Z→C).

Example: Encrypt "HELLO" with a shift of 3.

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

Encrypted message: KHOOR

Note

To decrypt a Caesar cipher, simply shift in the opposite direction by the same amount. To decrypt "KHOOR" with key 3: K→H, H→E, O→L, O→L, R→O → "HELLO".

Why It is Easy to Break

The Caesar cipher has a major weakness: there are only 25 possible keys (shifts of 1 to 25). An attacker can simply try all 25 possibilities until the message makes sense. This is called a brute-force attack.

Another method is frequency analysis: in English, 'E' is the most common letter. If 'H' appears most often in the cipher text, the shift is probably 3 (H is 3 ahead of E).

Warning

The Caesar cipher is not secure and should never be used to protect real information. It is only useful as an educational example of how basic encryption works.

ROT13

A popular variant of the Caesar cipher is ROT13, which uses a shift of 13. Because 13 + 13 = 26 (the length of the alphabet), ROT13 is its own inverse: applying it twice returns the original text. ROT13 is sometimes used on internet forums to hide puzzle spoilers.

From Caesar to Modern Encryption

The Caesar cipher shows us the key ideas behind encryption:

  1. A plaintext (the original message)
  2. An algorithm (the shifting method)
  3. A key (the shift amount)
  4. A ciphertext (the encrypted result)

Modern encryption uses the same three components, but with algorithms so complex that even the world's fastest computers cannot brute-force them in any reasonable time.

Practice Problems

Encrypt the word 'COMPUTING' using a Caesar cipher with a shift of 5. Show the substitution for each letter.

Show answer
C→H, O→T, M→R, P→U, U→Z, T→Y, I→N, N→S, G→L. Result: HTRUZNYSL.

A Caesar-encrypted message reads 'ROVVY'. A cryptanalyst tries all 25 possible keys and finds that shift 3 gives a recognisable word. What is the decrypted message?

Show answer
Shift back 3: R→O, O→L, V→S, V→S, Y→V. Decrypted message: OLSSV. Actually with shift 10 backward: R(17)→H(7), O(14)→E(4), V(21)→L(11), V→L, Y(24)→O(14). HELLO. (The correct answer is HELLO with a shift of 10.)