"
A matrix is a rectangular array of number, symbols or expressions arranged in rows and columns."
For example, a 2X2 matrix is comprised of two rows and two columns.
For example, a 2x3 matrix is comprised of two rows and three columns.
We will skip other things like how the actual matrix works. It is very simple and if someone has a doubt about matrix operations, comment in the comment box. I’ll arrange an article on Matrix operations.
How the Hill cipher works
Suppose, you want to encrypt the message – “Dr Greer Rocks“. See the steps, mentioned below, to work on the encryption part of your plaintext.
Plaintext = = > Dr Greer Rocks
Step 1
From the Square matrix of 2X2 with a non-negative integer, where each element is less than 26, the matrix actually is given in the analysis part. Right now, we assume that we have the encryption matrix, as shown below.
Step 2
Check that its determinant does not factor by 2 or 3 and if it exists, return to the step, mentioned above, to change the Encryption matrix.
Determinant of Matrix M is = -5 which is not actually the factor of 2 or 13, so we move on to next step.
Step 3
Make a pair of your plaintext, if you have an odd number of letters then repeat the last letter or just embed “X” into the plaintext. (You can add any other letter too.)
Pair the letters and declare their identity alphabetically, where A=1, B=2, C=3 and so on.
DR GREER ROCKS => [DR], [GR], [EE], [RR], [OC], [KS]
Step 4
Convert each pair into plaintext vector and multiply with the encrypted matrix (M).
Step 5
Replace each new vector by residue module 26.
Step 6
Convert each Ciphertext vector into its corresponding position in the alphabet.
Step 7
Align the letter in a single line and you will get your Ciphertext.
Implementation of Encryption of Hill Cipher in C#
Hope you like it. Thank you for reading. Have a good day.