I'm working on a simple Caesar Cipher in python using chr()
and ord()
Here's my code:
key = 13
newString = ''
if mode == 'decrypt':
key = -key
for c in message:
newString += chr(ord(c) + key)
print newString
But something funny happens!
When I input: "Hello world!"
, I get back "Uryy|-?|yq."
Looks about right, right?
But when I try deciphering it,
I get: Hello 2old!
Any insights? I'm thinking it has to do with chr()
returning something like this: '\x84'