Comeonin.Tools

Module that provides various tools for the hashing algorithms.

Source

Summary

dec_base64(string)

Decode using an adapted base64 alphabet (using . instead of + and with no padding)

dec_bcrypt64(string)

Decode using a base64 alphabet adapted for bcrypt

enc_base64(data)

Encode using an adapted base64 alphabet (using . instead of + and with no padding)

enc_bcrypt64(data)

Encode using a base64 alphabet adapted for bcrypt

random_bytes(number)

Use erlang’s crypto.strong_rand_bytes by default. Falls back to crypto.rand_bytes if there is too little entropy for strong_rand_bytes to work

secure_check(hash, stored)

Compares the two binaries in constant time to avoid timing attacks

Functions

dec_base64(string)

Decode using an adapted base64 alphabet (using . instead of + and with no padding).

Examples

iex> Comeonin.Tools.dec_base64 "c3BhbWFuZGVnZ3M"
"spamandeggs"
Source
dec_bcrypt64(string)

Decode using a base64 alphabet adapted for bcrypt.

Examples

iex> Comeonin.Tools.dec_bcrypt64 "a1/fZUDsXETlX1K"
"spamandeggs"
Source
enc_base64(data)

Encode using an adapted base64 alphabet (using . instead of + and with no padding).

Examples

iex> Comeonin.Tools.enc_base64 "spamandeggs"
"c3BhbWFuZGVnZ3M"
Source
enc_bcrypt64(data)

Encode using a base64 alphabet adapted for bcrypt.

Examples

iex> Comeonin.Tools.enc_bcrypt64 "spamandeggs"
"a1/fZUDsXETlX1K"
Source
random_bytes(number)

Use erlang’s crypto.strong_rand_bytes by default. Falls back to crypto.rand_bytes if there is too little entropy for strong_rand_bytes to work.

Source
secure_check(hash, stored)

Compares the two binaries in constant time to avoid timing attacks.

Source