Meet Ziggy. Press play to watch the video.
Your mission
Ziggy the squirrel hides secret notes with a zigzag trick called the rail fence cipher. Today you will learn the trick.
- Watch Ziggy's video.
- Open each tab, from left to right.
- Earn four badges to unlock Ziggy's Vault.
Take your time. If you miss a question, you get a new one, so think before you click.
My badges
Teacher note
- Built for grades 3 to 5. Plan on 40 to 50 minutes, or two shorter sessions.
- Students cannot click until they get it right. A missed question swaps in a new question, and a missed code swaps in a new message.
- Messages are picked at random, so neighbors will not have the same answers.
- Ziggy's Vault is a team challenge. It works best with scratch paper, or graph paper, and a partner.
- The Zigzag Machine, a free encoder and decoder, stays locked until the vault is open. That way nobody can use it to skip the practice.
- Offline extension: students write a note on graph paper, trade with a partner, and whisper the number of rails.
- This page pairs well with the scytale lesson. Both ciphers move letters around instead of swapping them.
- Progress saves in the browser on this Chromebook only.
Same letters, new order
Most ciphers swap your letters for something new. The Caesar wheel swaps each letter for a different letter. Pigpen swaps letters for shapes.
The rail fence cipher is different. It keeps every letter. It only mixes up the order. Code makers call this a transposition cipher.
Say it like this: trans-puh-ZISH-un.
The name comes from old wooden fences that zigzag across a field. People say soldiers used this cipher in the American Civil War to send quick notes.
Step 1: Write in a zigzag
Pretend your paper has two rails, like a fence. Put the first letter on the top rail. Put the next letter on the bottom rail. Then go back up. Keep going: down, up, down, up.
Here the word SECRET sits on 2 rails. Follow the dotted line with your finger.
Leave out the spaces between words. Spaces give snoops a clue about your message.
Step 2: Read along the rails
Now make the code. Read the top rail from left to right. Then read the bottom rail from left to right. Write those letters in one long row.
The top rail says S C E. The bottom rail says E R T.
So the code for SECRET is SCEERT
The key is the number of rails
You can use more rails. With 3 rails, the zigzag takes two steps down, then two steps up. The letters land on rails 1, 2, 3, 2, 1, 2, 3.
With 3 rails, SECRET turns into SEERTC
The number of rails is the secret key. Your friend needs the same number to read your note. A different key makes a different code.
How to read a rail fence code
To read a code, you rebuild the same fence. You need the key, which is the number of rails.
- Look at the empty zigzag. It has one spot for each letter in the code.
- Fill the top rail first. Go left to right with the first code letters.
- When the top rail is full, fill the next rail.
- Read the zigzag: down, up, down, up.
No key? Try them all
A code breaker reads notes that were not meant for them. They do not know the key, so they test one key after another. When real words show up, the code is cracked.
Ziggy found three notes from a sneaky raccoon. Crack each one and answer its question.