Store a password hash in output
using Argon2i.
Parameters
out: Buffer, Output buffer to store the hash in. Should be able to store sodium.crypto_pwhash_argon2i_STRBYTES
.
passwd: Buffer, Password to hash.
salt: Buffer, Salt for hash. Must be exactly sodium.crypto_pwhash_argon2i_SALTBYTES
.
oppLimit: Number, Maximum number of computations to perform. Higher values will require more CPU cycles.
memLimit: Number, Maximum amount of RAM to consume, in bytes.
alg: Number, Algorithm to use. Currently only sodium.crypto_pwhash_argon2i_ALG_ARGON2I13
is supported.
Returns
boolean, true
if successful, false
if not.
Returns a buffer of size sodium.crypto_pwhash_argon2i_STRBYTES
containing an ASCII-encoded string suitable for storage. It includes:
oppLimit
and memLimit
that were usedParameters
passwd: Buffer, Password to hash.
oppLimit: Number, Maximum number of computations to perform.
memlimit: Number, Maximum amount of RAM to consume, in bytes.
Returns
Buffer|Boolean, Hash buffer or false
if hash unsuccessful.
Hashes passwd
using the same parameters and salt as pwhash
and compares the result.
Parameters
pwhash: Buffer, Hash generated with crypto_pwhash_argon2i_str
.
pass: Buffer, Password to verify.
Returns
Boolean, true
if passwd
is verified, false
if not.
Store a password hash in out
using the specified algorithm.
Parameters
out: Buffer, Output buffer to store the hash in. Should be able to store sodium.crypto_pwhash_STRBYTES
.
passwd: Buffer, Password to hash.
salt: Buffer, Salt for hash. Must be exactly sodium.crypto_pwhash_SALTBYTES
.
oppLimit: Number, Maximum number of computations to perform.
memLimit: Number, Maximum amount of RAM to consume, in bytes.
alg: Number, Algorithm to use. Currently sodium.crypto_pwhash_argon2i_ALG_ARGON2I13
and sodium.crypto_pwhash_ALG_DEFAULT
are supported.
Returns
Boolean|null, true
if hash successful, null
if not.
Returns a buffer of size sodium.crypto_pwhash_STRBYTES
containing an ASCII-encoded string suitable for storage. It includes:
oppLimit
and memLimit
that were usedParameters
passwd: Buffer, Password to hash.
oppLimit: Number, Maximum number of computations to perform.
memlimit: Number, Maximum amount of RAM to consume, in bytes.
Returns
Buffer|Boolean, Hash buffer or false
if unsuccessful.
Hashes passwd
using the same parameters and salt as pwhash
and compares the result.
Parameters
pwhash: Buffer, Hash generated with crypto_pwhash_str
.
pass: Buffer, Password to verify.
Returns
Boolean, true
if passwd
verified, false
if not.
Stores a hash of passwd
in out
using Scrypt with Salsa20/8 core and SHA-256.
Parameters
out: Number, Output buffer.
passwd: Buffer, Password to hash.
salt: Buffer, Salt for hash. Must be crypto_pwhash_scryptsalsa208sha256_SALTBYTES
in length.
oppLimit: Number, Maximum number of computations to perform.
memLimit: Number, Maximum amount of RAM to consume, in bytes.
Returns
Boolean, true
if successful, false
if not.
Stores a hash of passwd
in out
using the low-level Scrypt API.
Parameters
passwd: Buffer, Password to hash.
salt: Buffer, Salt for hash. Must be crypto_pwhash_scryptsalsa208sha256_SALTBYTES
in length.
N: Number, CPU/memory cost. Higher values increase both CPU and memory cost. Must be a power of 2 greater than 1.
r: Number, Block size for hash, in bytes. Higher values increase relative memory cost.
p: Number, Parallelization factor. Higher values increase relative CPU cost.
out: Buffer, Output buffer to store the hash in. Should be able to store crypto_pwhash_scryptsalsa208sha256_STRBYTES
.
Returns
Boolean, true
if successful, false
if not.
Returns a hash of passwd
using Scrypt.
Parameters
passwd: Buffer, Password to hash.
oppLimit: Number, Maximum number of computations to perform.
memLimit: Number, Maximum amount of RAM to consume, in bytes.
Returns
Buffer|null, Hash buffer or null if unsuccessful.
Hashes passwd
using Scrypt with the parameters stored in pwhash
, and compares the result with pwhash
.
Parameters
passwd: Buffer, Password to hash.
oppLimit: Number, Maximum number of computations to perform.
memLimit: Number, Maximum amount of RAM to consume, in bytes.
Returns
Boolean, true
if passwd
verified, false
if not.
Default hashing algorithm to use. Currently crypto_pwhash_argon2i_ALG_ARGON2I13
.
Size of salt buffer in bytes. Algorithm-specific values: crypto_pwhash_scryptsalsa208sha256_SALTBYTES
, crypto_pwhash_argon2i_SALTBYTES
.
Size of returned hash buffer, in bytes. Algorithm-specific values: crypto_pwhash_argon2i_STRBYTES
,
crypto_pwhash_scryptsalsa208sha256_STRBYTES
.
Algorithm-specific values: crypto_pwhash_argon2i_STRPREFIX
, crypto_pwhash_scryptsalsa208sha256_STRPREFIX
.
ons
A suitable default for fast hashes used with interactive logins. Algorithm-specific values: crypto_pwhash_argon2i_OPSLIMIT_INTERACTIVE
, crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_INTERACTIVE
.
A suitable default for fast hashes used with interactive logins (32 MB RAM consumed). Algorithm-specific values: crypto_pwhash_argon2i_MEMLIMIT_INTERACTIVE
, crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_INTERACTIVE
.
A suitable default for normal use (moderate speed). Algorithm-specific values: crypto_pwhash_argon2i_OPSLIMIT_MODERATE
.
A suitable default for normal use (moderate speed). Algorithm-specific values: crypto_pwhash_argon2i_MEMLIMIT_MODERATE
.
A suitable default for slow hashes with highly-sensitive data. Algorithm-specific values: crypto_pwhash_argon2i_OPSLIMIT_SENSITIVE
, crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_SENSITIVE
.
A suitable default for slow hashes with highly-sensitive data. Algorithm-specific values: crypto_pwhash_argon2i_MEMLIMIT_SENSITIVE
, crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_SENSITIVE
.
Currently set to "argon2i".