Hash.keccak256
Calculates the Keccak256 hash of a Bytes.Bytes or Hex.Hex value.
This function is a re-export of keccak_256 from @noble/hashes, an audited & minimal JS hashing library.
Imports
Named
import { Hash } from 'ox'Examples
import { Hash } from 'ox'
Hash.keccak256('0xdeadbeef')
'0xd4fd4e189132273036449fc9e11198c739161b4c0116a9a2dccdfa1c492006f1'Calculate Hash of a String
import { Hash, Hex } from 'ox'
Hash.keccak256(Hex.fromString('hello world'))
'0x47173285a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01fad'Configure Return Type
import { Hash } from 'ox'
Hash.keccak256('0xdeadbeef', { as: 'Bytes' })
Uint8Array [...]Definition
function keccak256<value, as>(
value: value | Hex.Hex | Bytes.Bytes,
options?: keccak256.Options<as>,
): keccak256.ReturnType<as>Source: src/core/Hash.ts
Parameters
value
- Type:
value | Hex.Hex | Bytes.Bytes
Bytes.Bytes or Hex.Hex value.
options
- Type:
keccak256.Options<as> - Optional
Options.
options.as
- Type:
"Bytes" | "Hex" | as - Optional
The return type.
Return Type
Keccak256 hash.
keccak256.ReturnType<as>

