Skip to main content
Hash a UTF-8 string using Keccak256 and get the result as hex
import { Keccak256 } from '@tevm/voltaire/Keccak256';
import { Hex } from '@tevm/voltaire/Hex';

// Hash a simple string
const message = "Hello, World!";
const hash = Keccak256(message);
const hexHash = Hex.fromBytes(hash);

// Hash an empty string
const emptyHash = Keccak256("");
const emptyHexHash = Hex.fromBytes(emptyHash);
This is a fully executable example. View the complete source with test assertions at examples/hashing/keccak256-string.ts.