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

passlib may use different default parameters when hashing a password. For example, the sha512_crypt will use a higher number of of rounds than the default value used by most Linux system’s crypt. If you want to use the same parameters, you have to set the keyword argument rounds to 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 method is sha256_crypt, passlib.hash.sha256_crypt is going to be used. The default is sha512_crypt.

  • kwargs – additional keyword arguments that are passed to the hash or encrypt method of the hashing object specified by method.

Returns:

encrypted (hashed) password.