2017-11-09 06:38:11 +03:00
|
|
|
'use strict';
|
|
|
|
|
2018-06-19 09:12:57 +03:00
|
|
|
import { pbkdf2Sync as _pbkdf2 } from 'crypto';
|
|
|
|
|
2018-06-17 23:47:28 +03:00
|
|
|
import { arrayify, Arrayish } from './bytes';
|
2017-02-27 08:07:46 +03:00
|
|
|
|
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));
|
2017-02-27 08:07:46 +03:00
|
|
|
}
|