Back
encrypt (clj)
(source)function
(encrypt raw)
(encrypt raw work-factor)
Encrypt a password string using the BCrypt algorithm. The optional work
factor is the log2 of the number of hashing rounds to apply. The default
work factor is 11.
Examples
mcorbin/meuse
(ns meuse.interceptor.auth-test
(:require [meuse.auth.frontend :as auth-frontend]
[meuse.auth.token :as auth-token]
[meuse.helpers.fixtures :as fixtures]
[meuse.interceptor.auth :as auth]
[meuse.mocks.db :as mocks]
[clj-time.core :as t]
[crypto.password.bcrypt :as bcrypt]
[clojure.test :refer :all])
(:import java.util.UUID))
(def user-id (UUID/randomUUID))
(def token-clear (auth-token/generate-token))
(def token (bcrypt/encrypt token-clear))
weavejester/crypto-password
(ns crypto.password.bcrypt-test
(:require [clojure.test :refer :all]
[crypto.password.bcrypt :as password]))
(deftest test-passwords
(are [s] (password/check s (password/encrypt s))
"a"
"foo"
"password"
"Testing"
"Test123"
"ÁäñßOÔ"
"großpösna"
"Some rather long pass phrase perhaps out of a book or poem")
(are [s r] (not (password/check r (password/encrypt s)))
"a" "b"
"a" "a "
"aaaaa" "aaaaa\n"
"großpösna" "grossposna"))