Function dryoc::classic::crypto_pwhash::crypto_pwhash
source · pub fn crypto_pwhash(
output: &mut [u8],
password: &[u8],
salt: &[u8],
opslimit: u64,
memlimit: usize,
algorithm: PasswordHashAlgorithm
) -> Result<(), Error>
Expand description
Hashes password
with salt
, placing the resulting hash into output
.
opslimit
specifies the number of iterations to use in the underlying algorithmmemlimit
specifies the maximum amount of memory to use, in bytes
Generally speaking, you want to set opslimit
and memlimit
sufficiently
large such that it’s hard for someone to brute-force a password.
For your convenience, the following constants are defined which can be used
with opslimit
and memlimit
:
CRYPTO_PWHASH_OPSLIMIT_INTERACTIVE
andCRYPTO_PWHASH_MEMLIMIT_INTERACTIVE
for interactive operationsCRYPTO_PWHASH_OPSLIMIT_MODERATE
andCRYPTO_PWHASH_MEMLIMIT_MODERATE
for typical operations, such as server-side password hashingCRYPTO_PWHASH_OPSLIMIT_SENSITIVE
andCRYPTO_PWHASH_MEMLIMIT_SENSITIVE
for sensitive operations
Compatible with libsodium’s crypto_pwhash
.