# convertIPv6ToBinary

**Kind:** Function

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

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

Convert IPv6 to Uint8Array

`convertIPv6ToBinary` accepts an IPv6 address string and converts it into a `Uint8Array`. It belongs to the IP address utility layer, where callers can use the byte representation for address processing and comparisons.

## Signature

```ts
function convertIPv6ToBinary(ipv6: string): bigint
```

## Parameters

| Name | Type |
|---|---|
| `ipv6` | `string` |

**Returns:** `bigint`

## Diagram

```mermaid
graph LR
  Address[IPv6 address string] --> Convert[convertIPv6ToBinary]
  Convert --> Bytes[Uint8Array]
```

## Usage

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

const address = 'fe80::abcd';
const bytes = convertIPv6ToBinary(address);

console.log(bytes);
```

## AI Coding Instructions

- Pass IPv6 address strings to `convertIPv6ToBinary`; do not use it for IPv4 addresses.
- Treat the returned value as binary address data rather than a formatted address string.
- Keep address parsing and conversion logic in `src/utils/ipaddr.ts`.
- Match existing caller behavior for invalid or malformed IPv6 input.

## 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
