From fe1ab3bf6479d56ef23e95ae65b1718880e393fa Mon Sep 17 00:00:00 2001 From: Timo Hocker <35867059+TimoHocker@users.noreply.github.com> Date: Fri, 7 Apr 2023 16:55:52 +0200 Subject: [PATCH] add progress callback --- lib/pbkdf.js | 7 ++++--- package.json | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/pbkdf.js b/lib/pbkdf.js index 683af7c..cc5ce37 100644 --- a/lib/pbkdf.js +++ b/lib/pbkdf.js @@ -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} 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'); } diff --git a/package.json b/package.json index 3ed3ed6..e0769a8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@sapphirecode/crypto-helper", - "version": "2.1.1", + "version": "2.1.2", "main": "index.js", "author": { "name": "Timo Hocker",