Kit
Functions

getBaseXDecoder

getBaseXDecoder(alphabet): VariableSizeDecoder<string>

Returns a decoder for base-X encoded strings.

This decoder deserializes base-X encoded strings from a byte array using a custom alphabet. The decoding process converts the byte array into a numeric value in base-10, then maps that value back to characters in the specified base-X alphabet.

For more details, see getBaseXCodec.

Parameters

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

Returns

VariableSizeDecoder<string>

A VariableSizeDecoder<string> for decoding base-X strings.

Example

Decoding a base-X string using a custom alphabet.

const decoder = getBaseXDecoder('0123456789abcdef');
const value = decoder.decode(new Uint8Array([0xde, 0xad, 0xfa, 0xce])); // "deadface"

See

getBaseXCodec

On this page