cryptnoxpy.binary_utils

Utility module for handling binary data

Module Contents

Functions

list_to_hexadecimal(data: List[int], sep: str = '') → str

Convert list of integers into hexadecimal representation

hexadecimal_to_list(value: str) → List[int]

Convert given string containing hexadecimal representation of numbers into

path_to_bytes(path_str: str) → bytes

Convert given path for format that the card uses

binary_to_list(data: bytes) → List[int]

Convert given binary data to it’s representation as a list of hexadecimal

pad_data(data: bytes) → bytes

Pad data with 0s to be length of 128.

remove_padding(data: bytes) → bytes

Remove padding from the data

cryptnoxpy.binary_utils.list_to_hexadecimal(data: List[int], sep: str = '') str

Convert list of integers into hexadecimal representation

Parameters
  • data (List[int]) – List of integer to return in hexadecimal string form

  • sep (str) – (optional) Separator to use to join the hexadecimal numbers

Returns

list

Return type

str

cryptnoxpy.binary_utils.hexadecimal_to_list(value: str) List[int]

Convert given string containing hexadecimal representation of numbers into list of integers

Parameters

value (string) – String containing hexadecimal numbers

Returns

List of hexadecimal values in integer form

Return type

List[int]

cryptnoxpy.binary_utils.path_to_bytes(path_str: str) bytes

Convert given path for format that the card uses

Parameters

path_str (str) – path to convert

Returns

path formatted for use with the card.

Return type

bytes

cryptnoxpy.binary_utils.binary_to_list(data: bytes) List[int]

Convert given binary data to it’s representation as a list of hexadecimal values.

Parameters

data (bytes) – Binary data to convert to

Returns

List containing data in hexadecimal numbers in integer format

Return type

List[int]

cryptnoxpy.binary_utils.pad_data(data: bytes) bytes

Pad data with 0s to be length of 128.

Parameters

data – Data to be padded.

Returns

Data padded with 0s with length 128.

Return type

bytes

cryptnoxpy.binary_utils.remove_padding(data: bytes) bytes

Remove padding from the data

Parameters

data (bytes) – Data from which to remove padding

Returns

Data without the padding

Return type

bytes