Pbkdf2.add_hash

You're seeing just the function add_hash, go back to Pbkdf2 module for more information.
Link to this function

add_hash(password, opts \\ [])

View Source

Hashes a password, using hash_pwd_salt/2, and returns the password hash in a map.

This is a convenience function that is especially useful when used with Ecto changesets.

Options

In addition to the :hash_key option show below, this function also takes options that are then passed on to the hash_pwd_salt/2 function in this module.

See the documentation for hash_pwd_salt/2 for further details.

  • :hash_key - the password hash identifier
    • the default is :password_hash

Example with Ecto

The put_pass_hash function below is an example of how you can use add_hash to add the password hash to the Ecto changeset.

defp put_pass_hash(%Ecto.Changeset{valid?: true, changes:
    %{password: password}} = changeset) do
  change(changeset, add_hash(password))
end

defp put_pass_hash(changeset), do: changeset

This function will return a changeset with %{password_hash: password_hash} added to the changes map.