Encryption / Decryption (Due 28 October 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 simple algorithm to encrypt and decrypt called the transposition cipher. Here is an illustration of how we can encrypt the sentence - The quick brown fox jumps over the lazy dog.

00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
T h e q u i c k b r o w n f o x j u m p s o v e r t h e l a z y d o g .
T e q i k b o n f x j m s o e h a y d g
h u c r w o u p v r t e l z o .

We will form two strings - one with all the characters in the even locations starting at 0 and the other with all the characters in the odd locations. Our encrypted string will be the concatenation of the odd string and the even string.

even_str = 'Teqikbonfxjmsoe h aydg'
odd_str = 'h uc rw o up vrtelz o.'
encrypted_str = 'h uc rw o up vrtelz o.Teqikbonfxjmsoe h aydg'

The text that you want to encrypt or decrypt will always be in a file called input.txt. The output will always be written to a file called output.txt. You will prompt the user to enter whether he wants to encrypt or decrypt. Depending on his answer you will read the contents of the file input.txt as a single string and then encrypt or decrypt it using the transposition cipher. You will then write your result to the file output.txt. If the user does not enter the correct response, write an error message as specified and exit the program by doing a return.

Here is what a typical session would look like:

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

Output written to output.txt

Here is what a session would look like if the user does not supply the correct input value:

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

Wrong input. Bye.

For this assignment you may work with a partner. Both of you must read the paper on Pair Programming. .

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

#  File: Cipher.py

#  Description:

#  Student Name:

#  Student UT EID:

#  Partner Name:

#  Partner UT EID:

#  Course Name: CS 303E

#  Unique Number: 

#  Date Created:

#  Date Last Modified:

If you are working with a partner both of you will be submitting identical programs but make sure that you have your partner's name and eid in your program. If you are working alone, then remove the two lines that has the partner's name and eid in the header.

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

Most transposition 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 transposition cipher.