From 5bbf9d658ce8038e33288fdcd20bec8d63641f04 Mon Sep 17 00:00:00 2001 From: Timo Hocker <35867059+TimoHocker@users.noreply.github.com> Date: Tue, 4 Apr 2023 22:09:25 +0200 Subject: [PATCH] reduce extreme time consumption of pbkdf --- lib/pbkdf.js | 2 +- package.json | 2 +- test/spec/pbkdf.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/pbkdf.js b/lib/pbkdf.js index b2b42fc..683af7c 100644 --- a/lib/pbkdf.js +++ b/lib/pbkdf.js @@ -12,7 +12,7 @@ const { scrypt } = require ('scrypt-js'); 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, 65536, 8, 1, 64); + const hash = await scrypt (bstr, bsalt, 8192, 8, 1, 64); return Buffer.from (hash) .toString ('hex'); } diff --git a/package.json b/package.json index 1364bf9..3ed3ed6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@sapphirecode/crypto-helper", - "version": "2.1.0", + "version": "2.1.1", "main": "index.js", "author": { "name": "Timo Hocker", diff --git a/test/spec/pbkdf.js b/test/spec/pbkdf.js index 860cef3..176d9d3 100644 --- a/test/spec/pbkdf.js +++ b/test/spec/pbkdf.js @@ -10,7 +10,7 @@ describe ('hashing', () => { ) .toEqual ( // eslint-disable-next-line max-len - '1c357645d521cce3d015441a4215814d8acbf98ed671880ba369039784de05043f0fd9867a0f265b6e5303da202ec4d541bd11752079d8f490ed1fc52e547497' + 'f70baff6e80e83a2fc5af752f4b57b6b73442f913fc6446b6cb62e3f5f56f9b18c51c3461081239fdac6e9f8498a95ecfabb0b927db8a9ee2de80ed40469b034' ); }); });