libscrypt
scrypt
7.0

libscrypt

Jan Dvorak <[email protected]>

Colin Percival’s SCrypt library bindings. Provides the scrypt function for secure password derivation.

 (require libscrypt) package: libscrypt

procedure

(scrypt password    
  salt    
  [#:N N    
  #:r r    
  #:p p    
  #:size size])  bytes?
  password : (or/c string? bytes?)
  salt : (or/c string? bytes?)
  N : exact-positive-integer? = 14
  r : exact-positive-integer? = 8
  p : exact-positive-integer? = 1
  size : exact-positive-integer? = 32
Derive key of given size using user-supplied password and a salt. Salt should be random when you derive the key for permanent storage and needs to be stored along the password. Salts must not be reused.

It should be sufficient to call it with default options, specifying the output size only:

Example:
> (time
    (bytes->hex-string
      (scrypt "secret" "salt" #:size 8)))

cpu time: 51 real time: 51 gc time: 0

"05ffaebcca41770a"

If you need to tune the difficulty, for example to use more memory, you can do so. The overall difficulty N is given as exponent, r is the memory cost and p parallelisation.

Example:
> (time
    (bytes->hex-string
      (scrypt "letmein" "sugar" #:N 14 #:r 28 #:p 1 #:size 16)))

cpu time: 173 real time: 173 gc time: 0

"7503c151df1219d6fcd3a23c97cad9d5"