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:
InvalidMultibaseStringError – if the data is not multibase encoded
DecodingError – if decoding fails
- 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.Encodingobject for the data’s codec- Raises:
InvalidMultibaseStringError – if the codec is not supported