Practical Cryptology

CSCI 391: Practical Cryptology Fall 2010

Programming Lab Assignment - Programming Implementation of Affine 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.1, 2.2

Lab Assignment

Write a program that implements Affine Cipher encryption and decryption algorithms. 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 KEYS, A and B, and plaintext - a sequence of LOWER CASE letters. In case of decryption, the second input consists of KEYS, A and B, 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 multiplicative inverse of A mod 26. The program must output the multiplicative inverse along with plaintext in case of decryption. Also, your program must to check validity of the keys. In case of invalid keys you can decide to exit from the program or to ask user to re-enter the keys. You can decide on number of attempts. All choices should be well documented in comments and in output messages.

Bonus 1 (10 points): Write a program that implements a Brute Force attack on Shift Cipher.

In this program there is only one input - ciphertext - is a sequence of UPPER CASE letters. To make it easy, the program will be interactive and will output all possible plaintexts and ask user which plaintext makes sense. As soon as user will decide YES, the program will stop searching and print the desired plaintext and the found SHIFT KEY.

Bonus 2 (100 points): Write a program that implements Chaocipher Algorithm. For description of the Chaocipher Algorithm see the following paper of Moshe Rubin Chaocipher-Revealed: The Algorithm. If you decide to implement this bonus program it will repalce the Affine Cihper for this assignment.

Important

If you are experiencing difficulties in implementing Affine Cipher, you would be able to get partial credit for implementing Caesar Cipher encryption and decryption algorithms for maximal score of 75 points or General Shift Cipher encryption and decryption algorithms for maximal score of 85 points.

YOU CAN ONLY CHOOSE ONE PROGRAM! YOU CANNOT IMPLEMENT CAESAR AND SHIFT CIPHER TO RECEIVE A FULL CREDIT. FULL CREDIT COULD BE RECEIVED ONLY IF YOU IMPLEMENT AFFINE CIPHER.