One hash, two uses
Keccak-256 always produces the same 32-byte output for a given input — what changes is how you read it. Hash arbitrary data and the full 32 bytes is what you want. Hash a function signature specifically, and the first 4 bytes of that same hash are its selector — the value a contract actually inspects to decide which function you’re calling. There’s no separate algorithm for selectors; it’s the same hash, truncated.
Where this matters in practice
Selectors show up any time you’re reading raw calldata, writing a signature-based access-control check, or verifying that a signature collision (two different function signatures hashing to the same 4-byte selector) isn’t being exploited against a contract. Full hashes show up in Merkle proofs, commit-reveal schemes, and anywhere a contract needs a compact, collision-resistant fingerprint of some data.
How this tool works
Text input is UTF-8 encoded then hashed; hex input is hashed as raw bytes directly — both via viem’s Keccak-256 implementation, entirely in your browser.