Kit
Variables

getBaseXEncoder

const getBaseXEncoder: (alphabet) => VariableSizeEncoder<string>

Returns an encoder for base-X encoded strings.

This encoder serializes strings using a custom alphabet, treating the length of the alphabet as the base. The encoding process involves converting the input string to a numeric value in base-X, then encoding that value into bytes while preserving leading zeroes.

For more details, see getBaseXCodec.

Parameters

ParameterTypeDescription
alphabetstringThe set of characters defining the base-X encoding.

Returns

VariableSizeEncoder<string>

A VariableSizeEncoder<string> for encoding base-X strings.

Example

Encoding a base-X string using a custom alphabet.

const encoder = getBaseXEncoder('0123456789abcdef');
const bytes = encoder.encode('deadface'); // 0xdeadface

See

getBaseXCodec

On this page