dcf.cymru stimulus sheet · Computer Science · Year 9

Clwb Codio Conwy: the intercepted message

The code club, the message and the people are invented. The Caesar cipher, frequency analysis and the English letter percentages are real.

1. What happened

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.

2. Words you need

WordMeaning
plaintextthe readable message before it is scrambled
ciphertextthe scrambled message
encryptturn plaintext into ciphertext
decryptturn ciphertext back into plaintext
keythe 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 forcetrying every possible key until one works
frequency analysiscounting how often each letter appears and comparing the counts with normal English

3. The alphabet strip

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.

LetterABCDEFGHIJKLM
Position0123456789101112
LetterNOPQRSTUVWXYZ
Position13141516171819202122232425
Encrypt: new position = (old position + key) MOD 26 Decrypt: old position = (new position - key + 26) MOD 26 Example with key 3: Y is 24. (24 + 3) MOD 26 = 27 MOD 26 = 1, which is B. So Y becomes B.

MOD gives the remainder after dividing. Adding 26 before decrypting stops the answer going below 0.

4. The intercepted message

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.

Line 1: AOL ALHT DPSS TLLA HA AOL NHAL VM JVUDF JHZASL HA ZLCLU VU ABLZKHF LCLUPUN. Line 2: IYPUN AOL THW, AOL AVYJO HUK AOL ZWHYL RLFZ. Line 3: ALSS UVIVKF DOLYL DL HYL NVPUN. Line 4: PM AOL DLHAOLY PZ IHK DL DPSS TLLA PU AOL SPIYHYF PUZALHK HUK ZLA VMM AOL ULEA KHF.

Lines 1 and 2 contain 94 letters. Lines 3 and 4 contain 90 letters.

5. How often letters appear in normal English

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.

0 4 8 12 Percentage of letters ABCDEFGHIJKLMNOPQRSTUVWXYZ Letter
LetterETAOINSHRDLCU
%12.79.18.27.57.06.76.36.16.04.34.02.82.8
LetterMWFGYPBVKJXQZ
%2.42.42.22.02.01.91.51.00.80.20.20.10.1

The most common English letters are E, then T, then A. The most common 3-letter word is THE.

6. Modern encryption

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.