Vigenère
Vigenère
A keyword picks the shift per letter.
- Keyspace
- 26^keyLength
- Decode
- same options back
- Works on
- A-Z, the rest passes
- Family
- 14 in polyalphabetic
Options
Access
- Create
create("vigenere") - CLI
ciphers encode vigenere 'ATTACK AT DAWN' --key LEMON - Tryplayground with the sample above
- Kingronsfeld, beaufort, porta, autokey +9
The keyword repeats under the plaintext and each letter is shifted by the key letter above it, A meaning 0. Only letters advance the key. Spaces and punctuation pass through without eating a key position, which is why "ATTACK AT DAWN" and "ATTACKATDAWN" agree letter for letter. Key is letters only, case doesn't matter.
const vigenere = create("vigenere");
vigenere.encode("ATTACK AT DAWN", { key: "LEMON" }).text; // "LXFOPV EF RNHR"
vigenere.encode("ATTACK AT DAWN", { key: "LEMON", stripNonAlpha: true }).text; // "LXFOPVEFRNHR"
vigenere.decode("LXFOPV EF RNHR", { key: "LEMON" }).text; // "ATTACK AT DAWN"
vigenere.encode("HELLO"); // throws MissingOptionError: key
Keyspace is 26 to the key length, which sounds like a lot until you notice that every n-th letter is a plain Caesar. So the attack is finding the period. analyzeFrequency on the whole text gives an IC near 0.038; on every fifth letter of the LEMON example it climbs back toward English.
Trithemius is a Vigenère whose key is the alphabet itself, and Gronsfeld one whose key is a number. Running key takes a whole page of a book.