-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuzume
executable file
·38 lines (29 loc) · 1.17 KB
/
uzume
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
#!/usr/bin/env python
import random, string
import argparse
import os
import sys
arg_to_charset = {
'uppercase': string.ascii_letters,
'numbers': string.digits,
'symbols': string.punctuation
}
parser = argparse.ArgumentParser()
parser.add_argument("length", default=10, type=int, nargs='?', help='Length of the generated password. Defaults to 10')
parser.add_argument("-u", "--uppercase", action='store_true', required=False, help='Include uppercase letters')
parser.add_argument("-n", "--numbers", action='store_true', required=False, help='Include numbers')
parser.add_argument("-s", "--symbols", action='store_true', required=False, help='Include symbols')
a = parser.parse_args()
def randompass():
length = a.length
charsets = [string.ascii_lowercase]
for arg, charset in arg_to_charset.items():
if getattr(a, arg):
charsets.append(charset)
output = ''.join(random.choice(''.join(charsets)) for _ in range(length))
if "NO_COLOR" in os.environ or not sys.stdout.isatty():
return output
else:
return '\033[93m' + output + '\033[0m' # colored output
if __name__ == '__main__':
print(randompass())