Algorithms
Keccak-256
Keccak with its original padding. Ethereum addresses and function selectors and storage slots plus Tron and Monero
Hash / Cryptographic
Keccak-256
SHA-3 before NIST changed one padding byte.
- Digest
- 256-bit · 32 bytes
- HMAC
- takes a key
- Security
- 128-bit collision resistance
- Used by
- Ethereum, Tron, Monero
2 options, 0 required
Sample
- hex
- 47173285a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01fad
- base64
- RxcyhajXNB5ely/GdyhjhPgC+O9CpexfA7v6JUywH60=
Options
Access
- Create
create("keccak256") - CLI
hashes keccak256 'hello world' - Tryplayground with the sample above
- Kinsha256, sha384, sha512, sha512-half +11
What Ethereum calls keccak256 and too many libraries call sha3. The permutation is SHA-3's. The padding byte is the one from before NIST changed it, 0x01 instead of 0x06, and that byte is enough to make every digest different.
create("keccak256").hash("transfer(address,uint256)").digest;
// "a9059cbb2ab09eb219583f4a59a5d0623ade346d962bcd4e46b11da047c9049b"
create("keccak256").hash("").digest;
// "c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"
The first four bytes of the first one, a9059cbb, are the ERC-20 transfer selector you've seen in a thousand transactions. An EVM address is the last 20 bytes of Keccak-256 over the 64-byte public key without its 04 prefix. Pass that key as bytes, not as hex text. The empty digest is the codeHash of every account without code.
HMAC works too, for whatever needs a keyed Keccak.