v_to_sha256
Version:
Generates sha256 hash value from a provided string or returns false in case of an error.
18 lines (13 loc) • 498 B
JavaScript
var crypto = require("crypto");
const { notEmpty, notEmptySync } = require("v_is_empty_value");
function createSHA256(value) {
return crypto.createHash("sha256").update(String(value)).digest("hex");
}
const v_to_sha256 = async (value = null) => {
return (await notEmpty(value)) ? createSHA256(value) : false;
};
v_to_sha256.sync = function (value = null) {
return (notEmptySync(value)) ? createSHA256(value) : false;
};
module.exports = v_to_sha256;
module.exports.default = v_to_sha256;