crypto-helper/lib/pbkdf.js
Timo Hocker 5bbf9d658c
All checks were successful
continuous-integration/drone/push Build is passing
reduce extreme time consumption of pbkdf
2023-04-04 22:09:25 +02:00

21 lines
510 B
JavaScript

'use strict';
const { scrypt } = require ('scrypt-js');
/**
* creates a scrypt hash
*
* @param {string} str string input
* @param {string} salt salt
* @returns {Promise<string>} hash
*/
async function pbkdf_scrypt (str, salt) {
const bstr = Buffer.from (str.normalize ('NFKC'), 'utf-8');
const bsalt = Buffer.from (salt.normalize ('NFKC'), 'utf-8');
const hash = await scrypt (bstr, bsalt, 8192, 8, 1, 64);
return Buffer.from (hash)
.toString ('hex');
}
module.exports = { pbkdf_scrypt };