Renamed gen_password.py into generate_password.py, fixed gen_password command
This commit is contained in:
18
src/generate_password.py
Normal file
18
src/generate_password.py
Normal file
@ -0,0 +1,18 @@
|
||||
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
|
Reference in New Issue
Block a user