Part 1 (90 points): 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.
Part 2 (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.
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.