# Hill cipher — obtain matrix key [closed]

I have to solve Hill's cipher. I have only cipher text: CGQIYN and key: CFDG. I don't know how to decrypt it, because in all videos I've watched they knew the Matrix key from the beginning. I don't want you to solve it, but I am really hopeless and I absolutely don't know how to do it. If you can provide me some procedure, I will be grateful. Thank you.

## closed as off-topic by kelalaka, AleksanderRas, puzzlepalace, Maarten Bodewes♦Aug 15 at 23:42

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

• hint: usually the matrix is written as [[C F][D G]]. – kelalaka Apr 17 at 20:26
• Sorry, but still I don't know how to obtain key matrix. I tried everything but I got only gibberish text. In all videos and texts everyone knows the key matrix from the start and doesn't explain it. – hlll123 Apr 18 at 9:15
• @hlll123 You can comment here to request clarifications; you should always be able to comment on qustions and answers when you are the asker. – Maarten Bodewes Apr 18 at 10:12

The key is 4 characters long, therefore it must be in a 2 × 2 matrix. The numbers in this matrix must be the inverse of the encryption key matrix, and there are various methods to work this out (see this link). Once the matrix inversion has been calculated, you multiple it through each part of the cipher text in their respective 2 × 1 matrices

The key is 4 long, so should be a $$2 \times 2$$ matrix. In members of $$\mathbb{Z}_{26}$$ CFDG becomes $$2, 5, 3, 6$$ in the usual A becomes $$0$$, Z becomes 25 encoding.

After some experimenting I found that we make this into the encryption matrix

$$K = \begin{bmatrix} 2 & 5\\ 3 & 6 \end{bmatrix}$$

where encrypting is done by multiplying a row of plain text (as members of $$\mathbb{Z}_{26}$$) from the left by $$K$$ to get a cipher row.

So first we need the inverse of $$K$$, and $$\det(K)= 2\times 6 - 3 \times 5 = -3 = 23 \pmod{26}$$ which is invertible, as it should, as $$\det(K)^{-1} = -9 = 17 \pmod{26}$$.

The inverse of a $$2 \times 2$$ matrix $$A=\begin{bmatrix} a & b\\ c & d \end{bmatrix}$$ equals $$\det(A)^{-1}\cdot \begin{bmatrix} d & -b\\ -c & a \end{bmatrix}$$ when $$\det(A)$$ is invertible (works in any commutative unitary ring) and applying this to out $$K$$, we get (check this!)

$$K^{-1} = \begin{bmatrix} 24 & 19\\ 1 & 8 \end{bmatrix}$$

and this allows us to decrypt $$CG\rightarrow \begin{bmatrix} 2 & 6 \end{bmatrix}$$ as

$$\begin{bmatrix} 2 & 6 \end{bmatrix} \begin{bmatrix} 24 & 19\\ 1 & 8 \end{bmatrix} = \begin{bmatrix} 2 & 8 \end{bmatrix} \rightarrow \text{ci}$$

while QI becomes

$$\begin{bmatrix} 16 & 8 \end{bmatrix} \begin{bmatrix} 24 & 19\\ 1 & 8 \end{bmatrix} = \begin{bmatrix} 2 & 4 \end{bmatrix} \rightarrow \text{ce}$$ and finally

YN decrypts as

$$\begin{bmatrix} 24 & 13 \end{bmatrix} \begin{bmatrix} 24 & 19\\ 1 & 8 \end{bmatrix} = \begin{bmatrix} 17 & 14 \end{bmatrix} \rightarrow \text{ro}$$

So I suspect cicero to be the required solution. The method of encryption and decryption should hopefully be familiar to you, and also the method of finding matrix inverses.