Substitution cipher
In a substitution cipher, each letter is always replaced by the same other letter, following a list we call the substitution alphabet, or key. If the key says that A becomes Z, B becomes E and R becomes O, the word "BAR" is written "EZO". The Caesar cipher and Atbash are special cases, because their key follows a fixed rule. Here you choose the key, and there are a great many of them: over 400 septillion with 26 letters.
A little history
Substitution ciphers were used for centuries in diplomacy and war. In the 9th century the Arab scholar al-Kindi explained how to break them with frequency analysis: in a long text some letters appear far more often than others (E and T in English, E and A in Spanish), so the letters that repeat most in the cipher text give away those of the message. In 1586 Mary, Queen of Scots, was condemned because her enciphered letters had been decoded this way.
Try it
Type a keyword and press "Use keyword": its letters go first, without repeats, followed by the rest of the alphabet in order. You can also press "Shuffle" for a random key in which no letter stays in place, or type the key letter by letter in the boxes; the arrow keys move from box to box.
If a letter is repeated or missing, its boxes get a dashed border and a message tells you what to fix. Meanwhile, the result keeps using the last complete key.
Its letters first, without repeats, then the rest in order.
35 of 600 characters
QLJLOOLV VA LMAK QDA QOAZPTOA BDAPQ
The key
Each letter in the top row is encoded as the letter under it. To decode, find the letter in the bottom row and write the one above it.
| Letter | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Becomes | Z | E | B | R | A | S | C | D | F | G | H | I | J | K | L | M | N | O | P | Q | T | U | V | W | X | Y |
In the classroom
- Keyword challenge. Hand out an enciphered message and hide the keyword in another puzzle of the escape room, such as a character's name. With it, students rebuild the table and decode the message.
- Frequency detectives. With older students, encode a long text without giving the key and ask them to count which letters appear most. It is a very visual way to work on statistics and spelling.
- Team keys. Each team makes up a key with "Shuffle", encodes a message and passes it to another team together with the table.
Tips
- Choose keywords with few repeated letters, or use "Shuffle": with a keyword, the last letters of the alphabet sometimes stay the same.
- Give younger students the whole table; give older ones only part of it.
- With the 27-letter alphabet, Ñ is enciphered too. If your message has no Ñ, you can use the 26-letter one.
- Accents are dropped and the result is written in capitals; digits and punctuation do not change.
Printable worksheet
Practise this cipher on paper: a worksheet with the key and two exercises, ready to print or download with its answer key. Open the worksheet