ExPassword.Bcrypt (expassword_bcrypt v0.2.2) View Source
This module implements the ExPassword.Algorithm
behaviour to add support for Bcrypt hashing algorithms.
Except for specific details about proper options and deeper details, you might looking for ExPassword
's
documentation.
Link to this section Summary
Functions
Extracts informations from a given bcrypt hash (the options used to generate it in the first place)
Computes the hash for password. A salt of 16 bytes is randomly generated and prepended to password before hashing.
Compares the options used to generate hash to options and returns true
if they differ, which
means you should rehash the password to update its hash.
Returns true
if hash seems to be a Bcrypt hash.
Checks that a password matches the given bcrypt hash
Link to this section Functions
Extracts informations from a given bcrypt hash (the options used to generate it in the first place)
Returns {:error, :invalid}
if hash is not a valid bcrypt hash else {:ok, map}
where map is a Map which
contains all the parameters that permitted to compute this hash.
iex> ExPassword.Bcrypt.get_options("$2a$04$5DCebwootqWMCp59ISrMJ.l4WvgHIVg17ZawDIrDM2IjlE64GDNQS")
{:ok, %{cost: 4}}
Computes the hash for password. A salt of 16 bytes is randomly generated and prepended to password before hashing.
Valid options are:
- cost: the algorithmic cost. It defines the number of iterations as a power of two (2^cost) so higher is the cost longer it takes to compute it (and consequently brute force it)
An ArgumentError
will be raised if one of the options above is invalid or if an internal error occurs.
Compares the options used to generate hash to options and returns true
if they differ, which
means you should rehash the password to update its hash.
Returns true
if hash seems to be a Bcrypt hash.
This function is intended to quickly identify the algorithm which produces the given hash.
It does not perform extended checks like get_options/1
nor needs_rehash?/2
nor verify?/2
do.
Checks that a password matches the given bcrypt hash
An ArgumentError
will be raised if the hash is somehow invalid or if an internal error occurs.