🛠️ Elf Cipher Strip
How a Caesar cipher works
Every letter slides forward in the alphabet by the same amount, called the shift (or the key). With a shift of 3, A becomes D, B becomes E, and at the end it wraps around, so X becomes A. Julius Caesar is said to have used this to send military messages more than 2,000 years ago.
Try it: set the strip to shift 3 and encode the word SNOW. (You should get VQRZ.)
List 1The easy one
List 2A riddle for a key
List 3No key at all
DebriefHow a computer breaks it
A Caesar cipher only has 25 possible keys. A computer can simply try every one of them, which is called a brute-force attack. Click to try all 25 on List 3:
- How long did the brute-force attack take? How long would it take you by hand?
- How did you know which of the 25 lines was the real message? (Could a computer tell, too?)
- The encryption that protects your phone and online banking uses keys with about 2128 possibilities, which is roughly 340 trillion trillion trillion. If a computer tried a trillion keys per second, about how long would it take?
- Frequency analysis only needed the message itself, not the key. What does that tell you about designing a good cipher?
Your turnSend a secret wish
Pick a secret shift, write your own wish, and trade the scrambled version with a partner. Don't tell them your key! Can they crack it?
Scrambled:
Cracking a partner's message? Paste it here and drag the shift on the Elf Cipher Strip until it makes sense:
⭐ BonusBuild a codebreaker with AI
Elf Bramble intercepted one more message, and nobody knows the shift. This time, don't crack it by hand. Get Google Gemini to help you write a Python program that cracks it for you.
- Open gemini.google.com and sign in with your school Google account.
- Ask Gemini to write Python code that decodes a Caesar cipher by trying every possible shift. Paste the scrambled message into your prompt. Be specific: say what the program should do and what it should print.
- Run the code. You can use Gemini's run button if it shows one, or paste the code into Google Colab.
- Find the line that makes sense and type the decoded message below.
- Find the line of code that actually shifts a letter. Explain to a partner how it works.
- What does the code do with spaces? Did Gemini handle them correctly the first time?
- Did the code have any bugs, or did you need to ask Gemini to fix something? What did you change in your prompt?
🕵️ Final challengeA real codebreaking job
Someone at the North Pole got smarter. This message doesn't use a shift. Every letter was swapped for a random different letter, so E might be G and T might be N. This is called a substitution cipher.
Your mission
- Get the data. Ask Gemini to write Python code that counts how often each letter appears in the message, from most to least common. Then ask for code that lists the most common one-letter, two-letter and three-letter words. Run it in Gemini or Google Colab.
- Make smart guesses. The most common English letters are E, T, A, O, I and N. The most common three-letter word is THE. A one-letter word is almost always A or I.
- Test your guesses in the workbench below. Type the real letter under each scrambled letter and watch the message appear. Green letters are your guesses.
- Look for half-finished words. If you see TH_T or C_RISTMAS, you can fill in the missing letter. Keep going until it all makes sense.
Codebreaker's workbench
Each box shows a scrambled letter and how many times it appears. Type your guess for the real letter. A red box means you used the same guess twice.
- Was Gemini's answer correct? How could you tell?
- Which worked better: asking AI for the answer, or asking AI to write code that helped you find it? Why?
- Real codebreakers at places like the NSA use computers to do the counting and testing. What part of the job still needs a human?