mirror of
https://gitlab.com/80486DX2-66/gists
synced 2024-12-26 11:30:03 +05:30
Python: add generate_C_lang_token.py
This commit is contained in:
parent
0ef6c03393
commit
b965674095
19
python-programming/generate_C_lang_token.py
Normal file
19
python-programming/generate_C_lang_token.py
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
# generate_C_lang_token.py
|
||||||
|
#
|
||||||
|
# Author: Intel A80486DX2-66
|
||||||
|
# License: Creative Commons Zero 1.0 Universal
|
||||||
|
|
||||||
|
from random import choice
|
||||||
|
from string import ascii_lowercase, ascii_uppercase, digits
|
||||||
|
|
||||||
|
first_char_alphabet = ascii_uppercase + ascii_lowercase + "_"
|
||||||
|
alphabet = first_char_alphabet + digits
|
||||||
|
|
||||||
|
random_token = lambda n: \
|
||||||
|
"".join( \
|
||||||
|
[choice(first_char_alphabet)] + \
|
||||||
|
[choice(alphabet) for i in range(n - 1)]) if n > 0 else ""
|
||||||
|
|
||||||
|
print("Random token:", random_token(int(input("Token length? "))))
|
Loading…
Reference in New Issue
Block a user