Last active
September 15, 2019 02:57
-
-
Save rjjq/dc28605f9e7414c428c9783b97a37b3f to your computer and use it in GitHub Desktop.
ruby - aidc2aidu
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
@aidTable = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_" | |
def aidc2aidu(aid) | |
aidu = 0 | |
aid.split('').each do |c| | |
break if c == "@" | |
if v = @aidTable.index(c) | |
# aidu = aidu << 6 | |
# aidu = aidu | (v & 0x3f) | |
aidu = aidu * 64 + v % 63 | |
else | |
return 0 | |
end | |
end | |
return aidu | |
end | |
p aidc2aidu("9fM3MYRpR") # result : 2715110125190363 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment