The Gronsfeld cipher is a polyalphabetic substitution cipher that works exactly like the Vigenère cipher except that its key is a sequence of digits rather than a keyword of letters. It is named after the 17th-century Count Gronsfeld and was once a popular hand cipher because a short numeric key is easy to remember and to apply.
How it works
Each letter of the alphabet is numbered 0 (A) through 25 (Z). The numeric key is repeated cyclically beneath the message, and each key digit gives the shift for the letter above it. Encryption uses the standard Vigenère addition:
C = (P + d) mod 26
where d is the current key digit. Decryption simply subtracts instead:
P = (C - d) mod 26
Because digits only run from 0 to 9, the Gronsfeld cipher chooses from just ten of the 26 possible Caesar shifts. This is its only real difference from Vigenère, and it is what makes Gronsfeld a touch easier to break.
Example
With the key 31415 and plaintext HELLO:
P: H E L L O
d: 3 1 4 1 5
C: K F P M T
H (7) plus 3 gives K, E (4) plus 1 gives F, and so on. Decrypting KFPMT with the same key subtracts each digit to recover HELLO.
Notes
- Only letters are shifted; spaces and punctuation pass through and do not consume a key digit, keeping the digits aligned with the letters.
- A longer, non-repeating-looking key resists Kasiski examination better, but the small 0–9 shift range remains the cipher’s weakness.
- For a letter-keyed version with a full 0–25 shift range, use the Vigenère or Autokey cipher instead.