2
0
mirror of synced 2025-02-24 20:18:07 +00:00

15 lines
460 B
TypeScript
Raw Normal View History

2019-05-14 18:25:46 -04:00
"use strict";
import { pbkdf2Sync as _pbkdf2 } from "crypto";
import { arrayify, BytesLike, hexlify } from "@ethersproject/bytes";
function bufferify(value: BytesLike): Buffer {
return Buffer.from(arrayify(value));
}
export function pbkdf2(password: BytesLike, salt: BytesLike, iterations: number, keylen: number, hashAlgorithm: string): string {
return hexlify(_pbkdf2(bufferify(password), bufferify(salt), iterations, keylen, hashAlgorithm));
}