Name: Maria Nazir Class: Bsit Semester: 7 Roll No: 18 Subject: (NS) Submitted To: Ma'am Tanzeela
Name: Maria Nazir Class: Bsit Semester: 7 Roll No: 18 Subject: (NS) Submitted To: Ma'am Tanzeela
Class: BSIT
Semester: 7th
Roll no : 18
Subject : (NS)
Submitted to: Ma’am Tanzeela
QNO:1
Ans:
Hill cipher:
The Hill Cipher was invented by Lester S.
Hill in 1929, and like the other Digraphic Ciphers it acts on groups of letters.
Unlike the others though it is extendable to work on different sized blocks of letters. So,
technically it is a polygraphic substitution cipher, as it can work on digraphs, trigraphs (3
letter blocks) or theoretically any sized blocks.
Encryption
Steps:
To encrypt a message using the Hill Cipher we must first turn our keyword into a key matrix
(a 2 x 2 matrix for working with digraphs, a 3 x 3 matrix for working with trigraphs, etc).
We also turn the plaintext into digraphs (or trigraphs) and each of these into a column
vector. We then perform matrix multiplication modulo the length of the alphabet (i.e. 26)
on each vector. These vectors are then converted back into letters to produce the
ciphertext
We now split the plaintext into digraphs, and write these as column vectors. That is, in
the first column vector we write the first plaintext letter at the top, and the second letter at
the bottom. Then we move to the next column vector, where the third plaintext letter goes
at the top, and the fourth at the bottom. This continues for the whole plaintext.
we have to take each of these numbers, in our resultant column vector, modulo 26
(remember that means divide by 26 and take the remainder).
1 2
5 7
Key matrix
Table:
A B C D E F G H I J
0 1 2 3 4 5 6 7 8 9
K L M N O P Q R S T
10 11 12 13 14 15 16 17 18 19
U V W X Y Z
20 21 22 23 24 25
Now I am going to replace each letter by the number corresponding to its position such as
A=0,B=1…..Z=25.
Formula:
C= kpmod(26)
Now we must perform some matrix multiplication. We multiply the key matrix by each column
vector in turn. We shall go through the first of these in detail, then the rest shall be presented
in less detail. We write the key matrix first, followed by the column vector.
Such as:
Similarly we will multiply our key matrix with all the other pairs of plain text then the result will
be as follows:
Deincryption:
To decrypt a ciphertext encoded using the Hill Cipher, we must find the inverse matrix.
Once we have the inverse matrix, the process is the same as encrypting. That is we
multiply the inverse key matrix by the column vectors that the ciphertext is split into, take
the results modulo the length of the alphabet, and finally convert the numbers back to
letters.
Step 3 - Multiply the Multiplicative Inverse of the Determinant by the Adjugate Matrix
Solution:
We will convert our cipher text into plain text
d dinverse= 1mod26
(-3*-9)mod26=1
27mod26=1
1=1
We will remove the negitive value before we deincrypt by adding the value 26
Adj(k)=
K(inverse)=
P= k(inverse)Cmod26
P=
For c=
This process wil go till end and hence we will receive our result as follows: