pyufunc.generate_password#
- pyufunc.generate_password(pwd_len=15, lowercase=True, uppercase=True, digit=True, special_char=True, config={'num_digit': 1, 'num_lowercase': 1, 'num_special_char': 1, 'num_uppercase': 1})#
Generate a random password with given length and character types.
- Location:
The function defined in pyufunc/util_common/_password_generator.py.
- Parameters:
pwd_len (int, optional) – total length of password. Defaults to 15.
lowercase (bool, optional) – whether to include lowercase in password. Defaults to True.
uppercase (bool, optional) – whether to include uppercase in password. Defaults to True.
digit (bool, optional) – whether to include digits in password. Defaults to True.
special_char (bool, optional) – whether to include special character in password. Defaults to True.
config (_type_, optional) – Defaults to {“num_lowercase”: 1, “num_uppercase”: 1, “num_digit”: 1, “num_special_char”: 1}.
- Raises:
ValueError – if the total length of password in config is longer than the password length.
- Returns:
the generated password.
- Return type:
Examples
>>> generate_password() '5#4X6v8&9^0%1$2'
>>> generate_password(pwd_len=20, lowercase=False, uppercase=False, digit=True, special_char=False) '83920174651235323436'
>>> generate_password( ... pwd_len=20, ... config={"num_lowercase": 5, "num_uppercase": 5, "num_digit": 5, "num_special_char": 5}, ... ) '5y9D`Bp|5h0FXX3}%'px'