Proof-of-concept for a GitHub1 / npm2 style token library in Python.
This may not fulfill the security requirements for a real world application. Please do not use it in production.
import base62_token
token = base62_token.generate("prefix",32)
if base62_token.is_valid(token):
...
The base62 algorithms used in encode
/decode
should be COMPATIBLE3 with saltpack / GMP / GnuPG.
generate
and is_valid
are not designed to be compatible with anything else.
is_valid_gh
verifies prefix and checksum for the old new GitHub tokens1.
generate_gh
creates dummy tokens that should be indistinguishable from real ones without active validation.