Last active
August 29, 2015 13:56
-
-
Save n8foo/8894702 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
alphabet = '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ' | |
base = len(alphabet) | |
def b58enc(div, s=''): | |
if div >= base: | |
div, mod = divmod(div, base) | |
return b58enc(div, alphabet[mod] + s) | |
return alphabet[div] + s | |
def b58dec(s): | |
return sum(alphabet.index(c) * pow(base, i) for i, c in enumerate(reversed(s))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment