Skip to content

Instantly share code, notes, and snippets.

@Glench
Created January 19, 2014 05:46
Show Gist options
  • Save Glench/8500915 to your computer and use it in GitHub Desktop.
Save Glench/8500915 to your computer and use it in GitHub Desktop.
Get all the caesar ciphers for a given string.
# print all caesar ciphers
# python caesar.py word
import sys
for offset in range(1,26):
word = ''
for letter in sys.argv[1].lower():
num_of_letter = ord(letter)
new_num = num_of_letter + offset
if new_num > ord('z'):
new_num -= 26
elif new_num < ord('a'):
new_num += 26
word += chr(new_num)
print offset, word
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment