1

I'd have a quick question over hill cipher encrytion.

Say I have an input

[8 9]

I was to encrypt and an encryption matrix

[1 2]
[3 4]

I multiply the matrix by the input as:

[1 2][8] = [26 60]
[3 4][9]

I am now supposed to take mod 26 of both values of the output vector and convert them back to a corresponding letter using the table

1 = 'a', 2 = 'b', ... , 'z' = 26

However, considering 26 mod 26 is 0, how should I proceed?

2
  • 2
    just put 'z'? other wise you'll never have something mod 26 equals 26.
    – Haochen Wu
    Commented May 3, 2015 at 19:26
  • 1
    Since the mod operation returns the range 0..25, either start with a=0 or simply wrap it around, so z=0.
    – Jongware
    Commented May 3, 2015 at 19:30

1 Answer 1

1

Hill cipher associates with each letter, a number (generally from 0 to 25) and there's a logic behind modulo 26. We have 26 letters in English alphabet set, hence we do modulo 26.

Moreover, whenever, we do modulo n, the possible remainders are : 0, 1, 2, . . . , n-1.

Example: x mod 4, (x is any positive integer), we can get only 4 remainders: 0, 1,2,3 ....... never 4.

So, I suggest, one should number a=0, b=1, c=2, .. , z=25... you won't face this problem....

Hope this answered your question. :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.