2024-02-24 23:40:48 +05:30
|
|
|
#!/usr/bin/python3
|
|
|
|
|
|
|
|
# generate_C_lang_token.py
|
|
|
|
#
|
|
|
|
# Author: Intel A80486DX2-66
|
2024-04-26 01:46:39 +05:30
|
|
|
# License: Unlicense
|
2024-02-24 23:40:48 +05:30
|
|
|
|
|
|
|
from random import choice
|
|
|
|
from string import ascii_lowercase, ascii_uppercase, digits
|
2024-02-24 23:56:12 +05:30
|
|
|
from sys import argv, stdin
|
2024-02-24 23:40:48 +05:30
|
|
|
|
2024-05-05 12:35:02 +05:30
|
|
|
first_char_alphabet = ascii_uppercase + ascii_lowercase
|
|
|
|
alphabet = first_char_alphabet + digits + "_"
|
2024-02-24 23:40:48 +05:30
|
|
|
|
|
|
|
random_token = lambda n: \
|
|
|
|
"".join( \
|
|
|
|
[choice(first_char_alphabet)] + \
|
2024-02-24 23:56:12 +05:30
|
|
|
[choice(alphabet) for i in range(n - 1)]) if (n := int(n)) > 0 else ""
|
|
|
|
|
|
|
|
if "-" in argv[1:] and stdin:
|
|
|
|
print(random_token(list(stdin)[0]))
|
|
|
|
else:
|
|
|
|
print("Random token:", random_token(input("Token length? ")))
|
2024-02-24 23:40:48 +05:30
|
|
|
|