# Base32

Utility functions for working with Base32 values using the [BIP-173](https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki) bech32 alphabet.

## Examples

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

* [Encoding to Base32](#encoding-to-base32)

* [Decoding Base32](#decoding-base32)

### Encoding to Base32

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

const value = Base32.fromHex('0x00ff00')
```

### Decoding Base32

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

const value = Base32.toBytes('qrlsq')
```

## Functions

| Name                | Description                         |
| ------------------- | ----------------------------------- |
| [`Base32.fromBytes`](/api/Base32/fromBytes) | Encodes a [`Bytes.Bytes`](/api/Bytes/types#bytes) value to a Base32-encoded string (using the BIP-173 bech32 alphabet). |
| [`Base32.fromHex`](/api/Base32/fromHex) | Encodes a [`Hex.Hex`](/api/Hex/types#hex) value to a Base32-encoded string (using the BIP-173 bech32 alphabet). |
| [`Base32.toBytes`](/api/Base32/toBytes) | Decodes a Base32-encoded string (using the BIP-173 bech32 alphabet) to [`Bytes.Bytes`](/api/Bytes/types#bytes). |
| [`Base32.toHex`](/api/Base32/toHex) | Decodes a Base32-encoded string (using the BIP-173 bech32 alphabet) to [`Hex.Hex`](/api/Hex/types#hex). |

## Errors

| Name                | Description                         |
| ------------------- | ----------------------------------- |
| [`Base32.InvalidCharacterError`](/api/Base32/errors#base32invalidcharactererror) | Thrown when a Base32 string contains an invalid character. |
| [`Base32.InvalidPaddingError`](/api/Base32/errors#base32invalidpaddingerror) | Thrown when a Base32 string contains non-canonical (non-zero) trailing bits. |
