Gronsfeld Cipher Encoder/Decoder

Encrypt and decrypt text with a numeric key.

Result

Duxbhn bx efzo

How it is calculated

Every letter is shifted along the alphabet by a digit from the key, and the key digits repeat in order. Encoding is C = (P + d) mod 26; decoding is P = (C − d) mod 26, where P and C are letter positions 0 to 25 and d is the current key digit (0 to 9). A digit 0 leaves the letter unchanged.

Details of this tool: only the 26 letters A–Z are shifted, and upper and lower case are kept. Spaces, digits, punctuation and accented letters are copied through as they are and do not use up a key digit, so the key moves on only at letters. Anything in the key that is not a digit is dropped, so 3-1-4 is read as 314. An empty text or a key without digits gives no result. Mode decides encode or decode, and decoding needs the same key.

Worked example

Text Attack at dawn, key 31415, encode. The letters shift by 3, 1, 4, 1, 5, 3, then the key repeats from 1, 4, 1, 5, 3, 1. A+3 = D, t+1 = u, t+4 = x, a+1 = b, c+5 = h, k+3 = n. The space is copied and the key continues: a+1 = b, t+4 = x, then d+1 = e, a+5 = f, w+3 = z, n+1 = o. The result is Duxbhn bx efzo. Running that text in decode mode with the same key returns the original.

Try this example →

Common mistakes

  • Using a keyword such as LEMON. That is the Vigenère cipher; here the key must be digits, and letters in it are simply ignored, so a word key gives no result.
  • Decoding with the wrong mode. Pasting ciphertext while the mode is still on encode shifts it forward again and produces a different scrambled text.
  • Expecting the key to advance over spaces and punctuation. It advances only on letters, so a message encoded by hand with a key that counts every character will not match.
  • Expecting accented letters, such as Turkish ş or ğ, to be encrypted. They are passed through unchanged.
  • Treating the result as secure. With only ten possible shifts per position and a short repeating key, this is a puzzle cipher, not protection for private data.

About this calculator

The Gronsfeld cipher is a polyalphabetic substitution cipher, essentially a numeric-key variant of the Vigenère cipher: instead of a repeating keyword of letters, it uses a repeating string of digits (0–9), and each digit shifts the corresponding plaintext letter forward in the alphabet by that many positions, wrapping around from Z back to A. With only 10 possible shift values per position (versus 26 for a full Vigenère key letter), it's slightly weaker than Vigenère but historically easier to memorize and transmit as a number.

Cryptography students and hobbyists use the Gronsfeld cipher to learn the mechanics of polyalphabetic substitution and the Kasiski/index-of-coincidence techniques used to break it, since — like all classical repeating-key ciphers — it's vulnerable to frequency analysis once the key length is discovered. It was historically used by Count Gronsfeld in 17th-century military correspondence. Enter text and a numeric key to encode or decode.

Was this helpful?

You can pick up to 3 reactions.

Comments (0)

  • Be the first to comment.

Popular calculators

All Calculators