# Hill cipher , known plaintext attack.

I know the plaintext and ciphertext. I want to find the vector key which is used to encrypt the text. here is the step I want to do.

1. The convert the ciphertext and plaintext into matrix of n x n.
2. Find the inverse of the matrix which is equal to MM-1..
3. Use the function $k=p-c \pmod{26}$ to get the keys. This function delivered from $C=P\cdot K \pmod {26}$.

anything else, I missed or wrong? I cannot implement it in the code, not sure what wrong

• Do you know the block size? – Randall Aug 24 '18 at 3:42
• There are several examples on this site and the cryptography stack exchange of KP-attacks on Hill ciphers. Look them up. – Henno Brandsma Aug 24 '18 at 4:14
• E.g. math.stackexchange.com/q/982030/4280 is one example. – Henno Brandsma Aug 24 '18 at 4:17