Last active
July 12, 2018 16:10
-
-
Save matcool/9ada9eadf42d462c76ffa09b688e3e4f to your computer and use it in GitHub Desktop.
really unescessary because of the base64 module but eh
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
def decode(s): | |
result = '' | |
chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=" | |
for i in range(0,len(s),4): | |
b = [chars.find(s[j]) for j in range(i,i+4)] | |
result += chr((b[0] << 2) | (b[1] >> 4)) | |
if (b[2] != 64): result += chr(((b[1] & 15) << 4) | (b[2] >> 2)) | |
if (b[3] != 64): result += chr(((b[2] & 3) << 6) | b[3]) | |
return result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment