systemquery/src/lib/crypto/hash.mjs

17 lines
304 B
JavaScript
Raw Normal View History

"use strict";
import crypto from 'crypto';
function hash(algorithm, encoding, data) {
let hasher = crypto.createHash(algorithm);
hasher.update(data);
return hasher.digest(encoding);
}
function sha3hex(data) {
return hash("SHA3-256", "hex", data);
}
export { hash, sha3hex };
export default hash;