47: Keccak256
Keccak256
bytes32 hash = keccak256(abi.encode(data1, data2));contract MyContract {
// Generate the Keccak256 hash of a string
function keccak256Hash(string memory _string) public pure returns (bytes32) {
return keccak256(abi.encode(_string));
}
}
// input: "Hello World"
// output: 0x3c9229289a6125f7fdf1885a77bb12c37a8d3b4962d936f7e3084dece32a3ca1Further Reading
Keccak256 - Web3js
Last updated