quart-imp/quart_imp/auth/generate_salt.py

24 lines
426 B
Python
Raw Normal View History

2024-02-11 21:59:18 +00:00
from random import choice
from string import punctuation
def generate_salt(length: int = 4) -> str:
"""
Generates a string of (length) characters of punctuation.
:raw-html:`<br />`
The Default length is 4.
:raw-html:`<br />`
For use in password salting
:raw-html:`<br />`
-----
:return: str - salt of (length)
"""
return "".join(choice(punctuation) for _ in range(length))