Module erlpass

Erlpass is a simple wrapper library trying to abstract away common password operations using safe algorithms, in this case, bcrypt.

Authors: Fred Hebert (mononcqc@gmail.com) [web site: http://ferd.ca/].

Description

Erlpass is a simple wrapper library trying to abstract away common password operations using safe algorithms, in this case, bcrypt.

Data Types

hash()

hash() = binary()

The hashed password with a given work factor.

password()

password() = iodata()

A password, supports valid unicode.

work_factor()

work_factor() = 4..31

Work factor of the bcrypt algorithm.

Function Index

change/3If a given password matches a given hash, the password is re-hashed again using the new work factor.
change/4If a given old password matches a given old hash, a new password is hashed using the work factor passed in as an argument.
hash/1Similar to hash(Password, 12).
hash/2Hashes a given password with a given work factor.
match/2Compares a given password to a hash.

Function Details

change/3

change(Pass::password(), Hash::hash(), Factor::work_factor()) -> hash() | {error, bad_password}

Equivalent to change(Pass, Hash, Pass, Factor).

If a given password matches a given hash, the password is re-hashed again using the new work factor. This allows to update a given work factor to something stronger.

change/4

change(OldPass::password(), Hash::hash(), NewPass::password(), Factor::work_factor()) -> hash() | {error, bad_password}

If a given old password matches a given old hash, a new password is hashed using the work factor passed in as an argument. Allows to safely change a password, only if the previous one was given with it.

hash/1

hash(S::password()) -> hash()

Similar to hash(Password, 12).

hash/2

hash(Str::password(), Factor::work_factor()) -> hash()

Hashes a given password with a given work factor. Bcrypt will be used to create a hash of the password to be stored by the application. Compare the password to the hash by using match/2. Bcrypt takes care of salting the hashes for you so this does not need to be done. The higher the work factor, the longer the password will take to be hashed and checked.

match/2

match(Pass::password(), Hash::hash()) -> boolean()

Compares a given password to a hash. Returns true if the password matches, and false otherwise. The comparison is done in constant time (based on the hash length)


Generated by EDoc