Krug.HashUtil (Krug v0.4.11) View Source

Utilitary module to handle Bcrypt hashes. Useful for store and compare on more secure forms passwords.

Link to this section Summary

Functions

Makes a password hash to improve a better security on storage.

Compares a clean text string password with a string hashed password and verify if one matches another.

Link to this section Functions

Makes a password hash to improve a better security on storage.

If nil/empty password received return a empty string.

Example

iex > password = "123456"
iex > Krug.HashUtil.hash_password(password)
$2b$10$y9nOBmx.kJV3juLBivaixuWMpIoB7ctGREqqrwvvgbqprY/BIRDX6
Link to this function

password_match(hashed_password, password)

View Source

Compares a clean text string password with a string hashed password and verify if one matches another.

If hashed_password or password is nil/empty, return false.

Example

iex > password = "123456"
iex > hashed_password = "$2b$10$y9nOBmx.kJV3juLBivaixuWMpIoB7ctGREqqrwvvgbqprY/BIRDX6"
iex > Krug.HashUtil.password_match(hashed_password,password)
true (or false if not matches)