# Program to encrypt 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) # plain = raw_input("Enter your message here: ") # # initialize output (ciphertext) # cipher = "" # # encipher each character and append it to current ciphertext # for i in plain: # 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 cipher = cipher + lett # # print it, surrounded by quotes # print '"' + cipher + '"'