# Hex.random

Generates a random [`Hex.Hex`](/api/Hex/types#hex) value of the specified length.

## Imports

:::code-group
```ts [Named]
import { Hex } from 'ox'
```

```ts [Entrypoint]
import * as Hex from 'ox/Hex'
```
:::

## Examples

```ts twoslash
import { Hex } from 'ox'

const hex = Hex.random(32)
// @log: '0x...'
```

## Definition

```ts
function random(
  length: number,
): Hex
```

**Source:** [src/core/Hex.ts](https://github.com/wevm/ox/blob/main/src/core/Hex.ts#L1003)

## Parameters

### length

* **Type:** `number`

## Return Type

Random [`Hex.Hex`](/api/Hex/types#hex) value.

`Hex`
