PYTHON
CRYPTOGRAPHY – GRONSFELD CIPHER

 

 

DESCRIPTION


You will write code related to the Gronsfeld cipher that can be used in encrypting/decrypting messages.


THE GRONSFELD CIPHER

 

In Europe, instead of the Vigenere cipher, the very similar cipher called the Gronsfeld cipher was used.

 

Instead of a keyword, the cipher utilises a keycode consisting of numbers.  The rest of the cipher is the same.

 

EXAMPLE

 

Plaintext: CAMPEAU

Gronsfeld keycode: 214

 

Plaintext

Keycode

Ciphertext

Explanation

C

2

E

C shifted by 2 is E

A

1

B

A shifted by 1 is B

M

4

Q

M shifted by 4 is Q

P

2

R

P shifted by 2 is R

E

1

F

E shifted by 1 is F

A

4

E

A shifted by 4 is E

U

2

W

U shifted by 2 is W

 

The advantage of the Gronsfeld cipher over the Vigenere cipher is that there is not keywords that could easily be shared or stolen (as a number code is harder to remember and share).  On the flip side, the Gronsfeld offers less encoding options so is therefore a little more vulnerable to being broken.

 

WORK

 

QUESTION 1

In a Python file called Gronsfeld, write the enc and dec functions for Gronsfeld ciphers.  They only need to work with upper case letters.

 

enc (word, keycode)

dec (word, keycode)

 

Test your code.

 

Feel free to use any of your past code in here.

 

QUESTION 2

 

The following sentence has been encrypted using the Gronsfeld cipher with keycode 13579.  Use your program to decrypt it.

 

JINUMZRZYUBFPVOGDNAQELXADSENUP