Bcrypt
Types
Config
record Config {
cost: Int
}Configuration for hashing
BcryptError
type BcryptError =
| InvalidCost Int
| InvalidHash String
| HashError String
deriving (Show, Eq, Debug)Why a hashing or verification operation failed.
Functions
hasher
fun hasher : ConfigA hasher with the default cost (12)
with_cost
fun with_cost : Int -> Config -> ConfigSet the cost (work factor). Must be between 4 and 31; a value outside
that range produces Err (InvalidCost cost) when you call hash.
hash
fun hash : String -> Config -> Result String BcryptErrorHash a password, producing a $2b$ bcrypt string (salt embedded).
Returns Err (InvalidCost cost) if the configured cost is out of range.
verify
fun verify : String -> String -> Result Bool BcryptErrorVerify a password against a bcrypt hash. Ok True on match, Ok False
on mismatch, and Err (InvalidHash msg) if the hash string is malformed.