'use strict'; const { scrypt } = require ('scrypt-js'); /** * creates a scrypt hash * * @param {string} str string input * @param {string} salt salt# * @param {(progress: number) => void} [progress] progress callback * @returns {Promise} hash */ 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, progress); return Buffer.from (hash) .toString ('hex'); } module.exports = { pbkdf_scrypt };