**Part C: Hill Cipher**

Given the key displayed below 4×4 key. Pick a plain text message (three words, no spaces; *meetmetonight*, for example—or use something else!), go through the detailed steps of the Hill cipher explained in the textbook (Chapter 2 and any supporting material), and encrypt it. Then reverse the encryption (again in a detailed, step-by-step fashion) and recover the plaintext.

Here is the key matrix:

8 6 9 5

6 9 5 10

5 8 4 9

10 6 11 4

## EXPERT ANSWER

ANSWER

message = “soyerandtext”

breaking the message into pieces of 4 since the key is 4X4.

message = [s o y e]’ [r a n d]’ [t e x t]’

message in numbers = [18 14 24 4]’ [17 0 13 3]’ [19 4 21 19]’

Then multiplying the key matrix and message matrix to get the resulting array using a python program given below:

import numpy as np

key = [[8, 6, 9, 5], [6, 9, 5, 10], [5, 8, 4, 9], [10, 6, 11, 4]]

message = [18, 14, 24, 4]

print np.dot(key, message)

Result:

[464 394 334 544], [268 197 164 325] and [460 445 382 521]

Taking modulo 26 of all these resulting arrays:

= [22 4 22 24], [8 15 8 13] and [18 3 18 1]

Therefore, message = [W E W Y]’, [I P I N]’ and [S D S B]’

Hence, encrypted message = wewyipinsdsb

Getting back the plain text,

Inverse of the key matrix:

[ -3 20 -21 1]

[ 2 -41 44 1]

[ 2 -6 6 -1]

[ -1 28 -30 -1]

this mod 26 =

[ 23 20 5 1]

[ 2 11 44 1]

[ 2 20 6 25]

[ 25 2 22 25]

Now, multiplying this with our cipher text using the same python code:

[720 1080 856 1642]’ , [537 546 689 731]’ and [565 862 229 877]’

Now, finally taking modulo 26 of these matrices:

[18 14 24 4]’, [17 0 13 3]’ and [19 4 21 19]’

Which is “soyerandtext” which was our initial message.

THANK YOU