Caesar cipher practice: a worked example and three self-checks

A Caesar cipher replaces each letter with another letter a fixed distance along the alphabet. Use A=0 through Z=25. To encrypt with shift k, calculate (x+k) mod 26; to decrypt, calculate (y-k) mod 26.

Worked example: shift 3

The word ZEBRA becomes CHEUD. Z wraps to C, E moves to H, B moves to E, R moves to U, and A moves to D. Spaces and punctuation can stay unchanged; write down that convention before exchanging messages.

Three practice questions

  1. Encrypt ATTACK AT DAWN using shift 3.
  2. Decode KHOOR with shift 3.
  3. If A maps to N, what is the shift and why does applying it twice restore the original text?

Answers: DWWDFN DW GDZQ; HELLO; shift 13, because 13+13=26 and the alphabet wraps once.

How to check your reasoning

Try the examples in the Caesar Cipher interactive tool. Enter a short message, record your chosen shift, and compare each letter with a hand calculation. If the output differs, check direction, alphabet position, and wraparound before changing the key.

For an unknown shift, test all 26 possibilities, including the identity shift. Short text can produce several plausible answers, so use context rather than assuming the first readable fragment is correct.

Security lesson

This is a learning cipher. It has only 25 nonidentity shifts and preserves letter patterns, so it is unsuitable for passwords, private messages, or sensitive records. Its value is showing modular arithmetic and the difference between encoding and secure encryption.

Teaching extension: ask a partner to invent a four-word message, encrypt it, and trade ciphertext without the shift. Explain which clues helped recover it. Then use caesarcipher.org to verify the result.