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.
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.