Following algorithms are supported:
Pick an encryption algorithm, either bcrypt
or scrypt
:
(require '[macchiato.crypto.<algorithm> :as password])
Then use the encrypt
function to apply a secure, one-way encryption
algorithm to a password:
(def encrypted (password/encrypt "foobar"))
And the check
function to check the encrypted password against a
plaintext password:
(password/check "foobar" encrypted) ;; => true
The encrypt
and check
functions have async versions as well:
(password/encrypt-async
"secret"
(fn [err result]
(is (scrypt/check "secret" result))))
(password/check-async
"secret"
(password/encrypt "secret")
(fn [err result]
(is result)))