Back

encrypt (clj)

(source)

function

(encrypt raw) (encrypt raw n) (encrypt raw n r p)
Encrypt a password string using the scrypt algorithm. This function takes three optional parameters: * `n` - the CPU cost, must be a power of 2, defaults to 2^15 * `r` - the memory cost, defaults to 8 * `p` - the parallelization parameter, defaults to 1

Examples

weavejester/crypto-password
(ns crypto.password.scrypt-test
  (:require [clojure.test :refer :all]
            [crypto.password.scrypt :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"))