Gronsfeld cipher

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

Gronsfeld cipher

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Which one is a valid Gronsfeld cipher key?
A 31415
B PIZZA
2. The key is 31415 and the first message letter is A. What happens to it?
A It shifts 31 places and becomes F
B It shifts 3 places and becomes D
3. The key is 123 and the message has 7 letters. Which shifts are used?
A 1 2 3 1 2 3 1
B 1 2 3 0 0 0 0
4. How many different shifts can one Gronsfeld key digit give?
A 26 (letters A to Z)
B 10 (digits 0 to 9)
5. Key digit 2 was used to encrypt a letter and the cipher letter is F. What was the original letter?
A D
B H

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1key = '31415' APicks the key digit for position i, repeating the key along a longer message
2key[i % len(key)] B(n - shift) % 26
3To encrypt, shift the letter number forward by its key digit and wrap round with MOD 26 CThe same digit 3 was used for both letters. The key moves to the next digit, so I is shifted by 1 and becomes J. The correct result is KJ.
4To decrypt, shift the letter number backward by the same key digit and wrap with MOD 26 D(n + shift) % 26
5key = '3A415' EA Gronsfeld key: a string of digits 0-9 where each digit is the shift for one letter
6HI with key 31 gives KK FA Gronsfeld key can only use digits 0-9. The letter A makes this a Vigenere-style key and gives no valid numeric shift.

Definitions

Gronsfeld cipher

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
shift = int(key[_ % len(key)])
2.
shift = int(key[i _ len(key)])
3.
new = (ord(ch) - 65 _ shift) % 26 + 65
4.
new = (ord(ch) - 65 _ shift) % 26 + 65
5.
shifts = list(range(0, __))

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A key = "ABCDE"
B text = "HELLO"
C d = int(key[0])
D print(d)
Question 2
A key = "2718"
B text = "CATS"
C for i in range(len(text)):
D d = int(key[i])
E print(d)
Question 3
A key = "31415"
B pos = 0
C d = int(key[pos])
D new = (7 + d) % 10
E print(new)
Question 4
A plain = (cipher + d) % 26
B letter = chr(plain + 65)
C print(letter)
Question 5
A key = "31415"
B d = key[0]
C shifted = (4 + d) % 26
D print(shifted)

Answer Key

Gronsfeld cipher
Section A: Quick Questions
Q1
A — 31415
Q2
B — It shifts 3 places and becomes D
Q3
A — 1 2 3 1 2 3 1
Q4
B — 10 (digits 0 to 9)
Q5
A — D
Section B: Match the Pairs
Q1
key = '31415' → A Gronsfeld key: a string of digits 0-9 where each digit is the shift for one letter
Q2
key[i % len(key)] → Picks the key digit for position i, repeating the key along a longer message
Q3
To encrypt, shift the letter number forward by its key digit and wrap round with MOD 26 → (n + shift) % 26
Q4
To decrypt, shift the letter number backward by the same key digit and wrap with MOD 26 → (n - shift) % 26
Q5
key = '3A415' → A Gronsfeld key can only use digits 0-9. The letter A makes this a Vigenere-style key and gives no valid numeric shift.
Q6
HI with key 31 gives KK → The same digit 3 was used for both letters. The key moves to the next digit, so I is shifted by 1 and becomes J. The correct result is KJ.
Section C: Definitions
Q1
Gronsfeld cipher — A Vigenere variant whose key is a string of digits 0-9, like 31415. Each digit is the shift for one letter, and the key repeats along the message.
Section D: Fill in the Blanks
Q1
shift = int(key[i % len(key)])
Q2
shift = int(key[i % len(key)])
Q3
new = (ord(ch) - 65 + shift) % 26 + 65
Q4
new = (ord(ch) - 65 - shift) % 26 + 65
Q5
shifts = list(range(0, 10))
Section E: Spot the Error
Q1
A — A Gronsfeld key is made only of digits 0-9, because each digit is a shift. Letters like ABCDE make a Vigenere key. It should be key = "31415".
Q2
D — The key must repeat along the message. Using key[i] runs off the end of a short key. It should use i % len(key) to wrap back to the first digit.
Q3
D — Letter positions wrap around the 26-letter alphabet, so the MOD must be 26. The digits 0-9 are the shifts, not the alphabet size. It should be % 26.
Q4
A — Encrypting adds the digit shift, so decrypting must subtract it. It should be plain = (cipher - d) % 26.
Q5
B — key[0] is the text character "3", not a number, so it cannot be added to a letter position. It must be converted with int(), giving d = int(key[0]).