Skip to content

Base32

Utility functions for working with Base32 values using the BIP-173 bech32 alphabet.

Examples

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

Encoding to Base32

import { Base32 } from 'ox'
 
const value = Base32.fromHex('0x00ff00')

Decoding Base32

import { Base32 } from 'ox'
 
const value = Base32.toBytes('qrlsq')

Functions

NameDescription
Base32.fromBytesEncodes a Bytes.Bytes value to a Base32-encoded string (using the BIP-173 bech32 alphabet).
Base32.fromHexEncodes a Hex.Hex value to a Base32-encoded string (using the BIP-173 bech32 alphabet).
Base32.toBytesDecodes a Base32-encoded string (using the BIP-173 bech32 alphabet) to Bytes.Bytes.
Base32.toHexDecodes a Base32-encoded string (using the BIP-173 bech32 alphabet) to Hex.Hex.

Errors

NameDescription
Base32.InvalidCharacterErrorThrown when a Base32 string contains an invalid character.