2021-10-02 00:16:34 +00:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
import crypto from 'crypto';
|
|
|
|
|
2022-01-08 16:59:08 +00:00
|
|
|
function hash(algorithm, encoding, data) {
|
2021-10-02 00:16:34 +00:00
|
|
|
let hasher = crypto.createHash(algorithm);
|
|
|
|
hasher.update(data);
|
|
|
|
return hasher.digest(encoding);
|
|
|
|
}
|
2022-01-08 16:59:08 +00:00
|
|
|
|
|
|
|
function sha3hex(data) {
|
|
|
|
return hash("SHA3-256", "hex", data);
|
|
|
|
}
|
|
|
|
|
|
|
|
export { hash, sha3hex };
|
|
|
|
export default hash;
|