Function crypto_wasi::pbkdf2
source · pub fn pbkdf2(
password: impl AsRef<[u8]>,
salt: impl AsRef<[u8]>,
iterations: usize,
key_len: usize,
digest: &str
) -> Result<Vec<u8>, CryptoErrno>
Expand description
Password-Based Key Derivation Function 2 (PBKDF2) implementation.
A selected HMAC digest algorithm specified by digest
is applied to derive a key of the requested byte length (key_len
) from the password
, salt
and iterations
.
The iterations
argument must be a number set as high as possible.
The higher the number of iterations,
the more secure the derived key will be,
but will take a longer amount of time to complete.
The salt
should be as unique as possible.
It is recommended that a salt is random and at least 16 bytes long.
See NIST SP 800-132 for details.
When passing strings for password
or salt
,
please consider caveats when using strings as inputs to cryptographic APIs.
Supported algorithm:
- SHA256
- SHA512