Can anybody help me out on creating the ceasar cipher. I am attempting to create the program with several functions, including a function for a password. I think that it adds a few more "bells and whistles" by adding this feature. When I run the script below, what is being printed is the location of memory that it is being kept in.
Although I have yet to finish writing this script, i.e. for the decoding function, I can't seem correctly encrypt the string and have yet to get that far.
Any assistance would be greatly appreciated.
######CEASAR CIPHER##########
from string import *
def message():
print "Type in a message to encrypt:"
return raw_input()
def key():
print "What numerical value should the text be encrypted?"
return int(raw_input())
def password():
print "Please enter a password to protect this message:"
return raw_input()
print "Your message is now password protected."
def encrypted_message():
char = message
encrypted_message = ""
for char in encrypted_message:
x = ord(char)
if char.isalpha():
x = x + key
offset = 65
if char.islower():
offset = 97
while x < offset:
x += 26
while x > offset+25:
x -= 26
encrypted_message += chr(x+key)
print encrypted_message
def user_key():
user_key = raw_input("Please enter the password: \t")
if user_key==password:
print message
while user_key != password:
print "The password is incorrect."
user_key = raw_input("Please enter the password: \t")
if user_key == password:
print message
def decoder():
user_key()
if user_key == password:
print message
def main():
print 5*"\n"
repeat = "y"
while repeat == "y" or repeat == "Y":
print 5*"\n"
message()
key()
password ()
encrypted_message()
print encrypted_message
repeat = raw_input("Would you like to repeat the program? Press <y or n>")
ans = raw_input("Press <Enter> to QUIT. ")
main()