An attempt on Hill Cipher.
It has been a possible attempt to write on Hill Cipher Step
by step in order to not only makes it a child’s play but also strive to makes
it more and more understandable.
Why it is Hill Cipher?
It is Hill Cipher because the mathematician Laster Hill
developed at in 1929.
Points should be kept in mind!
Ø
It is a classical cipher, as
if Caesar cipher, Play fair cipher and so on.
Ø
It is a symmetric cipher,
which means key is shared between both parties- sender and receiver-.
Ø
It is a substitution and matrix
based cipher, means with the help of using mathematics matrix operation the position
of letters are be changed.
Let’s play the game now.
Step 1: first of all select a key. But, select the
key in matrix, as I selected:
[2 3]
[3 4] Note: This key will be shared BTW both parties.
Step 2:
Just select a plain text which you want to encrypt.
As I selected “RACEY”.
Step 3:
Break the message into pairs of letter which
means create the pair of letters. Start pairing from left to right.
As I do so.
RA
|
CE
|
Y
|
1st
pair
|
2nd pair
|
What
about Y?
|
How long
your message will be, you should break and pair it.
Considerable:
But Y is a single letter how a single letter can create a pair?
Step 4:
It’s very interesting as we know that the hill cipher
needs to break the message and create pairs. But, if, the message is break and created
pairs where still a letter remains for pairing, which have no other extra
letter to fulfill the pair demand. In such case we use the concept of Pillar
Letter
Step 4: what is pillar letter?
The pillar is a helper which helps the other
letter to fulfil the requirements of pairing. In our case the pillar letter
will help” Y” to create its pair. You can select any letter which is used as a
pillar but the second party must be informed
which is your pillar letter. Mostly, “X” is used as pillar letter. I am also
using X is pillar letter. Now the pairs will be.
This is the sequence of pairing the letters.
RA
|
CE
|
YX
|
1st
pair
|
2nd pair
|
3rd
pair
|
Step 5:
Now put the
letters into their position. Mostly, the letters position started from 0 and
end 25 like array.
As I put them like.
0
|
1
|
2
|
3
|
4
|
5
|
6
|
7
|
8
|
9
|
10
|
11
|
12
|
13
|
14
|
15
|
16
|
17
|
18
|
19
|
20
|
21
|
22
|
23
|
24
|
25
|
A
|
B
|
C
|
D
|
E
|
F
|
G
|
H
|
I
|
J
|
K
|
L
|
M
|
N
|
O
|
P
|
Q
|
R
|
S
|
T
|
U
|
V
|
W
|
X
|
Y
|
Z
|
Step 6:
Start putting the
letters:
1st
pair: R {17} A {0} second pair: C {2} E {4} third pair: Y {24} X {22}.
Step 7:
Now apply the
Matrix operation with the help of key on each pair.
As I did so.
1st pair:
[2 3] [17] Mode 26
[3 4] [0]
Perform the matric like this: multiply the row
of First table with the column of second table. AS,
(2*17) + (3*0) =34+0=34
(3*17)+ (4*0) =51+0=51
As you know we are using 26 mode because of
total letters are 26.
Use the mode 26
and get the output.
[34] Mode 26 =8
[51] ===== =25
What come after the mode find the position of that
letter. Which will be your cipher letter. As I did for 1st which is on
8th and second is on 25th.
8[I] and 25[Z]. It Will be first pair output.
Your first Pair
cipher: 8[I] and 25[Z] =IZ
Note: Don’t worry if you don’t know how to perform the mode
operation. Just wait or see below. In last step.
Second pair:
Second pair: C {2} E {4}
[2 3] [2] Mode 26 = [16]
[3 4] [4] ------------ = [22]
(2*2) + (3*4) =4+12=16
(3*2) + (4*4) =6+16=22
The output of second pair will be:
16[Q] and 22[W]. Or QW.
3rd pair:
Third pair is: Y
{24} X {22}.
[2 3] [24] Mode 26 = [114] = [10]
[3 4] [22] ------------ = [162] = [6]
(2*24) + (3*22) =48+66=114
(3*22) + (4*24) =66+96=162
Output will be: [10] =K and [6] =G.
Finally, we have encrypted our
message. Pair by pair and step by step. Which is.
Plain text is “RACEY”.
Cipher text is: “IZQWKG”.
Last:
How to perform Mode operation?
Keep in mind we have length of 26 letters,
0-25. If we multiply the Matrix key with the letter’s position which can exceed
the length of 26. Therefore, we need to put a limit through which we will be
able to not let the letters to cross the length of 26.
But how really this
mode magical operation work?
It is really too simple, just get the
product of multiplied letters with key. And divide them with 26. Get the
reminder, the reminder will be your cipher letter position as I did with first
pair:
Output of multiplied “R”, (2*17)
+ (3*0) =34+0=34
Now I divided
34/26.
34 will be
divided by 26 only one time.
Reminder will be
8 (try and confirm it). Take the 8 [I] in place of 17[R].
But what if the multiplied product is less than 26?
No matter, get relaxed.
If, it is not greater than 26, then simply put the same number of letter in
place of plain text. As I did in 2nd pair. Where both 16 and 22 are
not greater than 26. Simply put both of them as: 16[Q] and 22[W] in place of C [2] E [4].
Got? If still have confusion, don’t
hesitate just put your question and get the possible Anwser.