stdlib

base58_encode(key: bytes)str

Encodes a bytes value using base58.

Parameters

key (bytes) – bytes value to be encoded

Returns

the encoded string

Return type

str

base58_decode(key: str)bytes

Decodes a string value encoded with base58.

Parameters

key (str) – string value to be decoded

Returns

the decoded bytes

Return type

bytes

base58_check_encode(key: bytes)str

Converts a bytes value to its equivalent str representation that is encoded with base-58 digits. The encoded str contains the checksum of the binary data.

Parameters

key (bytes) – bytes value to be encoded

Returns

the encoded string

Return type

str

base58_check_decode(key: str)bytes

Converts the specified str, which encodes binary data as base-58 digits, to an equivalent bytes value. The encoded str contains the checksum of the binary data.

Parameters

key (str) – string value to be decoded

Returns

the decoded bytes

Return type

bytes

base64_encode(key: bytes)str

Encodes a bytes value using base64.

Parameters

key (bytes) – bytes value to be encoded

Returns

the encoded string

Return type

str

base64_decode(key: str)bytes

Decodes a string value encoded with base64.

Parameters

key (str) – string value to be decoded

Returns

the decoded bytes

Return type

bytes

serialize(item: Any)bytes

Serializes the given value into its bytes representation.

Parameters

item (Any) – value to be serialized

Returns

the serialized value

Return type

bytes

Raises

Exception – raised if the item’s type is not serializable.

deserialize(data: bytes)Any

Deserializes the given bytes value.

Parameters

data (bytes) – serialized value

Returns

the deserialized result

Return type

Any

Raises

Exception – raised when the date doesn’t represent a serialized value.

atoi(value: str, base: int = 10)int

Converts a character string to a specific base value, decimal or hexadecimal. The default is decimal.

Parameters
  • value (str) – the int value as a string

  • base (int) – the value base

Returns

the equivalent value

Return type

int

Raises

Exception – raised when base isn’t 10 or 16.

itoa(value: int, base: int = 10)str

Converts the specific type of value to a decimal or hexadecimal string. The default is decimal.

Parameters
  • value (int) – the int value

  • base (int) – the value’s base

Returns

the converted string

Return type

int

Searches for a given value in a given memory.

Parameters
  • mem (bytes or str) – the memory

  • value (bytes or str) – the value

  • start (int) – the index the search should start from

  • backward (bool) – whether it should invert the memory

Returns

the index of the value in the memory. Returns -1 if it’s not found

Return type

int

memory_compare(mem1: Union[bytes, str], mem2: Union[bytes, str])int

Compares a memory with another one.

Parameters
  • mem1 (bytes or str) – a memory to be compared to another one

  • mem2 (bytes or str) – a memory that will be compared with another one

Returns

-1 if mem1 precedes mem2, 0 if mem1 and mem2 are equal, 1 if mem1 follows mem2

Return type

int