Gronsfeld Cipher Tool

Free online Gronsfeld cipher: a Vigenère-style cipher with a numeric key. Encrypt, decrypt, and follow a worked example.

TL;DR

  • A Gronsfeld cipher is a polyalphabetic substitution cipher.
  • Its key is a sequence of digits, usually repeated across the message.
  • Each digit shifts the next alphabetic character by 0-9 positions.
  • This browser tool preserves formatting by default and stores no text.

How to Use the Gronsfeld Cipher Tool

  1. Choose encrypt or decrypt.
  2. Enter a numeric key such as 31415 or 271828.
  3. Paste plaintext or ciphertext into the text box.
  4. Copy the result, download it, or swap it back for a round trip.

How Gronsfeld Ciphers Work

A Gronsfeld cipher is a polyalphabetic substitution cipher that works like a numeric-key version of the Vigenere cipher. Instead of converting keyword letters to shifts from 0 through 25, it uses key digits from 0 through 9.

A numeric key is the digit stream that controls the shift pattern. With key 31415, the first alphabetic character shifts by 3, the second by 1, the third by 4, and so on. When the key runs out, it repeats from the beginning.

A classical cipher is a hand-solvable encryption method from the pre-computer era. Gronsfeld belongs to that family: it is useful for teaching, puzzles, and historical comparison, but it is not a substitute for modern cryptography.

History and Use Cases

The Gronsfeld cipher is commonly described as a simplified Vigenere variant associated with Count Gronsfeld. The smaller digit alphabet made the key easy to write as a number, which also made the cipher easier to teach and operate by hand. Helen Fouche Gaines' public-domain cryptanalysis manual on Project Gutenberg includes a dedicated section on Gronsfeld encipherment and decryption.

Its weakness is the same pattern that makes it convenient: repeated shifts leak structure. Frequency analysis is a cryptanalysis method that studies letter counts and patterns, and it can help break many repeated-key classical systems; see this frequency analysis reference.

Today, use a Gronsfeld cipher for classroom demonstrations, escape-room clues, puzzle hunts, and comparisons with Caesar, Vigenere, Beaufort, and autokey ciphers. Do not use it to protect passwords, private messages, API keys, or sensitive files.

Worked Example

Plaintext: ATTACK AT DAWN
Key: 31415
Repeated key: 314153 14 1531
Ciphertext: DUXBHN BX EFZO

The first letter encrypts as A + 3 = D. The second encrypts as T + 1 = U. The same digits must be applied in the same order to decrypt.

A Gronsfeld key is a Vigenère key that only uses A to J

Each key digit is the same shift as a Vigenère key letter: 0 is A (shift 0), 1 is B, and so on up to 9, which is J (shift 9). That is the whole difference from Vigenère: Gronsfeld can only use ten of the 26 possible shifts at each position.

Key digit0123456789
Vigenère letterABCDEFGHIJ

So key 31415 is the Vigenère keyword DBEBF. We checked with the tool’s own logic: ATTACK AT DAWN becomes DUXBHN BX EFZO with Gronsfeld key 31415 and with Vigenère keyword DBEBF. If you already know how to handle one, you know the other.

How to decrypt by hand

Decrypting reverses the shift: subtract the key digit from each ciphertext letter, wrapping round from A back to Z. Use the same digits in the same order, and skip spaces and punctuation without using a key digit. Here are the first six letters of DUXBHN BX EFZO with key 31415:

CiphertextKey digitStepPlaintext
D3D (3) − 3 = 0A
U1U (20) − 1 = 19T
X4X (23) − 4 = 19T
B1B (1) − 1 = 0A
H5H (7) − 5 = 2C
N3N (13) − 3 = 10K

Letters are numbered A = 0 to Z = 25. When the subtraction goes below zero you add 26: for example B (1) minus 3 is −2, which wraps to 24, the letter Y.

What this tool does with your key and text

  • Only digits count in the key. Anything else you type is ignored, so 3-1-4 and 314 give the same result.
  • Spaces and punctuation do not use up key digits. The key moves on only when a letter is processed.
  • Formatting kept: with formatting preserved, capitals and punctuation are left in place. “Hello, World!” with key 2718 becomes Jlmtq, Dpznk!
  • Formatting off: the output is letters only, in capitals, in groups of five. The same message becomes JLMTQ DPZNK
  • Key 0 changes nothing, since every shift is zero, and a key with no digits returns an empty result.

Everything runs in your browser, and no text is sent anywhere.

How easy is a Gronsfeld cipher to break?

Very easy. A key of n digits has 10n possibilities, which is small for a computer and even small next to a same-length Vigenère keyword:

Key lengthGronsfeld keys (10n)Vigenère keywords (26n)
410,000456,976
5100,00011,881,376
61,000,000308,915,776
8100,000,000208,827,064,576

The repeating key also shows through. Encrypting a run of the letter A returns the key as letters: fifteen A’s with key 31415 give DBEBFDBEBFDBEBF, with the five-letter pattern repeating. Real messages are less obvious, but the same repetition lets an analyst find the key length (with a Kasiski or index-of-coincidence attack). After that each position is a plain Caesar shift with only ten candidates, and frequency analysis picks the right one. Use Gronsfeld for puzzles, teaching and escape rooms, never for real secrets.

Frequently Asked Questions

What is the Gronsfeld cipher?

The Gronsfeld cipher is a polyalphabetic substitution cipher that works like the Vigenère cipher but takes its key from digits 0-9 instead of letters. Each digit shifts the next letter of the message forward by that many places, and the key repeats when it runs out.

How is the Gronsfeld cipher different from the Vigenère cipher?

A Gronsfeld key is a Vigenère key restricted to the letters A-J (digit 0 = A, 1 = B, up to 9 = J). Key 31415 gives exactly the same result as the Vigenère keyword DBEBF. Because only ten shifts are possible per position instead of 26, Gronsfeld has fewer keys to try.

How do you decrypt a Gronsfeld cipher?

Subtract instead of add. Line the key digits up under the ciphertext letters, move each letter back by its digit (wrapping from A round to Z), and skip spaces and punctuation without using up a key digit. With key 31415, D minus 3 gives A, U minus 1 gives T, and so on.

How many keys does a Gronsfeld cipher have?

A key of n digits has 10 to the power n possibilities: 10,000 for four digits, 100,000 for five, 1,000,000 for six and 100,000,000 for eight. For comparison, a five-letter Vigenère keyword has 11,881,376 possibilities. Any of these is tiny for a computer to try.

Is the Gronsfeld cipher secure?

No. It is a classical cipher and should not protect real secrets. The key repeats, so the same letter patterns recur, and after the key length is found each position is just one of ten shifts. Use it for puzzles, teaching and escape rooms, and use modern, vetted encryption for anything private.