39 lines
943 B
Python
39 lines
943 B
Python
import random
|
|
import string
|
|
|
|
|
|
def validate_length(length):
|
|
if length < 8:
|
|
print("Пароль должен быть не менее 8 символов")
|
|
return False
|
|
else:
|
|
return True
|
|
|
|
|
|
def generate_password(length, use_digits, use_special):
|
|
password_book = string.ascii_letters
|
|
if use_digits:
|
|
password_book += string.digits
|
|
if use_special:
|
|
password_book += string.punctuation
|
|
result = "".join(random.choices(password_book, k=length))
|
|
return result
|
|
|
|
|
|
def create_passwords(count, length):
|
|
pasword_list = []
|
|
i = 0
|
|
for i in range(count):
|
|
if validate_length(length):
|
|
pasword = generate_password(
|
|
length,
|
|
use_digits=False,
|
|
use_special=False
|
|
)
|
|
pasword_list.append(pasword)
|
|
i += 1
|
|
return pasword_list
|
|
|
|
|
|
print(create_passwords(5, 12))
|