function pbkdf2(
   _password, 
   _salt, 
   iterations, 
   keylen, 
   algo): string

Return the PBKDF2 for keylen bytes for password using the salt and using iterations of algo.

This PBKDF is outdated and should not be used in new projects, but is required to decrypt older files.

Parameters

ParameterTypeDescription
_passwordBytesLikeThe password to use.
_saltBytesLikeThe salt to use.
iterationsnumberThe number of iterations to use.
keylennumberThe length of the key to generate.
algo"sha256" | "sha512"The algorithm to use.

Returns

string

The key derived from the password.

Example

// The password must be converted to bytes, and it is generally
// best practices to ensure the string has been normalized. Many
// formats explicitly indicate the normalization form to use.
password = 'hello';
passwordBytes = toUtf8Bytes(password, 'NFKC');

salt = id('some-salt');

// Compute the PBKDF2
pbkdf2(passwordBytes, salt, 1024, 16, 'sha256');

Source

crypto/pbkdf2.ts:55