Last active
December 17, 2015 23:09
-
-
Save mwollenweber/5687219 to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/python | |
#base94 decode | |
tati_string = "replace me" | |
def decode(input): | |
output = 0 | |
base = ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}' | |
power = 0 | |
for c in input: | |
output += base.index(c) * len(base)**power | |
power += 1 | |
return output | |
def encode(input): | |
output = '' | |
base = ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}' | |
while input > 0: | |
r = len(input) % len(base) | |
output += base[r] | |
input = int((input-r) / len(base)) | |
return output | |
print decode(tati_string) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment