[API reference](https://jsprismarine.dev/api/index.md) / [@jsprismarine/native-network](https://jsprismarine.dev/api/@jsprismarine/native-network/index.md) / Cfb8

# Class: Cfb8

Defined in: [native-network/src/Cfb8.ts:47](https://github.com/JSPrismarine/JSPrismarine/blob/21088b69d7b227110b98eefd29702ff7304762ef/packages/native-network/src/Cfb8.ts#L47)

One direction of an AES-128-CFB8 stream, Java Edition's connection cipher, run in the native
library's TLS library. It exists for Bun, whose `node:crypto` has no `aes-128-cfb8`; Node.js
has its own.

The native cipher holds its key and register until [Cfb8.close](#close), so the owner closes it
when the connection ends.

## Methods

### close()

> **close**(): `void`

Defined in: [native-network/src/Cfb8.ts:102](https://github.com/JSPrismarine/JSPrismarine/blob/21088b69d7b227110b98eefd29702ff7304762ef/packages/native-network/src/Cfb8.ts#L102)

Frees the native cipher. Closing it again does nothing.

#### Returns

`void`

***

### update()

> **update**(`data`): `Buffer`

Defined in: [native-network/src/Cfb8.ts:91](https://github.com/JSPrismarine/JSPrismarine/blob/21088b69d7b227110b98eefd29702ff7304762ef/packages/native-network/src/Cfb8.ts#L91)

Runs the next bytes of the stream through the cipher.

#### Parameters

##### data

`Uint8Array`

The bytes, which are left as they are.

#### Returns

`Buffer`

The same number of bytes, encrypted or decrypted.

#### Throws

When the cipher was closed or the library fails.

***

### available()

> `static` **available**(): `boolean`

Defined in: [native-network/src/Cfb8.ts:62](https://github.com/JSPrismarine/JSPrismarine/blob/21088b69d7b227110b98eefd29702ff7304762ef/packages/native-network/src/Cfb8.ts#L62)

Whether the native cipher is available: a build of the library for this machine loads and
has it.

#### Returns

`boolean`

True when [Cfb8.create](#create) returns a cipher.

***

### create()

> `static` **create**(`direction`, `key`, `iv`): `Cfb8` \| `undefined`

Defined in: [native-network/src/Cfb8.ts:74](https://github.com/JSPrismarine/JSPrismarine/blob/21088b69d7b227110b98eefd29702ff7304762ef/packages/native-network/src/Cfb8.ts#L74)

Starts one direction of a stream.

#### Parameters

##### direction

`"encrypt"` \| `"decrypt"`

Which way the stream goes.

##### key

`Uint8Array`

The sixteen-byte AES-128 key.

##### iv

`Uint8Array`

The sixteen-byte initial register.

#### Returns

`Cfb8` \| `undefined`

The cipher, or undefined when the library is missing or predates the cipher.

#### Throws

When the library refuses the key or the register.
