Skip to content

Instantly share code, notes, and snippets.

@rjjq
Last active September 15, 2019 02:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rjjq/dc28605f9e7414c428c9783b97a37b3f to your computer and use it in GitHub Desktop.
Save rjjq/dc28605f9e7414c428c9783b97a37b3f to your computer and use it in GitHub Desktop.
ruby - aidc2aidu
@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