Keccak256 is a cryptographic hash function that takes input of arbitrary length and produces a fixed-length 256-bit output. It is a member of the SHA-3 family.
keccak256 computes the Keccak-256 hash of the input.
Common uses:
In Stylus, use stylus_sdk::crypto::keccak to compute the hash:
1pub fn keccak<T: AsRef<[u8]>>(bytes: T) -> B2561pub fn keccak<T: AsRef<[u8]>>(bytes: T) -> B256The example below demonstrates hashing ABI-encoded tuples using alloy_sol_types:
abi_encode_sequence, then keccak(...)abi_encode_packed, then keccak(...)Note: Standard
decoderoutines expect padded ABI encoding. Don’t attempt todecodebytes produced by packed encoding.
1Loading...1Loading...1Loading...1Loading...1Loading...1Loading...