A utility class for encoding and decoding data using Base58 encoding.

Base58 encoding is commonly used in blockchain systems to encode binary data into a human-readable and compact format. This class provides methods to calculate the required buffer sizes for encoding/decoding and to perform the actual encoding/decoding.

Methods

  • Decodes a Base58-encoded string into binary data.

    Parameters

    • encodedString: string

      The Base58-encoded string to decode.

    Returns Uint8Array

    The decoded binary data.

    If the decoding fails.

  • Decodes a Base58 string into a hexadecimal string.

    This method converts the input Base58-encoded string into binary data (a Uint8Array), which is then transformed into its hexadecimal representation.

    Parameters

    • base58String: string

      The Base58-encoded string to decode. This should be a valid Base58 string (e.g., "19DXstMaV...").

    Returns string

    The decoded hexadecimal string.

    If the input is not a valid Base58 string or the decoding fails.

  • Encodes binary data into a Base58 string.

    Parameters

    • data: Uint8Array

      The binary data to encode.

    Returns string

    The Base58-encoded string.

    If the encoding fails.

  • Encodes a hexadecimal string into a Base58 string.

    This method converts the input hexadecimal string into binary data (a Uint8Array), which is then encoded into a Base58 string.

    Parameters

    • hexString: string

      The input hexadecimal string to encode. This should be a valid hexadecimal representation (e.g., "a1b2c3").

    Returns string

    The Base58-encoded string.

    If the input is not a valid hex string or the encoding fails.