stdlib
- base58_encode(key: bytes) str
Encodes a bytes value using base58.
>>> base58_encode(b'unit test') b"2VhL46g69A1mu"
- base58_decode(key: str) bytes
Decodes a string value encoded with base58.
>>> base58_decode('2VhL46g69A1mu') b"unit test"
- 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.
>>> base58_check_encode(b'unit test') b"AnJcKqvgBwKxsjX75o"
- 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.
>>> base58_check_decode('AnJcKqvgBwKxsjX75o') b"unit test"
- base64_encode(key: bytes) str
Encodes a bytes value using base64.
>>> base64_encode(b'unit test') b"dW5pdCB0ZXN0"
- base64_decode(key: str) bytes
Decodes a string value encoded with base64.
>>> base64_decode("dW5pdCB0ZXN0") b"unit test"
- serialize(item: Any) bytes
Serializes the given value into its bytes representation.
>>> serialize('42') b'(42'
>>> serialize(42) b'!*'
>>> serialize([2, 3, 5, 7]) b'@!!!!'
>>> serialize({1: 1, 2: 1, 3: 2}) b'H!!!!!!'
- deserialize(data: bytes) Any
Deserializes the given bytes value.
>>> deserialize(b'(42') '42'
>>> deserialize(b'!*') 42
>>> deserialize(b'@!!!!') [2, 3, 5, 7]
>>> deserialize(b'H!!!!!!') {1: 1, 2: 1, 3: 2}
- atoi(value: str, base: int = 10) int
Converts a character string to a specific base value, decimal or hexadecimal. The default is decimal.
>>> atoi('10') 10
>>> atoi('123') 123
>>> atoi('1f', 16) 31
>>> atoi('ff', 16) -1
- itoa(value: int, base: int = 10) str
Converts the specific type of value to a decimal or hexadecimal string. The default is decimal.
>>> itoa(10) '10'
>>> itoa(123) '123'
>>> itoa(-1, 16) 'f'
>>> itoa(15, 16) '0f'
- memory_search(mem: bytes | str, value: bytes | str, start: int = 0, backward: bool = False) int
Searches for a given value in a given memory.
>>> memory_search('abcde', 'a', 0) 0
>>> memory_search('abcde', 'e', 0) 4