Cryptography / Classical ciphers
Substitution and Shift Ciphers
Caesar, affine and Vigenère ciphers, written as modular arithmetic.
Contents 3 sections
By the end you can
- Encrypt and decrypt with shift and affine ciphers
- Describe a cipher by its key space
- Explain how Vigenère hides letter frequencies
§1Shifting the alphabet
Number the letters to . A shift cipher with key encrypts and decrypts by subtracting. Julius Caesar reportedly used .
There are only 26 keys, so an attacker can try them all: a brute-force attack. A secure cipher needs a key space far too large to search.
§2Vigenère
The Vigenère cipher uses a keyword and shifts each letter by the corresponding keyword letter, cycling through it. The same plaintext letter encrypts differently in different positions, which flattens the letter frequencies that betray a simple substitution.
Preparing the instrument…
Check yourself
- Q1With a Caesar shift of 3, the plaintext CAB encrypts to…
- Q2Which value of is allowed in an affine cipher mod 26?