ethers.js/src.ts/utils/pbkdf2.ts

16 lines
464 B
TypeScript
Raw Normal View History

'use strict';
2018-06-19 09:12:57 +03:00
import { pbkdf2Sync as _pbkdf2 } from 'crypto';
import { arrayify } from './bytes';
import { Arrayish } from './types';
2018-06-19 09:12:57 +03:00
function bufferify(value: Arrayish): Buffer {
return new Buffer(arrayify(value));
2018-06-13 22:39:39 +03:00
}
2018-06-19 09:12:57 +03:00
export function pbkdf2(password: Arrayish, salt: Arrayish, iterations: number, keylen: number, hashAlgorithm: string): Uint8Array {
return arrayify(_pbkdf2(bufferify(password), bufferify(salt), iterations, keylen, hashAlgorithm));
}