-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
utils.py
24 lines (20 loc) · 853 Bytes
/
utils.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
import string
import secrets
import random
def generate_password(length, include_numbers, include_mixed_case, include_symbols):
characters = string.ascii_letters
if include_numbers:
characters += string.digits
if include_symbols:
characters += string.punctuation
if include_mixed_case:
password = ''.join(secrets.choice(characters) for i in range(length))
else:
password = ''.join(random.choice(string.ascii_lowercase) for i in range(length))
return password
def generate_passwords(length, include_numbers, include_mixed_case, include_symbols, num_passwords):
passwords = []
for i in range(num_passwords):
password = generate_password(length, include_numbers, include_mixed_case, include_symbols)
passwords.append(password)
return passwords