Skip to content

Instantly share code, notes, and snippets.

@nazt
Created April 6, 2010 07:15
Show Gist options
  • Save nazt/357312 to your computer and use it in GitHub Desktop.
Save nazt/357312 to your computer and use it in GitHub Desktop.
# Decrypt the given cyphertext using the Caesar cipher. Shift by the given
# shift value.
def encrypt(string, shift):
# for i in range('A', 'Z'):
for c in string:
print chr((((ord(c)-ord('a'))+shift)%26)+ord('a')),
def decrypt(ciphertext,shift):
print 'decrypt'
for c in ciphertext:
print chr((((ord(c)-ord('a'))-shift)%26)+ord('a')),
##
########## END Decryption Code #############################
# for i in range(ord('a'),ord('z')):
decrypt('the',3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment