Comeonin.Tools
Module that provides various tools for the hashing algorithms.
Summary↑
dec_base64(string) | Decode using an adapted base64 alphabet (using |
dec_bcrypt64(string) | Decode using a base64 alphabet adapted for bcrypt |
enc_base64(data) | Encode using an adapted base64 alphabet (using |
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
Decode using an adapted base64 alphabet (using .
instead of +
and with no padding).
Examples
iex> Comeonin.Tools.dec_base64 "c3BhbWFuZGVnZ3M"
"spamandeggs"
Decode using a base64 alphabet adapted for bcrypt.
Examples
iex> Comeonin.Tools.dec_bcrypt64 "a1/fZUDsXETlX1K"
"spamandeggs"
Encode using an adapted base64 alphabet (using .
instead of +
and with no padding).
Examples
iex> Comeonin.Tools.enc_base64 "spamandeggs"
"c3BhbWFuZGVnZ3M"
Encode using a base64 alphabet adapted for bcrypt.
Examples
iex> Comeonin.Tools.enc_bcrypt64 "spamandeggs"
"a1/fZUDsXETlX1K"
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.
Compares the two binaries in constant time to avoid timing attacks.