dcf.cymru stimulus sheet · Computer Science · Year 9
The code club, the message and the people are invented. The Caesar cipher, frequency analysis and the English letter percentages are real.
Clwb Codio Conwy is a code club for Year 9 pupils. Two members, Nia and Rhodri, have been sending each other messages scrambled with a Caesar cipher. Another member copied one of their long messages from the club noticeboard. Nobody told him the key. Your job is to find out whether a Caesar cipher kept the message safe.
| Word | Meaning |
|---|---|
| plaintext | the readable message before it is scrambled |
| ciphertext | the scrambled message |
| encrypt | turn plaintext into ciphertext |
| decrypt | turn ciphertext back into plaintext |
| key | the secret that tells you how to encrypt and decrypt. In a Caesar cipher the key is how many places each letter moves along the alphabet. |
| brute force | trying every possible key until one works |
| frequency analysis | counting how often each letter appears and comparing the counts with normal English |
Each letter has a position number. To encrypt, move each letter forward by the key. If you go past Z, carry on from A again. To decrypt, move each letter back by the key. Spaces and punctuation are not changed.
| Letter | A | B | C | D | E | F | G | H | I | J | K | L | M |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Position | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |
| Letter | N | O | P | Q | R | S | T | U | V | W | X | Y | Z |
| Position | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 |
MOD gives the remainder after dividing. Adding 26 before decrypting stops the answer going below 0.
The message was written in English in capital letters. Spaces and full stops were left in. The lines are numbered so that you can share the counting.
Lines 1 and 2 contain 94 letters. Lines 3 and 4 contain 90 letters.
These are approximate percentages for a large amount of ordinary written English, rounded to 1 decimal place. In a long English text, about 12.7% of the letters are E.
| Letter | E | T | A | O | I | N | S | H | R | D | L | C | U |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| % | 12.7 | 9.1 | 8.2 | 7.5 | 7.0 | 6.7 | 6.3 | 6.1 | 6.0 | 4.3 | 4.0 | 2.8 | 2.8 |
| Letter | M | W | F | G | Y | P | B | V | K | J | X | Q | Z |
| % | 2.4 | 2.4 | 2.2 | 2.0 | 2.0 | 1.9 | 1.5 | 1.0 | 0.8 | 0.2 | 0.2 | 0.1 | 0.1 |
The most common English letters are E, then T, then A. The most common 3-letter word is THE.
Websites, banking apps and messaging apps do not use Caesar ciphers. They use modern encryption such as AES (Advanced Encryption Standard). A 128-bit AES key can be any one of 2128 numbers, which is about 3.4 × 1038 possible keys. Modern encryption also mixes the letters up so that letter patterns such as “E is common” no longer show in the ciphertext.
When a web address begins https and the browser shows a padlock, the data travelling between your device and that website is encrypted. The padlock does not prove the website itself is honest: a scam website can have a padlock too.