Technical collage /Najaf Communication security
4- Hill cipher:
Hill cipher is a multiletter cipher . The encryption algorithm takes m
successive plaintext letters and substitutes for them m ciphertext letters.
The substitution is determined by m linear equations in which each
character is assigned a numerical value (a = 0, b = 1 ... z = 25). For m = 3,
the system can be described as follows:
This can be expressed in term of column vectors and matrices:
Or
C is cipher letter (3x1)
K is key (3x3).
P is plaintext letter (3x1).
In general terms, the Hill system can be expressed as follows:
By Marwa Al-Musawy
-18-
Technical collage /Najaf Communication security
Ex: plaintext = paymoremoney
and use the encryption key is
Find the ciphertext?
Sol:
pay mor emo ney
first three letters p=15 , a=0 , y=24
this can be represented in vector as :
15
P= 0
24
Then;
C=K P mod 26= mod26
11 = L , 13 = N , 18 = S
So , pay LNS .continuing in this fashion,
The ciphertext for the entire plaintext is LNSHDLEWMTRW.
Ex :
Decrypt the above ciphertext ?
Sol.
Decryption requires using the inverse of the matrix K. The inverse K
By Marwa Al-Musawy
-19-
Technical collage /Najaf Communication security
of a matrix K is defined by the equation KK = K K = I,
This is demonstrated as follows:
P= D(K,C)= K . C mod 26
P1 4 9 15 11 15 p
P2 = 15 17 6 13 mod26= 0 a
P3 24 0 17 5 24 y
H.W
The plaintext "friday" is encrypted using a 2 x 2 Hill cipher to yield the
ciphertext PQCFKU, find the encrypted key?
Note: to find additive inverse modulo n of an integer we use the table
below ,as example modulo 5
0 1 2 3 4
0 0 1 2 3 4
1 1 2 3 4 0
2 2 3 4 0 1
3 3 4 0 1 2
4 4 0 1 2 3
By Marwa Al-Musawy
-20-
Technical collage /Najaf Communication security
The negative of integer x is the integer y ,such that
( x+ y) mod n =0
(x+y) mod 5=0
If x=2 y=3 because (2+3)mod 5=0
If x=4 y=1 because (4+1) mod 5=0
While the multiplicative inverse of an integer x is y such that
(x* y) mod n=1
Example of modulo 5 multiplicative invers of an integer x is
0 1 2 3 4
0 0 0 0 0 0
1 0 1 2 3 4
2 0 2 4 1 3
3 0 3 1 4 2
4 0 4 3 2 1
(x*y) mod 5 =1
If x= 2 y=3 because (2*3) mode 5=1
If x= 4 y=4 because (4*4) mod 5=1
Example :
Find 5 8 for modulo 26 ?
17 3
solution :
By Marwa Al-Musawy
-21-
Technical collage /Najaf Communication security
By Marwa Al-Musawy
-22-