I've been trying to solve this question from Forouzan's book ("Cryptography And Network Security") and haven't been able to wrap my head around how to solve it.

The plaintext “letusmeetnow” and the corresponding ciphertext “HBCDFNOPIKLB” are given. You know that the algorithm is a Hill cipher, but you don’t know the size of the key.

Find the key matrix.

I inverse the 2x2 plaintext matrix and multiple with a 2x2 ciphertext matrix and take a mod 26. However, the key matrix is always in fractions, never an integer.

It would be great if someone could point me in the right direction / tell me what I'm doing wrong.

Thanks in advance!

  • $\begingroup$ How did you find the inverse in the fractions? The inverse of it either exists or not, Did you really worked modulo 26? $\endgroup$
    – kelalaka
    Commented Oct 15, 2020 at 14:43
  • $\begingroup$ I think i miscommunicated, what I mean by inverse in the fractions is that when I calculate the inverse of a 2x2 matrix, I have to divide by the determinant right? and then transpose the matrix and so on. The inverse exists because the determinant exists. I do modulo 26 after finding inverse or after multiplying plaintext matrix inverse with ciphertext matrix $\endgroup$ Commented Oct 15, 2020 at 17:15
  • $\begingroup$ Could you show your work with a good $\LaTeX$ by editing your question? I'll not write an answer, however, I'm pretty sure that Fgrieu can update their answer base on that. $\endgroup$
    – kelalaka
    Commented Oct 15, 2020 at 17:17
  • $\begingroup$ $A \times A^{-1} = I$. See: mathsisfun.com/algebra/matrix-inverse.html $\endgroup$
    – kelalaka
    Commented Oct 15, 2020 at 17:19
  • $\begingroup$ @kelalaka, thanks for this link. I went through it and im inverting the matrix just right. Ill edit my question with Latex by tonight. Thanks again $\endgroup$ Commented Oct 17, 2020 at 10:50

1 Answer 1


Two independent ideas:

  • In the Hill cipher, elements of matrices are in the ring of integers modulo the number of characters in the alphabet used, usually $n=26$. Therefore, as long as the denominator of a fraction is coprime with $n$ (that is, for $n=26$, if the denominator is divisible neither by $2$ not by $13$), that fraction reduces to an integer modulo $n$.
    E.g. $\displaystyle\frac23\equiv18\pmod{26}$ since $2\equiv3\cdot18\pmod{26}$.
  • The Hill cipher is sometime instantiated with a $3\times3$ or larger matrix.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.