# Program to encrypt using Caesar cipher after eliminating spaces # Matt Bishop, Apr. 17, 2009 # for ECS 10 Spring 2009 # import string; # load string library; we use split # # 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 = ""; # # split the text into a list of words # this eliminates the white space that separates words # wordlist=string.split(plain); # # now for each word ... # for j in wordlist: # encipher each character and append it to current ciphertext for i in j: # shift character by key amount c = (ord(i) + key) % 256; cipher = cipher + chr(c); # # print it, surrounded by quotes # print "\"%s\"" % cipher;