I was wondering if someone could help me with modifying a program. I first must write a program that not only encrypts, but decrypts a message as well. This part I think I have figured out (although it is probabaly a little bloated) here it is:
#Cypher.py #A program that encrypts/decrypts a message import string def main(): print"This program will either encrypt or decrypt a message." mess = raw_input("Please enter your message: ") meth = raw_input("Enter 0 for encryption, 1 for decryption: ") while meth >= "2": print "Please enter 0 or 1 ONLY." meth = raw_input("Enter 0 for encryption, 1 for decryption: ") key = raw_input("What key index do you want to use: ") mesCode =  if meth == "0": for ch in(mess): ch = chr(ord(ch)+ eval(key)) mesCode.append(ch) elif meth == "1": for ch in(mess): ch = chr(ord(ch) - eval(key)) mesCode.append(ch) print string.join(mesCode,"") main()
( I hope I enclosed that right)
Anyway, now I have to modify it so that when we "drop off the end" of the alaphabet, the cypher shift goes in a circular fashion, ie: after z comes a again. I have found other solutions, but think I have gone a little over my head with my if/elif statements, and I can't get them to work properly.
Could someone point me in the right direction as to where to take this next, and also, (I feel dumb asking this), WHY would you want the shift to go in a circular fashion? Thanks for any and all advice
Ps. I am using Python 2.6.1, which came with the book, and have no prior programming experience.