This commit is contained in:
Igor
2026-07-18 20:05:03 +03:00
parent ee235ece10
commit 2e823d96af
6 changed files with 75 additions and 6 deletions
+38
View File
@@ -0,0 +1,38 @@
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))