datasquirel/functions/hashPassword.js

14 lines
340 B
JavaScript
Raw Normal View History

2023-08-12 15:46:00 +00:00
const { createHmac } = require("crypto");
/**
* # Hash password Function
* @param {string} password
* @returns {string}
*/
module.exports = function hashPassword(password) {
const hmac = createHmac("sha512", process.env.ENCRYPTION_PASSWORD);
hmac.update(password);
let hashed = hmac.digest("base64");
return hashed;
};