- To calculate the SHA-3 (keccak-256) hash of something, use the keccak256/sha3 function:
keccak256(...)// ORsha3(...) // alias to keccak256
- The function returns the hash in bytes32 format:
keccak256(...) returns (bytes32);
- Since the arguments to this functions are concatenated without padding, use any of the following input formats to yield the same value:
keccak256("hello", "world")keccak256("helloworld")keccak256(0x68656c6c6f776f726c64)keccak256(68656c6c6f776f726c64)
- Use solidity's sha3 function to calculate the SHA-256 hash of the input. It works just like the keccak256 function:
sha256(...) returns (bytes32);
- Use the ecrecover function to verify the address associated with a public key. The function accepts a signed ...