# Bytes.random

Generates random [`Bytes.Bytes`](/api/Bytes/types#bytes) of the specified length.

## Imports

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

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

## Examples

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

const bytes = Bytes.random(32)
// @log: Uint8Array([... x32])
```

## Definition

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

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

## Parameters

### length

* **Type:** `number`

Length of the random [`Bytes.Bytes`](/api/Bytes/types#bytes) to generate.

## Return Type

Random [`Bytes.Bytes`](/api/Bytes/types#bytes) of the specified length.

`Bytes`
