ariadne/ariadne/utils/passwords.py

12 lines
311 B
Python

from __future__ import annotations
import secrets
import string
def random_password(length: int = 32) -> str:
"""Generate a random alphanumeric password with the requested length."""
alphabet = string.ascii_letters + string.digits
return "".join(secrets.choice(alphabet) for _ in range(length))