Practical Cryptology - Hill Cipher Cryptanalysis Programming Lab

Write a program that reads two strings - ciphertext and the partial plaintext and finds the key matrix and the complete plaintext using the known plaintext cryptanalysis technique that we learned in class.

You can assume that the ciphertext was obtained by encrypting plaintext using Hill Cipher with 2X2 matrix.

You can assume that the ciphertext is a string of UPPER CASE letters and the plaintext is the string of LOWER CASE letters.

You can assume that there are no other characters in the input strings.

You will not lost points if your program will find the key matrix ONLY. In this case you will run 2 programs in a row: first, the new program that will find the key matrix and second, the program that you wrote before that will perform decryption using Hill cipher and known matrix key.

Simplification: you can assume that the maximal length of the known plaintext is 10 character. This simplification will result in 5 points reduction.

Your program must print the following:

  • Matrix B for each two pairs that you are trying at the current moment and the determinant of B.
  • The message that tells if you continue to the next pair (since the determinant was not relatively prime with 26) or this pair is good for the following step
  • The final printout should include:
    • the matrix B that gave you a successful determinant (relatively prime with 26),
    • the determinant of B,
    • the inverse of B
    • the final key matrix A.
    • The final plaintext(if your program is combined with the regular Hill cipher program that we did before)
All these intermediate prints and final output will help you to test your program.
Also, pay attention, it could be the situation that the plaintext input is not sufficient to find the key matrix (we have this situation with MONDAY and SELUKE).
Your program must print the appropriate message in this case. You can test your program for this case on MONDAY and SELUKE as plaintext and ciphertext.