Encryption / Decryption (Due 03 August 2013)

Cryptography is an ancient study of secret writing. There is a wealth of literature in this field. An extremely readable book on this subject is The Code Book by Simon Singh. This is a field of study that is of particular relevance to Computer Science. Given the widespread use of computers, one of the things people are interested in is making transactions over the internet more secure.

For this assignment we will be using a variation of the Caesar Cipher to encrypt and decrypt. The Caesar Cipher falls under the class of substitution cipher. It was said to have been used by Julius Caesar to encode messages to his generals. In the classic Caesar cipher the letters are shifted 3 places to the right. The message "return to rome" would be encoded as "uhwxuq wr urph". For this assignment the shift could be an arbitrary positive whole number.


Output: If the user does not correctly enter whether he or she wants to encrypt or decrypt or does not give a positive whole number for the shift parameter then print an error message (Invalid Input) and quit the program.

Otherwise, you will open the input file for reading. You have two options on how to read the file - either you can read the whole file as one string or read the file one line at a time. But in either case you will go through the input string character by character.

If the character is a digit, uppercase or lower case letter then you will apply the shift that the user has given you. A digit should map to a digit, a lower case letter to a lower case letter, and an upper case letter to an upper case letter.

You will write the resulting character in the output file. The output file will be in the same directory as the Python script. You will write any non-alphanumeric character (e.g. punctuation marks, blank spaces, or new line characters) as is. When you have finished processing the input file print a message that you are done. Remember to close both the input and output file at the end.

Here is what a typical session would look like:

Do you want to encrypt or decrpyt? (E / D): E

Enter name of input file: inFile.txt

Enter shift parameter: 8

Enter name of output file: outFile.txt

Output written to outFile.txt

The program that you will be writing will be called Cipher. We will be looking at good documentation, and adherence to the coding convention discussed in class. Your file Cipher.py will have the following header:

#  File: Cipher.py

#  Description:

#  Student Name:

#  Student UT EID:

#  Course Name: CS 303E

#  Unique Number: 

#  Date Created:

#  Date Last Modified:

Use the turnin program to submit your Cipher.py file. The TA should receive your work by 11 PM on Saturday, 03 August 2013. There will be substantial penalties if you do not adhere to the guidelines.

Most substitution ciphers are easy to crack. You may want to look at the Vigenere Cipher that involves using a pass phrase and is harder to deciper compared to the substitution cipher.