# Bech32m

Utility functions for [BIP-350](https://github.com/bitcoin/bips/blob/master/bip-0350.mediawiki) bech32m encoding and decoding.

## Examples

Below are some examples demonstrating common usages of the `Bech32m` module:

* [Encoding](#encoding)

* [Decoding](#decoding)

### Encoding

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

const encoded = Bech32m.encode('tempo', new Uint8Array(20))
```

### Decoding

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

const { hrp, data } = Bech32m.decode(
  'tempo1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq7w9gdx'
)
```

## Functions

| Name                | Description                         |
| ------------------- | ----------------------------------- |
| [`Bech32m.decode`](/api/Bech32m/decode) | Decodes a bech32m string (BIP-350) into a human-readable part and data bytes. |
| [`Bech32m.encode`](/api/Bech32m/encode) | Encodes data bytes with a human-readable part (HRP) into a bech32m string (BIP-350). |

## Errors

| Name                | Description                         |
| ------------------- | ----------------------------------- |
| [`Bech32m.ExceedsLengthError`](/api/Bech32m/errors#bech32mexceedslengtherror) | Thrown when the encoded string exceeds the length limit. |
| [`Bech32m.InvalidCharacterError`](/api/Bech32m/errors#bech32minvalidcharactererror) | Thrown when a bech32m string contains an invalid character. |
| [`Bech32m.InvalidChecksumError`](/api/Bech32m/errors#bech32minvalidchecksumerror) | Thrown when a bech32m string has an invalid checksum. |
| [`Bech32m.InvalidHrpError`](/api/Bech32m/errors#bech32minvalidhrperror) | Thrown when the HRP is invalid (empty or contains non-ASCII characters). |
| [`Bech32m.MixedCaseError`](/api/Bech32m/errors#bech32mmixedcaseerror) | Thrown when a bech32m string contains mixed case. |
| [`Bech32m.NoSeparatorError`](/api/Bech32m/errors#bech32mnoseparatorerror) | Thrown when a bech32m string has no separator. |

## Types

| Name                | Description                         |
| ------------------- | ----------------------------------- |
| [`Bech32m.InvalidPaddingError`](/api/Bech32m/types#bech32minvalidpaddingerror) |  |
