-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgenerate_uuid.py
executable file
·52 lines (37 loc) · 1.14 KB
/
generate_uuid.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/python3
"""
Use this script to generate random strings
USAGE:
-q sets the amount of IDs to generate, default 1
-l sets the length of each ID, default 8
FOR LINUX USERS:
I personally run this command: ./generate_uuid.py | xclip -selection c -rmlastnl
This will automatically copy the output to my clipboard
Note that just selecting the output and copying and pasting manually is sufficient
"""
import argparse
from secrets import randbelow
# These should be case insensitive and generally just
# not a pain to encode or move around
CHARS = [i for i in "abcdefghijklmnopqrstuvwxyz0123456789"]
CHARS_LEN = len(CHARS)
argp = argparse.ArgumentParser()
argp.add_argument(
"--quantity", "-q",
type=int, default=1,
help="Number of strings to generate")
argp.add_argument(
"--length", "-l",
type=int, default=8,
help="length of the string to generate"
)
args = argp.parse_args()
quantity = args.quantity
length = args.length
def random_string():
ret = ""
for i in range(0, length):
ret += CHARS[randbelow(CHARS_LEN)]
return ret
for i in range(0, quantity):
print(random_string())