Edexcel International Advanced Level Computer Science, point 3.2.3
Definition
A monoalphabetic substitution cipher replaces each letter of the plaintext with a different letter (or symbol), using one fixed substitution alphabet for the whole message. "Mono" means one: each plaintext letter always becomes the same cipher letter.
Function and characteristics
- The key is the substitution alphabet: a mapping from each plaintext letter to its cipher letter.
- It's a symmetric method (the same key is used to encrypt and decrypt), but very weak by modern standards.
- Spaces and punctuation are normally left unchanged (or removed), which gives away word lengths.
- The number of possible keys (arrangements of 26 letters) is . That is far too many to try by hand, but it is still a limited (finite) number, so an exhaustive search by computer will eventually find the key. In practice the cipher is broken much faster without trying them all (see frequency analysis).
A special case: the Caesar (shift) cipher
Each letter is shifted along the alphabet by a fixed number of places (the key). With a shift of 3:
- Encrypt: HELLO becomes KHOOR.
- Decrypt: shift back by 3.
- Wrap round at the end of the alphabet: with a shift of 3, XYZ becomes ABC (X → A, Y → B, Z → C).
- Only 25 possible keys (shifts 1 to 25), so it is easily broken by trying them all.
With numbers A = 0, B = 1, ..., Z = 25: and .
Operation: a general substitution key
A general monoalphabetic cipher can use any arrangement of the alphabet as the key. For example, a keyboard-order key:
| Plain | 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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Cipher | Q | W | E | R | T | Y | U | I | O | P | A | S | D | F | G | H | J | K | L | Z | X | C | V | B | N | M |
Encrypting
For each letter, find it in the plain row and write the letter below it.
HELLO WORLD:
| Plain | H | E | L | L | O | W | O | R | L | D | |
|---|---|---|---|---|---|---|---|---|---|---|---|
| Cipher | I | T | S | S | G | V | G | K | S | R |
Ciphertext: ITSSG VGKSR
Decrypting
For each cipher letter, find it in the cipher row and write the letter above it.
ITSSG: I is above H, T above E, S above L, S above L, G above O, giving HELLO.
Notice that the double L in HELLO becomes a double S in the ciphertext. Repeated letters and patterns survive, which is a weakness.
Weakness: frequency analysis
Because each plaintext letter always gives the same cipher letter, the frequency of letters in the ciphertext matches the frequency in the language.
- In English, the most common letters are E, T, A, O, I, N, and the least common are Z, Q, X, J.
- An attacker counts the letters in the ciphertext: the most common cipher letter is probably E, the next T, and so on.
- Then they use patterns: common words ("THE", "AND"), single-letter words (A, I), double letters (LL, EE, SS) and word lengths.
- A few hundred letters of ciphertext are usually enough to solve it by hand.
So even though there are keys, the cipher is not secure. The attack uses structure in the language, not brute force.
Improvements
- Polyalphabetic ciphers (such as the Vigenère cipher) use several substitution alphabets in turn, which hides the letter frequencies.
- The Vernam cipher (3.2.4) is perfectly secure if used correctly.
- Modern ciphers (AES) are far more complex.
Benefits and drawbacks
- Benefits: simple to understand, use and program, fast, and needs no special equipment. It's useful for teaching and puzzles.
- Drawbacks:
- Easily broken by frequency analysis.
- A Caesar cipher has only 25 keys.
- Spaces and punctuation reveal the structure.
- Key exchange is needed, since it is symmetric.
- The key must be remembered or written down.
Worked example
Task: (a) Encrypt MEET AT NOON with the keyboard-order key above. (b) Decrypt KHOOR using a Caesar shift of 3. (c) Why is a Caesar cipher easier to break than a general monoalphabetic cipher?
(a) Look each letter up (M is the 13th letter, so cipher D; E gives T; T gives Z; A gives Q; N gives F; O gives G):
| Plain | M | E | E | T | A | T | N | O | O | N | ||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Cipher | D | T | T | Z | Q | Z | F | G | G | F |
Ciphertext: DTTZ QZ FGGF
(b) Shift each letter back 3: K to H, H to E, O to L, O to L, R to O. The plaintext is HELLO.
(c) A Caesar cipher has only 25 possible keys, so an attacker can try all of them in seconds. A general monoalphabetic cipher has about keys: still a limited number that an exhaustive search could get through, but frequency analysis breaks it far more quickly.
Exam tip: when encrypting, write the plain and cipher alphabets one above the other, and work letter by letter. Leave spaces where they are, unless told otherwise. When asked about weaknesses, either answer earns marks: frequency analysis works because each plaintext letter always becomes the same ciphertext letter, so letter frequencies are preserved; or an exhaustive search works because the number of possible keys is limited (26!).
Check yourself
What does "monoalphabetic" mean?
One substitution alphabet is used for the whole message, so each plaintext letter always becomes the same cipher letter.
Encrypt CAT with a Caesar shift of 2
ECV.
Why does the Caesar cipher have only 25 useful keys?
There are only 25 different non-zero shifts of a 26-letter alphabet, so an attacker can try them all.
What is frequency analysis?
Counting how often each letter appears in the ciphertext and comparing with the known frequencies in the language, to work out which cipher letter stands for which plain letter.
How does a polyalphabetic cipher improve on a monoalphabetic cipher?
It uses several substitution alphabets in turn, so a plaintext letter doesn't always give the same cipher letter, which hides the letter frequencies.