Module Scrypt

module Scrypt: sig .. end
Strong, password based encryption.

No wheels invented. This module is a high level interface to the official scrypt distribution.

Scrypt is designed to make it costly to perform large scale custom hardware attacks by requiring large amounts of memory. (Wikipedia)


exception Scrypt_error of int
Scrypt_error code indicates an error during a call to the underlying C implementation of scrypt.

code is the exact return code reported by the underlying implementation and is defined as one of the following:


val encrypt : ?maxmem:int ->
?maxmemfrac:float -> ?maxtime:float -> string -> string -> string option
encrypt data passwd encrypts data using passwd and returns Some string of the cyphertext or None if there was an error.

The default values of maxmem=0, maxmemfrac=0.125, and maxtime=5.0 are chosen to match the the reference scrypt implementation.

See Meaning of maxmem, maxmemfrac, and maxtime.

val encrypt_exn : ?maxmem:int ->
?maxmemfrac:float -> ?maxtime:float -> string -> string -> string
Same as Scrypt.encrypt except raise Scrypt.Scrypt_error in case of an error.
val decrypt : ?maxmem:int ->
?maxmemfrac:float -> ?maxtime:float -> string -> string -> string option
decrypt cyphertext passwd decrypts cyphertext using passwd and returns Some string of the decrypted data or None if there was an error.

The default values of maxmem=0, maxmemfrac=0.5, and maxtime=300.0 are chosen to match the the reference scrypt implementation.

See Meaning of maxmem, maxmemfrac, and maxtime.

val decrypt_exn : ?maxmem:int ->
?maxmemfrac:float -> ?maxtime:float -> string -> string -> string
Same as Scrypt.decrypt except raise Scrypt.Scrypt_error in case of an error.

Meaning of maxmem, maxmemfrac, and maxtime