I want to implement Hill cipher but I think I have a problem in understanding the algorithm itself.
The key I'll use is a 2X2 matrix and I'll encode 2 characters each time. I'll multiply the key matrix with the matrix of 2 characters then modulus the result on 26 as this equation.
C = E(K, P) = KP mod 26
where: K:key
P:plain text
I do it like this but there's something wrong. I use the example in my book to test my algorithm. Since plain text is friday
and key is: int key[][] = {{5, 8}, {17, 3}}
;
the result should be PQCFKU
.
For the first letters f
, r
, f= 5
, r=17
order of alphabetic letters
encryption of f
is (5*5 + 17*8)%26 =5 => f
it should be P
Where is the error that I make?
?
above the edit text field.