19 lines
498 B
Python
19 lines
498 B
Python
import string
|
|
from random import SystemRandom
|
|
|
|
from .account_checks import FORBIDDEN_CHARS, PUNCTUATION, check_gened_password
|
|
|
|
PASSWORD_CHARS = tuple(
|
|
frozenset(string.ascii_letters + string.digits).difference(FORBIDDEN_CHARS)
|
|
| PUNCTUATION
|
|
)
|
|
|
|
|
|
def gen_password() -> str:
|
|
"""Generates password of length 32"""
|
|
choices = SystemRandom().choices
|
|
while True:
|
|
passwd = "".join(choices(PASSWORD_CHARS, k=32))
|
|
if check_gened_password(passwd):
|
|
return passwd
|