Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | 3x 7x 7x 7x 7x 7x 7x | import { Pbkdf2, Pbkdf2Digests } from './types';
type NodePbkdf2Fn = typeof import('crypto').pbkdf2;
export class NodeCryptoPbkdf2 implements Pbkdf2 {
nodePbkdf2: NodePbkdf2Fn;
constructor(nodePbkdf2: NodePbkdf2Fn) {
this.nodePbkdf2 = nodePbkdf2;
}
async derive(
password: string,
salt: Uint8Array,
iterations: number,
keyLength: number,
digest: Pbkdf2Digests
): Promise<Uint8Array> {
Iif (digest !== 'sha512' && digest !== 'sha256')
throw new Error(`Unsupported digest "${digest}" for Pbkdf2`);
return new Promise((resolve, reject) => {
this.nodePbkdf2(password, salt, iterations, keyLength, digest, (error, result) => {
Iif (error) reject(error);
resolve(result);
});
});
}
}
|