Skip to content

Instantly share code, notes, and snippets.

@thiagodeschamps
Last active August 24, 2018 17:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thiagodeschamps/a2fceaa732427ad520be0ed7da80803d to your computer and use it in GitHub Desktop.
Save thiagodeschamps/a2fceaa732427ad520be0ed7da80803d to your computer and use it in GitHub Desktop.
Show all the possible combinations in a Ceasar encripture
def decypher(word):
des = ''
pos = 0
for c in range(0, 26):
for i in word:
if ord(i.upper()) + c > 90:
pos = 64
aux = ord(i.upper()) + c - 90
des += chr(pos + aux)
else:
pos = ord(i)
des += chr(pos + c)
print(des, f'- key = {c}')
des = ''
word = str(input('Insert the word to shift in all possible ways: '))
decypher(word)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment