godprotocol
Version:
A distributed computing environment
19 lines (12 loc) • 303 B
JavaScript
const crypto = require("crypto");
const hash = (data, alg) => {
let hash = crypto.createHash(alg || "sha256");
hash.update(data);
let result = hash.digest("hex");
if (alg){
if (!isNaN(Number(result[0])))
result = `_${result.slice(0, -1)}`;
}
return result;
};
export { hash };