def _generate_derived_key(password, salt=None, iterations=None):
<EOL>backend = default_backend()<EOL>if salt is None:<EOL><INDENT>salt = os.urandom(_SALT_SIZE)<EOL><DEDENT>if iterations is None:<EOL><INDENT>iterations = _PBKDF2_ITERATIONS<EOL><DEDENT>pbkdf_object = PBKDF2HMAC(algorithm=hashes.SHA256(), length=<NUM_LIT:32>, salt=salt,<EOL>iterations=iterations, backend=backend)<EOL>derived_key = pbkdf_object.derive(password.encode('<STR_LIT:utf-8>'))<EOL>return salt, iterations, derived_key<EOL>
Generate a derived key by feeding 'password' to the Password-Based Key
Derivation Function (PBKDF2).  pyca/cryptography's PBKDF2 implementation is
used in this module.  'salt' may be specified so that a previous derived key
may be regenerated, otherwise '_SALT_SIZE' is used by default.  'iterations'
is the number of SHA-256 iterations to perform, otherwise
'_PBKDF2_ITERATIONS' is used by default.