Pbkdf2.hash_pwd_salt
You're seeing just the function
hash_pwd_salt
, go back to Pbkdf2 module for more information.
Hashes a password with a randomly generated salt.
Options
In addition to the options for Pbkdf2.Base.gen_salt/1
(:salt_len
and
:format
), this function also takes options that are then passed on to
the hash_password
function in the Pbkdf2.Base
module.
See the documentation for Pbkdf2.Base.hash_password/3
for further details.
Examples
The following examples show how to hash a password with a randomly-generated salt and then verify a password:
iex> hash = Pbkdf2.hash_pwd_salt("password")
...> Pbkdf2.verify_pass("password", hash)
true
iex> hash = Pbkdf2.hash_pwd_salt("password")
...> Pbkdf2.verify_pass("incorrect", hash)
false
The next examples show how to use some of the various available options:
iex> hash = Pbkdf2.hash_pwd_salt("password", rounds: 100_000)
...> Pbkdf2.verify_pass("password", hash)
true
iex> hash = Pbkdf2.hash_pwd_salt("password", digest: :sha256)
...> Pbkdf2.verify_pass("password", hash)
true
iex> hash = Pbkdf2.hash_pwd_salt("password", digest: :sha256, format: :django)
...> Pbkdf2.verify_pass("password", hash)
true