Last active
December 29, 2015 19:49
-
-
Save shoya140/7719943 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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