Base58

class cometa.encoding.base58.Base58[source]

Bases: object

Base58 encoding and decoding utilities.

Base58 is a binary-to-text encoding scheme used in Bitcoin and other cryptocurrencies. It uses an alphabet that excludes easily confused characters (0, O, I, l) and non-alphanumeric characters.

Example

>>> data = b"\x01\x02\x03\x04\x05"
>>> encoded = Base58.encode(data)
>>> decoded = Base58.decode(encoded)
>>> decoded == data
True
static encode(data)[source]

Encodes binary data to a Base58 string.

Parameters:

data (bytes) – The binary data to encode.

Returns:

The Base58-encoded string.

Raises:

CardanoError – If encoding fails.

Return type:

str

Example

>>> Base58.encode(b"\x01\x02\x03\x04\x05")
'7bWpTW'
static decode(encoded)[source]

Decodes a Base58 string to binary data.

Parameters:

encoded (str) – The Base58-encoded string.

Returns:

The decoded binary data.

Raises:

CardanoError – If decoding fails (e.g., invalid Base58 string).

Return type:

bytes

Example

>>> Base58.decode("7bWpTW")
b'\x01\x02\x03\x04\x05'