Based on node-argon2.
npm install @leeor/bs-argon2 --save
Argon2.hash
typeTo promote security of the generated hashes, a special type is used to represent the output of the hashing functions. This should be used for protecting at the type level against leakage and usage of these values in sensitive areas (such as code that is used by both client and server).
Hash a string
or a Node.Buffer.t
returning an Argon2.hash
.
type hashInput =
| String(string)
| Buffer(Node.Buffer.t);
let hash:
(
~hashLength: int=?,
~timeCost: int=?,
~memoryCost: int=?,
~parallelism: int=?,
~type_: hashMode=?,
~version: version=?,
~salt: Node.Buffer.t=?,
~saltLength: int=?,
~associatedData: Node.Buffer.t=?,
hashInput
) =>
Js.Promise.t(hash);
958: <UNKNOWN SYNTAX ERROR>
Hash a string
or a Node.Buffer.t
returning a Node.Buffer.t
.
type hashInput =
| String(string)
| Buffer(Node.Buffer.t);
let hashRaw:
(
~hashLength: int=?,
~timeCost: int=?,
~memoryCost: int=?,
~parallelism: int=?,
~type_: hashMode=?,
~version: version=?,
~salt: Node.Buffer.t=?,
~saltLength: int=?,
~associatedData: Node.Buffer.t=?,
hashInput
) =>
Js.Promise.t(Node.Buffer.t);
958: <UNKNOWN SYNTAX ERROR>
Return whether the hash needs to be recomputed due to changed options/version.
let needsRehash:
(~timeCost: int=?, ~memoryCost: int=?, ~version: version=?, hash) =>
bool;
958: <UNKNOWN SYNTAX ERROR>
Verify a given string
or Node.Buffer.t
against a previously generated hash.
type hashInput =
| String(string)
| Buffer(Node.Buffer.t);
let verify: (hash, hashInput) => Js.Promise.t(bool);
958: <UNKNOWN SYNTAX ERROR>
Use the following two functions when (de)serializing generated hashes:
let hashToJson: hash => Js.Json.t;
let jsonToHash: Js.Json.t => hash;
958: <UNKNOWN SYNTAX ERROR>
Note: in its current implementation, jsonToHash
will raise an exception if the decoding fails.