> **Can't find what you're looking for?** Use `search_docs` on the docs MCP server at `https://v3.viem.sh/api/mcp` to find what you need.

# Hash.keccak256

:::info
`Hash.keccak256` is a re-export of ox's [`Hash.keccak256`](https://oxlib.sh/api/Hash/keccak256). Refer to the ox documentation for the full reference.
:::

Calculates the [Keccak256](https://en.wikipedia.org/wiki/SHA-3) hash of a [`Bytes.Bytes`](/docs/utilities/bytes/types#bytes) or [`Hex.Hex`](/docs/utilities/hex/types#hex) value.

Backed by `keccak_256` from [`@noble/hashes`](https://github.com/paulmillr/noble-hashes), an audited & minimal JS hashing library, unless another implementation is installed with [`Engine.set`](https://oxlib.sh/api/Engine/set).

## Imports

```ts
import { Hash } from 'viem/utils'
```

## Examples

```ts twoslash
// @noErrors
import { Hash } from 'viem/utils'

Hash.keccak256('0xdeadbeef')
// @log: '0xd4fd4e189132273036449fc9e11198c739161b4c0116a9a2dccdfa1c492006f1'
```

### Calculate Hash of a String

```ts twoslash
// @noErrors
import { Hash, Hex } from 'viem/utils'

Hash.keccak256(Hex.fromString('hello world'))
// @log: '0x3ea2f1d0abf3fc66cf29eebb70cbd4e7fe762ef8a09bcc06c8edf641230afec0'
```

### Configure Return Type

```ts twoslash
// @noErrors
import { Hash } from 'viem/utils'

Hash.keccak256('0xdeadbeef', { as: 'Bytes' })
// @log: Uint8Array [...]
```

## Definition

```ts
function keccak256<value, as>(
  value: value | Hex.Hex | Bytes.Bytes,
  options?: keccak256.Options<as>,
): keccak256.ReturnType<as>
```

## Parameters

### value

* **Type:** `value | Hex.Hex | Bytes.Bytes`

[`Bytes.Bytes`](/docs/utilities/bytes/types#bytes) or [`Hex.Hex`](/docs/utilities/hex/types#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>`
