Created
October 8, 2016 13:06
-
-
Save sergkondr/7fa534f83f0e0d89984191026e56fea6 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
abc = '0123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghjkmnopqrstuvwxyz' | |
def to_b58(div): | |
ret = '' | |
while div != 0: | |
div, mod = divmod(div, len(abc)) | |
ret += abc[mod] | |
return ret[::-1] | |
def from_b58(num): | |
div = 0 | |
for mod in num: | |
div = div * len(abc) + abc.find(mod) | |
return div |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment