API Reference

multibase.encode(encoding, data)[source]

Encodes the given data using the encoding that is specified

Parameters:
  • encoding (str) – encoding to use, should be one of the supported encoding

  • data (str or bytes) – data to encode

Returns:

multibase encoded data

Return type:

bytes

Raises:

UnsupportedEncodingError – if the encoding is not supported

multibase.decode(data, return_encoding=False)[source]

Decode the multibase decoded data

Parameters:
  • data (str or bytes) – multibase encoded data

  • return_encoding (bool) – if True, return tuple (encoding, decoded_data)

Returns:

decoded data, or tuple (encoding, decoded_data) if return_encoding=True

Return type:

bytes or tuple

Raises:
multibase.get_codec(data)[source]

Returns the codec used to encode the given data

Parameters:

data (str or bytes) – multibase encoded data

Returns:

the multibase.Encoding object for the data’s codec

Raises:

InvalidMultibaseStringError – if the codec is not supported

multibase.is_encoded(data)[source]

Checks if the given data is encoded or not

Parameters:

data (str or bytes) – multibase encoded data

Returns:

if the data is encoded or not

Return type:

bool