-
-
Save Gricha/9baed08833237d8a67b0 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
import uuid # from http://zesty.ca/python/uuid.html | |
import sys | |
import base64 | |
def fetch_code(custom_string="CODE_'): | |
""" | |
takes an optional argument, a string to be put at the beginning of a code, | |
so the code will look like that: | |
CODE_8mANDJ | |
KEY_9coOeC | |
default is CODE_ | |
usage: | |
fetch_code() | |
fetch_code(custom_string="KEY_") | |
""" | |
b64uid = '00000000' | |
uid = uuid.uuid4() | |
b64uid = base64.b64encode(uid.bytes,'-_') | |
code = b64uid[0:6] | |
return custom_string+code |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment