Gronsfeld cipher — shift letters with a number key like 31415

The Gronsfeld cipher is a Vigenère cipher with a number for a key, where each digit says how far to shift the next letter, 0 to 9 places; enter the digits, then encrypt or decrypt.

Live demo · real result from this tool
Direction

Result

Duxbhn bx efzo

Processed on your device — nothing is uploaded.

How to use the Gronsfeld cipher tool

  1. Choose the Direction: Encrypt or Decrypt.
  2. Enter the Digit key, for example a date, a PIN-like number or the default 31415.
  3. Type into Your text.
  4. Copy the Result. To decrypt, use the same digits and switch the direction.

What it does and when to use it

The Gronsfeld cipher, named after a 17th-century Count Gronsfeld, is a version of the Vigenère cipher where the keyword is replaced by a string of digits. A digit key is easy to remember and to hide: a phone extension, a year or the first digits of pi. That makes it popular in geocaching puzzles and escape rooms, where a number found in one clue unlocks the next.

Like every classical cipher it is for fun and learning, not security. If you want letter keys, compare the Beaufort cipher or the autokey Vigenère cipher. With a key of a single digit, Gronsfeld is the same as the Caesar cipher with a shift of 0 to 9.

How it works

Number the letters A = 0 to Z = 25. The key digits repeat along the letters of the message:

Encrypt:  C = (P + d) mod 26
Decrypt:  P = (C − d) mod 26

Here d is the key digit for that letter. With key 31415, H (7) moves 3 places to K, E moves 1 to F, L moves 4 to P, the next L moves 1 to M and O moves 5 to T: HELLO becomes KFPMT.

The tool keeps each letter’s case and skips anything that is not A to Z or a to z, without using a digit for it. Letters near the end of the alphabet wrap around, so Z shifted by 9 becomes I. The whole process runs in your browser.

Worked examples

Results from the tool:

HELLO            key 31415            →  KFPMT
Attack at dawn   key 31415            →  Duxbhn bx efzo
Duxbhn bx efzo   key 31415, Decrypt   →  Attack at dawn
Zoo 24/7         key 9-0-1            →  Iop 24/7

In the second line the key runs 3, 1, 4, 1, 5 across “Attack”, then restarts at 3 for the final k and continues through “at dawn”, ignoring the spaces. The last line shows wrap-around (Z to I), a 0 that leaves the o alone, and the 24/7 staying exactly as written.

Limits and tips

  • A key the same length as the message, used once, is much stronger than a short repeating one, but this is still not modern encryption.
  • Agree whether spaces and punctuation stay in the message. This tool keeps them, which reveals word lengths.
  • Accented letters are not shifted. Write them as plain letters first if needed.

Frequently asked questions

Can the key contain letters or dashes?
Only the digits are used; everything else in the key box is ignored. So 9-0-1 and 901 are the same key. A key with no digits at all, such as key, gives the message "The Gronsfeld key is a sequence of digits, such as 31415."
What does a 0 in the key do?
It leaves that letter unchanged. In the example Zoo with key 901, the first o stays an o. A key full of zeros would not encrypt anything, so avoid long runs of 0.
Are the digits in my message encrypted?
No. Only the letters A to Z and a to z are shifted. Digits, spaces and punctuation are copied across and do not use up a key digit, so 24/7 stays 24/7.
How is Gronsfeld weaker than Vigenère?
Each position can shift by only 10 amounts instead of 26, so there are far fewer keys of a given length to try. Both share the repeating-key weakness. Gronsfeld is a puzzle and teaching cipher, not a way to protect real information.

Written by the ToolsRift team · Last updated

Pages are drafted with AI assistance and checked by automated tests. How we write and check pages.

Was this tool useful?

Report a problem

Start typing to search every tool.

↑ ↓ to moveEnter to openEsc to close