Solidity has a function named sha3
and I tested it with an empty string input. It is not matching what other sha3 libraries produce. I see contracts written by others using the same sha3
function in Solidity, and their hashes also do not match. The same goes for Javascript web3.sha3
hashes. Why?
Solidity SHA3 – Why Aren’t Solidity SHA3 Hashes Matching Other SHA3 Libraries?
cryptographykeccaksha3solidityweb3js
Best Answer
Ethereum uses Keccak-256, instead of the SHA-3 FIPS 202 standard. In the sha3 libraries you are using, try looking for the option to specify using Keccak-256.
For Python see Getting Method ID "Keccak hash" in Python
For Javascript, this library js-sha3 would involve using the
keccak_256
function instead ofsha3_256
.Others: