Skip to content

↑↓ navigate ↵ open Esc close Search runs locally

Keccak-256 Hash Generator (Ethereum & Solidity)

Generate Keccak-256 hashes exactly as Ethereum and Solidity do. Hash a function signature to get its 4-byte selector, or an event signature to get its topic.

  • Runs in your browser
  • Nothing is uploaded
  • Free, no sign-up
Algorithms
0 BUTF-8
Hashes

    Runs in your browser. Files are never uploaded. Tip: drop a file to verify a download

    How to use the Keccak-256 tool#

    1. Type a string, such as a Solidity function signature like transfer(address,uint256).
    2. The Keccak-256 hash appears on the right. The first 8 hex characters (4 bytes) are the function selector.
    3. To compare with on-chain data, paste the expected value (with or without 0x) into Compare with a checksum.
    4. Hashing raw bytes rather than text? Use the Hex tool to check your input first: this tool hashes the text as UTF-8.

    Examples#

    ERC-20 transfer function

    Input
    transfer(address,uint256)
    Output
    a9059cbb2ab09eb219583f4a59a5d0623ade346d962bcd4e46b11da047c9049b

    The first 4 bytes, a9059cbb, are the function selector you see at the start of every ERC-20 transfer transaction.

    Keccak-256 of a word

    Input
    hello
    Output
    1c8aff950685c2ed4bc3174f3472287b56d9517b9c948127319a09a7a36deac8

    Different from SHA3-256 of the same word, which is 3338be69…

    Keccak-256 of an empty string

    Input
    Output
    c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470

    This is Ethereum's "empty code hash", the codehash of accounts without contract code.

    What is Keccak-256?#

    Keccak-256 is the original version of the algorithm that became SHA-3, and the hash function used throughout Ethereum. When NIST standardised SHA-3 in 2015, it changed the padding rule. Ethereum had already chosen Keccak in 2014, so it kept the original. That is why Solidity's keccak256() and the standard SHA3-256 give different results for the same input.

    Where Ethereum uses Keccak-256#

    UseWhat is hashedWhat is kept
    Function selectorThe signature, e.g. transfer(address,uint256)First 4 bytes (0xa9059cbb)
    Event topicThe event signature, e.g. Transfer(address,address,uint256)All 32 bytes (topic 0)
    AddressThe 64-byte public keyLast 20 bytes
    Storage slotsMapping key and slot number (ABI-encoded)All 32 bytes
    Checksum addresses (EIP-55)The lowercase hex addressDecides which letters are uppercase

    Function signatures: the exact format#

    For a selector, the signature must be in canonical form: the function name, then parameter types only, no names and no spaces, with aliases expanded. transfer(address to, uint amount) must be written as transfer(address,uint256). A single extra space gives a completely different hash.

    Keccak-256 in code#

    Solidity#

    javascript
    bytes32 h = keccak256(abi.encodePacked("hello"));bytes4 selector = bytes4(keccak256("transfer(address,uint256)"));

    ethers.js#

    javascript
    import { keccak256, toUtf8Bytes, id } from 'ethers'; keccak256(toUtf8Bytes('hello'));id('transfer(address,uint256)').slice(0, 10); // "0xa9059cbb"

    Python#

    python
    from eth_utils import keccak keccak(text='hello').hex()# Note: hashlib.sha3_256 is NOT Keccak-256

    Common errors and fixes#

    • My hash does not match Solidity's keccak256

      Check you did not use SHA3-256: Python's hashlib.sha3_256 and PHP's hash("sha3-256") are the standard SHA-3, not Keccak. Also check the exact input: Solidity often hashes ABI-encoded bytes, not text.

    • The function selector is wrong

      The signature must have no spaces and no parameter names, and use full type names (uint256, not uint).

    • I need to hash hex bytes, not text

      This tool hashes text as UTF-8, so 0x1234 is hashed as six characters. Use a library such as ethers.js for raw bytes.

    Frequently asked questions#

    Is Keccak-256 the same as SHA3-256?

    No. They share the same core, but SHA3-256 uses different padding, so the hashes differ. Ethereum uses Keccak-256.

    How do I get a function selector?

    Hash the canonical signature, such as transfer(address,uint256), and take the first 8 hex characters: a9059cbb.

    How long is a Keccak-256 hash?

    256 bits: 64 hexadecimal characters, usually shown with a 0x prefix in Ethereum tools.

    Is my input uploaded?

    No. The hash is calculated in your browser.

    Your next tool is one search away.

    Free, private developer tools that run in your browser. No signup, nothing uploaded, no waiting.

    Browse all tools

    Tip: press Ctrl D to bookmark dev247.