Gronsfeld Cipher Encoder/Decoder
Encrypt and decrypt text with a numeric key.
Result
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.
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.
Was this helpful?
You can pick up to 3 reactions.
Popular calculators
Loan Calculator
Monthly payment, total interest and full amortization schedule.
Percentage Calculator
Percent change, percent of, and ratio calculations.
Discount Calculator
Calculate final price, savings, and discount amount.
BMI Calculator
Body mass index from height and weight (metric or imperial).
Age Calculator
Compute your exact age in years, months and days from a birth date.
Compound Interest Calculator
Calculate the final amount and interest earned with compounding.
All Calculators
- Loan Calculator
- Profit Calculator
- Discount Calculator
- BMI Calculator
- Percentage Calculator
- Ideal Weight Calculator
- Age Calculator
- Pregnancy Due Date Calculator
- Compound Interest Calculator
- BMR Calculator (Basal Metabolic Rate)
- Tip Calculator
- Fuel Cost Calculator
- Date Difference Calculator
- Sleep Cycle Calculator
- Daily Water Intake Calculator
- Simple Interest Calculator
- Heart Rate Zones Calculator
- Running Pace Calculator
- Pet Age Calculator
- Calories Burned Calculator
- Macro Calculator
- TDEE Calculator (Total Daily Energy Expenditure)
- Waist-to-Hip Ratio Calculator
- Honor Roll Calculator
- One Rep Max (1RM) Calculator
- Ovulation Calculator
- Electricity Cost Calculator
- Unit Price Calculator
- Savings Goal Calculator
- Break-Even Point Calculator
- Paint Calculator
- Course Grade Average Calculator
- Business Days Calculator
- Time Duration Calculator
- Fuel Economy Calculator
- Temperature Converter
- Tile Calculator
- Aspect Ratio Calculator
- Roman Numeral Converter
- Goal Weight Timeline Calculator
- Salary Converter (Hourly to Annual)
- Credit Card Validator (Luhn)
- Body Surface Area (BSA) Calculator
- Feels-Like Temperature Calculator
- Ohm’s Law Calculator
- PPI (Pixel Density) Calculator
- Molar Mass Calculator
- Zodiac Sign Calculator (Western + Chinese)
- IBAN Validator
- Shoe Size Converter
- Country Info & Dialing Code Lookup
- Time Zone Difference (World Clock)
- CAGR (Compound Annual Growth Rate) Calculator
- Rule of 72 Calculator
- Blood Alcohol Content (BAC) Calculator
- Lean Body Mass (LBM) Calculator
- Pythagorean Theorem Calculator
- Speed Converter
- Download Time Calculator
- Date Calculator (Add/Subtract)
No calculators found
Comments (1)
Choose your key digits with some variety. A key made of one repeated digit, such as 3333, shifts every letter by the same amount, so it behaves as a plain Caesar shift, and a key of all zeros changes nothing at all. A mix like 31415 gives each position its own shift. Try the round trip: encode, paste the output into decode with the same key, and check you get your text back. Want to post a short ciphertext and key length as a puzzle?