add progress callback
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Timo Hocker 2023-04-07 16:55:52 +02:00
parent 5bbf9d658c
commit fe1ab3bf64
Signed by: Timo
GPG Key ID: DFAC2CF4E1D1BEC9
2 changed files with 5 additions and 4 deletions

View File

@ -6,13 +6,14 @@ const { scrypt } = require ('scrypt-js');
* creates a scrypt hash
*
* @param {string} str string input
* @param {string} salt salt
* @param {string} salt salt#
* @param {(progress: number) => void} [progress] progress callback
* @returns {Promise<string>} hash
*/
async function pbkdf_scrypt (str, salt) {
async function pbkdf_scrypt (str, salt, progress) {
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);
const hash = await scrypt (bstr, bsalt, 8192, 8, 1, 64, progress);
return Buffer.from (hash)
.toString ('hex');
}

View File

@ -1,6 +1,6 @@
{
"name": "@sapphirecode/crypto-helper",
"version": "2.1.1",
"version": "2.1.2",
"main": "index.js",
"author": {
"name": "Timo Hocker",