[API reference](https://evolu.dev/docs/api-reference) › [@evolu/common](https://evolu.dev/docs/api-reference/common) › [Crypto](https://evolu.dev/docs/api-reference/common/Crypto) › RandomBytes

Defined in: [packages/common/src/Crypto.ts:27](https://github.com/evoluhq/evolu/blob/59dabb7c56c68040b30d3919013adeb2b40bad10/packages/common/src/Crypto.ts#L27)

## Methods

<a id="create"></a>

### create()

#### Call Signature

```ts
create(bytesLength: 16): Uint8Array<ArrayBufferLike> & Brand<"Entropy"> & Brand<"Length16">;
```

Defined in: [packages/common/src/Crypto.ts:73](https://github.com/evoluhq/evolu/blob/59dabb7c56c68040b30d3919013adeb2b40bad10/packages/common/src/Crypto.ts#L73)

Creates cryptographically secure random bytes with type-safe length
branding.

Uses the operating system's cryptographically secure random number
generator (crypto.getRandomValues) to generate high-quality entropy
suitable for cryptographic operations.

## Type Safety

Returns specific branded types for common sizes:

- `Entropy16` for 16-byte values (128 bits)
- `Entropy24` for 24-byte values (192 bits)
- `Entropy32` for 32-byte values (256 bits)
- `Entropy64` for 64-byte values (512 bits)
- `Entropy` for any other size

### Example

```ts
import {
  assertEqual,
  assertType,
  createRandomBytes,
  type Entropy16,
  type Entropy24,
  type Entropy32,
  type Entropy64,
} from "@evolu/common";

const randomBytes = createRandomBytes();
const nonce16 = randomBytes.create(16);
const nonce24 = randomBytes.create(24);
const key = randomBytes.create(32);
const seed = randomBytes.create(64);
const custom = randomBytes.create(48);

assertType<Entropy16, typeof nonce16>();
assertType<Entropy24, typeof nonce24>();
assertType<Entropy32, typeof key>();
assertType<Entropy64, typeof seed>();
assertEqual(custom.length, 48);
```

##### Parameters

| Parameter     | Type |
| ------------- | ---- |
| `bytesLength` | `16` |

##### Returns

`Uint8Array`\<`ArrayBufferLike`\> & [`Brand`](https://evolu.dev/docs/api-reference/common/Brand/interfaces/Brand)\<`"Entropy"`\> & [`Brand`](https://evolu.dev/docs/api-reference/common/Brand/interfaces/Brand)\<`"Length16"`\>

#### Call Signature

```ts
create(bytesLength: 24): Uint8Array<ArrayBufferLike> & Brand<"Entropy"> & Brand<"Length24">;
```

Defined in: [packages/common/src/Crypto.ts:74](https://github.com/evoluhq/evolu/blob/59dabb7c56c68040b30d3919013adeb2b40bad10/packages/common/src/Crypto.ts#L74)

##### Parameters

| Parameter     | Type |
| ------------- | ---- |
| `bytesLength` | `24` |

##### Returns

`Uint8Array`\<`ArrayBufferLike`\> & [`Brand`](https://evolu.dev/docs/api-reference/common/Brand/interfaces/Brand)\<`"Entropy"`\> & [`Brand`](https://evolu.dev/docs/api-reference/common/Brand/interfaces/Brand)\<`"Length24"`\>

#### Call Signature

```ts
create(bytesLength: 32): Uint8Array<ArrayBufferLike> & Brand<"Entropy"> & Brand<"Length32">;
```

Defined in: [packages/common/src/Crypto.ts:75](https://github.com/evoluhq/evolu/blob/59dabb7c56c68040b30d3919013adeb2b40bad10/packages/common/src/Crypto.ts#L75)

##### Parameters

| Parameter     | Type |
| ------------- | ---- |
| `bytesLength` | `32` |

##### Returns

`Uint8Array`\<`ArrayBufferLike`\> & [`Brand`](https://evolu.dev/docs/api-reference/common/Brand/interfaces/Brand)\<`"Entropy"`\> & [`Brand`](https://evolu.dev/docs/api-reference/common/Brand/interfaces/Brand)\<`"Length32"`\>

#### Call Signature

```ts
create(bytesLength: 64): Uint8Array<ArrayBufferLike> & Brand<"Entropy"> & Brand<"Length64">;
```

Defined in: [packages/common/src/Crypto.ts:76](https://github.com/evoluhq/evolu/blob/59dabb7c56c68040b30d3919013adeb2b40bad10/packages/common/src/Crypto.ts#L76)

##### Parameters

| Parameter     | Type |
| ------------- | ---- |
| `bytesLength` | `64` |

##### Returns

`Uint8Array`\<`ArrayBufferLike`\> & [`Brand`](https://evolu.dev/docs/api-reference/common/Brand/interfaces/Brand)\<`"Entropy"`\> & [`Brand`](https://evolu.dev/docs/api-reference/common/Brand/interfaces/Brand)\<`"Length64"`\>

#### Call Signature

```ts
create(bytesLength: number): Uint8Array<ArrayBufferLike> & Brand<"Entropy">;
```

Defined in: [packages/common/src/Crypto.ts:77](https://github.com/evoluhq/evolu/blob/59dabb7c56c68040b30d3919013adeb2b40bad10/packages/common/src/Crypto.ts#L77)

##### Parameters

| Parameter     | Type     |
| ------------- | -------- |
| `bytesLength` | `number` |

##### Returns

`Uint8Array`\<`ArrayBufferLike`\> & [`Brand`](https://evolu.dev/docs/api-reference/common/Brand/interfaces/Brand)\<`"Entropy"`\>