Lazo Lab Sign up

Cryptography / Classic ciphers

Lesson 2 of 25

The Caesar cipher

Julius Caesar shifted each letter three places: A becomes D, B becomes E. With only 25 possible shifts, it's broken by trying them all.

Key points

  • Shift every letter by a fixed amount
  • ROT13 is a Caesar shift of 13
  • Try it in the Cipher Crack game
def caesar(text, k):
    return "".join(
        chr((ord(c) - 65 + k) % 26 + 65) if c.isupper() else c
        for c in text.upper())
Watch a video on thisOpens YouTube search results for “The Caesar cipher” in a new tab

Quiz · +10 XP

With a shift of 3, what does HELLO become?

Log in to save progress and earn XP.