Skip to content

Instantly share code, notes, and snippets.

@zyuiop
Created December 20, 2015 18:19
Show Gist options
  • Save zyuiop/200923954aa59641dd8a to your computer and use it in GitHub Desktop.
Save zyuiop/200923954aa59641dd8a to your computer and use it in GitHub Desktop.
word = input("Expression > ")
step = int(input("Decallage > "))
word = word[::-1] # Reverse letters order
def decryptLetter(letter, key):
pos = ord(letter)
upBound, downBound = 0, 0
if pos >= 97 and pos <= 122:
upBound = 122
downBound = 97
elif pos >= 65 and pos <= 90:
upBound = 90
downBound = 65
else:
return letter
pos += key
if pos > upBound:
pos -= 26
if pos < downBound:
pos += 26
return chr(pos)
print(''.join([decryptLetter(char, step) for char in word]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment