The encryption technique called Caesar Cipher replaces each letter in a text message by a letter that appears a fixed distance in the alphabet. As an example, suppose that you wanted to encode a message by shifting every letter ahead three places. In this cipher, each A becomes a D, B becomes E, and so on. If you reach the end of the alphabet, the process cycles around to the beginning, so that X becomes A, Y becomes B, and Z becomes C.
Note that the transformation applies only to letters; any other characters are copied unchanged to the output, where the case of letters is unaffected: lowercase letters come out as lowercase, and uppercase letters come out as uppercase. Your python program should also accept negative shift values that means that letters are shifted toward the beginning of the alphabet instead of toward the end.
In addition to regular shifting, a second shifting is applied to each letter in the input stream, where a key of letters is used to figure out the shifting value of a letter in a text file. The key is entered from stdin and it can contain any number of letters. As an example, the key could be key = "QWERTYUIOPASDFGHJKLZXCVBNM". For the letter A, the corresponding letter in the key is Q, so the second shift value for A is -16 that is the difference between the ASCII values of A and Q; for the letter B, the corresponding letter in the key is W that yields the second shift value of 21; for the letter C, the corresponding letter in the key is E that yields the second shift value of 2; etc. For a lowercase letter, you need to convert the letter to uppercase before you use. If the length of the key is less than 26, then the position of a letter in the key can be determined by the expression: k % len ( key ), where k is the position of the letter in the 26-letter alphabetic sequence. If the length of the key is greater than 26, simply discard the letter beyond the 26 letters.
There are two data files for this program: prog3.d1 and prog3.d2. The first file contains several test values for shift and key, and the second one contains a text message to encode.
Note: If you want to test your program, simply enter arbitrary key, shift pairs from the stdin and use the full pathname of your data file in your python program instead of the test data file prog3.d2