2017-11-08 22:38:11 -05:00
|
|
|
'use strict';
|
|
|
|
|
2018-06-19 02:12:57 -04:00
|
|
|
import { pbkdf2Sync as _pbkdf2 } from 'crypto';
|
|
|
|
|
2018-07-16 03:27:49 -04:00
|
|
|
import { arrayify } from './bytes';
|
|
|
|
|
2018-07-30 18:59:52 -04:00
|
|
|
// Imported Types
|
|
|
|
import { Arrayish } from './bytes';
|
2017-02-27 00:07:46 -05:00
|
|
|
|
2018-06-19 02:12:57 -04:00
|
|
|
function bufferify(value: Arrayish): Buffer {
|
2018-09-04 10:20:31 -04:00
|
|
|
return Buffer.from(arrayify(value));
|
2018-06-13 15:39:39 -04:00
|
|
|
}
|
|
|
|
|
2018-06-19 02:12:57 -04: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));
|
2017-02-27 00:07:46 -05:00
|
|
|
}
|