This commit is contained in:
20
lib/pbkdf.js
Normal file
20
lib/pbkdf.js
Normal file
@ -0,0 +1,20 @@
|
||||
'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, 65536, 8, 1, 64);
|
||||
return Buffer.from (hash)
|
||||
.toString ('hex');
|
||||
}
|
||||
|
||||
module.exports = { pbkdf_scrypt };
|
Reference in New Issue
Block a user