ETHnodeJS/utils/index.js

21 lines
No EOL
541 B
JavaScript

/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/ClientSide/javascript.js to edit this template
*/
const keccak256 = require("js-sha3").keccak256;
const sortCharacters = data => {
return JSON.stringify(data).split("").sort().join("");
};
const keccakHash = data => {
const hash = keccak256.create();
hash.update(sortCharacters(data));
return hash.hex();
};
module.exports = {
sortCharacters,
keccakHash
};