Skip to content

Instantly share code, notes, and snippets.

@shoya140
Last active December 29, 2015 19:49
Show Gist options
  • Save shoya140/7719943 to your computer and use it in GitHub Desktop.
Save shoya140/7719943 to your computer and use it in GitHub Desktop.
import math
import string
class CCipher:
def decode(self, cipherText, shift):
res = ""
for val in cipherText:
res = res + self.getDecodedChar(val, shift)
return res
def getDecodedChar(self, char, shift):
seed = 'AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz'
index = seed.find(char)
if index < 0:
return char
res = index - shift*2
if res < 0:
res = res + len(seed)
elif res >= len(seed):
res = res - len(seed)
return seed[res]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment