- Mathematics
- Class 11
- Project 3
3Code Makers and Code Breakers: Modular Arithmetic in Secret Messages
Teams encrypt messages with shift (Caesar) and affine ciphers, turning letters into numbers 0–25 and using arithmetic "mod 26", like a clock that wraps around. Rival teams then try to break the codes, first by trying all shifts and then with letter-frequency analysis. Finally students see why modern codes use huge numbers that are easy to multiply but very hard to factorise.
- Class and age
- Class 11 · 16–17
- Activity type
- Group
- Time needed
- 60–90 minutes
- Difficulty
- Medium
- Estimated budget
- Almost free
Mathematical concepts
- Modular arithmetic (clock arithmetic)
- Functions and their inverses
- Multiplicative inverses mod 26 and why gcd(a, 26) = 1 is needed
- Frequency analysis
- The idea of one-way functions
Learning objectives
- Calculate with remainders confidently.
- Encrypt and decrypt with shift and affine ciphers.
- Break a simple cipher using frequency data.
- Explain why some keys fail.
Real-life connection
Every mobile banking transfer, password and secure website depends on cryptography built on modular arithmetic and prime numbers.
Materials required
- Cipher wheels (two paper circles with letters, joined at the centre)
- Worksheets with letter-to-number tables
- A long piece of English text for counting letter frequencies
Step-by-step instructions
- Make a cipher wheel. Encrypt a short message with a shift of 3: each letter number x becomes (x + 3) mod 26.
- Swap messages with another team and decrypt by shifting back.
- Break a shift cipher with an unknown key by trying all 25 shifts. Why is this easy?
- Count letters in a long English text and draw a frequency bar chart. Which letters are most common?
- Break a longer secret message by matching its most common letters to the chart.
- Try the affine cipher: x becomes (5x + 8) mod 26. Encrypt a word.
- Find the number that "undoes" multiplying by 5 mod 26 (it is 21, because 5 × 21 = 105 = 4 × 26 + 1) and decrypt.
- Try the key a = 13. What goes wrong? Explain using common factors with 26.
Mathematical explanation
Working mod 26 means keeping only the remainder after dividing by 26, so 25 + 3 = 28 becomes 2: Z wraps round to C. A shift cipher has only 25 keys, so trying them all is quick. Letter frequencies in a language are fairly stable, so the most common symbol in a long secret message probably stands for a common letter such as E. In the affine cipher, multiplying by a can be undone only if a has no common factor with 26; with a = 13, every even number and every odd number land on just two values, so different letters become the same and the message cannot be recovered. Modern systems rely on operations that are easy one way and extremely hard to reverse without a secret key.
Expected project output
A cipher wheel, encrypted and decrypted messages, a letter-frequency chart and a written explanation of why some keys fail.
Skills developed
- Modular arithmetic
- Inverse functions
- Data-based code breaking
- Logical reasoning
Assessment criteria
- Encryption and decryption are correct.
- Frequency analysis is used to break a code.
- The inverse of 5 mod 26 is found and checked.
- The failure of a = 13 is explained with factors.
Extension challenge
Count how many valid keys the affine cipher has (values of a with no common factor with 26, times 26 shifts). Is it secure against a computer?
Safety and inclusion
Codes are for fun and learning. Never use them to hide unkind messages, and never share real passwords or PINs, even in a game.