Practical Cryptology

CSCI 391: Practical Cryptology Fall 2010

Programming Lab Assignment - Programming Implementation of HILL Cipher

Important note: Please, do your own work. Programs which are written in groups are easily identified and will receive grades of 0 for all participants.

Reading Material for this assignment: Chapter 2: 2.9

Lab Assignment

Write a program that implements HILL Cipher encryption and decryption algorithms. You can assume that the size of the MATRIX KEY is 2X2. The program should be able to perform either encryption or decryption. The program must take two inputs. The first input must be either 1 or 2, with 1 signaling encryption and 2 signaling decryption. The second input depends on the first input. In case of encryption, the second input consists of MATRIX KEY, and plaintext - a sequence of LOWER CASE letters. In case of decryption, the second input consists of MATRIX KEY, and ciphertext a sequence of UPPER CASE letters. Your program should output encrypted or decrypted message accordingly with appropriate descriptive message.
Pay attention: in case of decryption your program must to calculate the INVERSE MATRIX. The program must output the INVERSE MATRIX along with plaintext in case of decryption. Also, your program must to check validity of the key. In case of invalid keys you can decide to exit from the program or to ask user to re-enter the key. You can decide on number of attempts. All choices should be well documented in comments and in output messages.


Bonus 1 (10 points): Write the above program for the 3X3 Matrix Key. For mathematical formulas see HERE.
Pay attention that you would need to perform all calculations MOD 26 and to find multiplicative inverse of DET(A) mod 26

Bonus 2 (10 points): Combine Affine and Hill Cipher programs to be able to perform 2-step encryption and decryption.