Last active
May 10, 2019 04:23
-
-
Save bulatie/fdd1e6da521b2c90fcb6285401eaf4e9 to your computer and use it in GitHub Desktop.
genereate token
This file contains hidden or 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
# python2 | |
import os | |
import string | |
charset = string.ascii_uppercase + string.digits | |
random_bytes = os.urandom(25) | |
len_charset = len(charset) | |
indices = [int(len_charset * (ord(byte) / 256.0)) for byte in random_bytes] | |
defaultToken = "".join([charset[index] for index in indices]) | |
# python3 | |
"".join(secrets.choice(string.ascii_uppercase + string.digits) for i in range(25)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment