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);
examples/hashing/keccak256-string.ts.Was this page helpful?
Suggestions