'use strict'; const scrypt = require('scrypt'); module.exports = { /** * Hash a password with scrypt * * @param {string} str - the password to hash * @return {Promise} - a promise returning the hash */ hash(str) { return scrypt.kdf(str, { N:16, // Number of rounds r:8, // Block-size of hash p:1, // Parallization }); }, /** * Verify a password hash matches * * @param {string} hash - the hash to check against * @param {string} str - the password to check against the computed hash * @return {Promise} - a promise returning a boolean */ verify(hash, str) { return scrypt.verifyKdf(hash, str); }, };