17 lines
304 B
JavaScript
17 lines
304 B
JavaScript
"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;
|