Reputation: 437
I am working on some ciphers (just theory, no coding yet). Currently I am doing the hill cipher and I can use it fine. However I have came across a problem which has stumped me. Say for example I am encrypting the letters A and I. A
would be 0
and I
8
. Now take my encryption box to be:
K= 18 2
23 0
This is all well and good. I can encrypt as such:
A = 18*0 = 0 2 *8 = 16
The problem is that adding these results produces 16. Is 16 % 26 just 16? Is this the number that I use for my encryption? Similar problem occurs if I have an encryption where the result is 260 % 26. Do this become 10 or 0? When you divide 260 by 26 you get 10. To finish the modulo operation I would take away any whole number and multiply the remainder by 26. Of course if I do it in this case then I get 0, which cannot be multiplied. Any suggestions?
Upvotes: 0
Views: 646
Reputation: 2277
Yes. 16 % 26 = 16
and 260 % 26 = 0.
The point is that your encryption matrix cannot be used as Hill cipher's encryption/decryption key.
The reason is that the encryption matrix must have an inverse matrix
(modulo 26
). In other words, the determinant
of the matrix must be nonzero
, and not divided by 2
or 13
. In fact,
the determinant
of your matrix is 24 mod 26
, which cannot satisfy this requirement of the Hill cipher. This is why you got the strange result and the decryption will failed.
So try to generate another encryption matrix which has the required property. For example,
3 5
1 2
can be used as an encryption matrix.
Upvotes: 2