Skip to main content

Keccak256 Hashing (Python)

Compute Keccak-256 hashes in Python, matching Solidity’s keccak256 function. Compute Keccak-256 hashes in Python, matching Solidity’s keccak256 function.

Explanation

Keccak-256 is the hash function used by Ethereum. The first 4 bytes of keccak(signature) is the function selector used in ABI encoding. eth_hash provides a pure-Python implementation; pysha3 is an alternative.

Code


Canonical knowledge ID: code-example:keccak256-hashing-python