package documentation

Password tools.

From __init__.py:

Function check Check if a password matches a hash.
Function compare Compares two Strings in a safe way to prevent timing attacks.
Function encode Encode a password into a hash.
Function _pbkdf2 Undocumented
Function _random_string Undocumented
def compare(a: str, b: str) -> bool: (source)

Compares two Strings in a safe way to prevent timing attacks.

Parameters
a:str1st String.
b:str2nd String.
Returns
boolTrue if a equals b, False otherwise.
def encode(password: str, algo: str = 'sha512') -> str: (source)

Encode a password into a hash.

Parameters
password:strString password.
algo:strHashing algorithm. Default is SHA512.
Returns
strRespective hash value in the format $algorithm$salt$hash.
def check(password: str, encoded: str) -> bool: (source)

Check if a password matches a hash.

Parameters
password:strPassword as a string.
encoded:strHash of the input password as a string.
Returns
boolTrue if password matches the hash, else False.
def _pbkdf2(password, salt, algo): (source)

Undocumented

def _random_string(length): (source)

Undocumented