Vigenère cipher: the maths
The formulas of the Vigenère cipher in modular arithmetic, the key space and why the repetition of the key is its weakness.
Numbering the letters from A = 0 to Z = 25, encryption and decryption are written with modular arithmetic.
- 01
Encryption
C_i = (P_i + K_(i mod m)) mod 26, where P is the text, K the key and m its length.
- 02
Decryption
P_i = (C_i − K_(i mod m)) mod 26.
- 03
Key space
With an m-letter key there are 26^m possible keys: with 10 letters over 140 trillion.
- 04
Structure
The letters in positions i, i + m, i + 2m… are encrypted with the same key letter, that is with the same Caesar cipher.
Why the key space is not enough
A huge number of keys seems to guarantee security, but the cipher’s structure means you do not have to try them all. Once the length m is found, the text splits into m columns, each encrypted with a simple shift: each is solved with frequency analysis, like a Caesar cipher.
Vigenère cipher: weaknesses and attacks
The Kasiski method, Friedman’s index of coincidence and column-by-column frequency analysis: how the Vigenère cipher is broken.
The pages of this topic
Back to the overviewVigenère cipher: history
From Alberti to Trithemius, from Bellaso to Vigenère: how the “indecipherable” cipher was born, why it bears the wrong name and how it was broken in the nineteenth century.
Vigenère cipher: how it works
How to encrypt and decrypt with the Vigenère cipher using the square table and the repeated keyword.
Vigenère cipher: worked example
Step-by-step encryption of the message “meet me at the bridge” with the key CIPHER, letter by letter.
The Vigenère cipher today
Where the Vigenère cipher is found today: teaching, games, puzzles, and the lessons it left to modern cryptography.
Vigenère cipher: try it yourself
Encryption and decryption exercises with the Vigenère cipher, with solutions.
Vigenère cipher: frequently asked questions
Short answers to the most common questions about the Vigenère cipher.