# Program to decrypt using shift cipher of 3 # # Matt Bishop, MHI 289I, Winter 2018 # # # this corresponds to a key of 'D' ('A' = 0, ... 'Z' = 25) # key = 3 # # ask user for input message (plaintext) # cipher = raw_input("Enter your message here: ") # # initialize output (plaintext) # plain = "" # # decipher each character and append it to current plaintext # for i in cipher: # leave non-letters alone if i in "ABCDEFGHIJKLMNOPQRSTUVWXYZ": # map the letter into 0 . . 25 n = ord(i) - ord('A') # shift it n = (n - key) % 26 # map it back into a letter lett = chr(ord('A') + n) elif i in "abcdefghijklmnopqrstuvwxyz": # map the letter into 0 . . 25 n = ord(i) - ord('a') # shift it n = (n - key) % 26 # map it back into a letter lett = chr(ord('a') + n) else: lett = i # now append it plain = plain + lett # # print it, surrounded by quotes # print '"' + plain + '"'