Computer · Demo 14 of 19

How do you keep a secret safe?

A safe hides things behind a secret number. A cipher hides a message behind a secret key. Open the safe, find the note inside, and learn how codes are made, and how they are cracked.

WKH WUHDVXUH LVXQGHU WKH RDN WUHHABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZIN OUT
Dial0
Lock
Game
Mode
Key0
Your message
Message
Tape

Controls

Lock
Cipher mode
Message
Tape
The lock wheel the dial is turning nowCipher wheel: outer ring plain letters, inner ring secret lettersThe dial turns the blue wheel. Turn it to the first number and press Next, then the second number, Next, then the third number, and try the handle. New game puts a new combination on the sticky note and starts everything again. The window shows the wheels: when every gate is at the top, the fence bar drops in and the handle can pull the bolts back. On the cipher wheel, each plain letter on the outside sits over its secret letter on the inside; the key is how far the inside ring is turned.

Watch it work

A short film of this machine in action. Watch it, then try the challenges yourself.

What you're seeing

The safe's lock has three wheels behind the dial, each with a notch called a gate. Only when all three gates line up at the top can the fence bar drop in and the handle pull the bolts back. Someone stuck the combination on the door with a sticky note: anyone can read it. That's the most common way real secrets leak!

The cipher wheel is a Caesar cipher: every letter is swapped for the letter a fixed number of places further along the alphabet. That number is the key. Right now: A → A.

Try this

0 of 4 solved
  1. Open the safe using the combination on the sticky note.Turn the blue wheel to the first number and press Next; the second, Next; the third, then Handle.
  2. Pick the Note message and decode it. The note says it was written with key 3.Mode: Decode, then set the key.
  3. Write your own message, encode it with a key, press Use the output, then decode the secret back with the same key.Your friend needs the same key, but you should never write it on the message!
  4. Crack the intercepted Spy message. Nobody told you the key.There are only 25 keys to try. Watch the tape until it makes sense.

Why it works

A secret only works if the key stays secret. The method (turn the ring) can be public; the key (how far) must not be. That's why you send the key a different way from the message, and never stick it on the door.

The Caesar cipher is easy to crack because it has only 25 useful keys: you can just try them all. This is called a brute-force attack. The safe has 40 × 40 × 40 = 64,000 combinations: trying one every 10 seconds would take over a week.

Real encryption (the padlock in your web browser) works on the same idea, a public method and a secret key, but the key is a number so big that trying every possibility would take all the computers on Earth longer than the age of the universe.

Go deeper AGES 14–16

With letters numbered A = 0 … Z = 25, the Caesar cipher with key k is:

secret = (plain + k) mod 26  ·  plain = (secret − k) mod 26

"mod 26" means wrap round: after Z comes A again. Key now: 0.

There's a faster way to crack it than trying every key: frequency analysis. In English, E is the most common letter. Find the most common letter in a long secret message, and it's probably E, which tells you the key. Arab scholar Al-Kindi described this trick over 1,100 years ago.

Modern ciphers like AES use keys of 128 or 256 bits. A 128-bit key has 2¹²⁸ ≈ 340,000,000,000,000,000,000,000,000,000,000,000,000 possibilities.