vinegar.transform.passlib
Transformations for encrypting passwords.
The transformations provided by this module use the passlib library, so
they are only available if that library is installed.
- vinegar.transform.passlib.hash(plaintext: str, method: str = 'sha512_crypt', **kwargs) str
Hash a password using one of the methods supported by
passlib.hash.Note
passlibmay use different default parameters when hashing a password. For example, thesha512_cryptwill use a higher number of of rounds than the default value used by most Linux system’scrypt. If you want to use the same parameters, you have to set the keyword argumentroundsto 5000.Usage example (when specified in a YAML configuration file):
transform: - passlib.hash: plaintext: "mypassword" method: sha256_crypt rounds: 5000
- Parameters:
plaintext – password string to be enrcypted / hashed.
method – hash method to be used. This must be a string that identifies one of the methods that are supported passlib. For example, if
methodissha256_crypt,passlib.hash.sha256_cryptis going to be used. The default issha512_crypt.kwargs – additional keyword arguments that are passed to the
hashorencryptmethod of the hashing object specified bymethod.
- Returns:
encrypted (hashed) password.