/* * Copyright (C) Sapphirecode - All Rights Reserved * This file is part of password-helper which is released under MIT. * See file 'LICENSE' for full license details. * Created by Timo Hocker , May 2020 */ /* eslint-disable no-magic-numbers */ 'use strict'; const argon2 = require ('argon2'); const argon_options = { hashLength: 64, saltLength: 32, type: argon2.argon2id }; /** * verify a plain text against an argon2 hash * * @param {string} hash_str hash * @param {string} plain plain text * @returns {Promise} true if valid */ function verify (hash_str, plain) { return argon2.verify (hash_str, plain, argon_options); } /** * create an argon2 hash * * @param {string} plain plain text * @returns {Promise} hash */ function hash (plain) { return argon2.hash (plain, argon_options); } module.exports = { hash, verify };