# convertIPv4ToBinary

**Kind:** Function

**Source:** [`src/utils/ipaddr.ts`](https://github.com/honojs/hono/blob/main/src/utils/ipaddr.ts#L148)

**Part of:** [Utils](subsystem-src-utils)

Convert IPv4 to Uint8Array

Converts an IPv4 address string into a `Uint8Array` representation. It supports code in `src/utils/ipaddr.ts` that needs address data in byte form.

## Signature

```ts
function convertIPv4ToBinary(ipv4: string): bigint
```

## Parameters

| Name | Type |
|---|---|
| `ipv4` | `string` |

**Returns:** `bigint`

## Diagram

```mermaid
graph LR
  Input[IPv4 address string] --> Convert[convertIPv4ToBinary]
  Convert --> Output[Uint8Array]
```

## Usage

```ts
import { convertIPv4ToBinary } from './utils/ipaddr';

declare const ipv4Address: string;

const addressBytes = convertIPv4ToBinary(ipv4Address);

console.log(addressBytes);
```

## AI Coding Instructions

- Pass a valid IPv4 address string to this function.
- Keep the returned value as a `Uint8Array` when passing address data to byte-oriented APIs.
- Handle invalid address input at the caller when the surrounding flow requires user-facing errors.
- Import the helper from `src/utils/ipaddr.ts` rather than duplicating address-to-byte conversion logic.

## Used by

1 reference from 1 file. Each is a place in this repository where the symbol is actually used — go read one rather than trusting an example.

### Imported by (1)

- `IPRestrictionRule` — `src/middleware/ip-restriction/index.ts`:38
