Skip to content

Instantly share code, notes, and snippets.

@clesaege
Created August 18, 2020 00:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clesaege/00cc08cc4ccd873fa60a19ffb30e2e9d to your computer and use it in GitHub Desktop.
Save clesaege/00cc08cc4ccd873fa60a19ffb30e2e9d to your computer and use it in GitHub Desktop.
pragma solidity ^0.7.0;
contract Storing {
uint a;
uint b;
uint c;
uint d;
function store(uint _a, uint _b, uint _c, uint _d) public {
a=_a;
b=_b;
c=_c;
d=_d;
}
function compute() public view returns(uint e) {
return a+b+c+d;
}
}
contract Hashing{
bytes32 hash;
function store(uint _a, uint _b, uint _c, uint _d) public {
hash=keccak256(abi.encodePacked(_a,_b,_c,_d));
}
function compute(uint _a, uint _b, uint _c, uint _d) public view returns(uint e) {
require(keccak256(abi.encodePacked(_a,_b,_c,_d))==hash);
return _a+_b+_c+_d;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment