:py:mod:`cryptnoxpy.connection` =============================== .. py:module:: cryptnoxpy.connection .. autoapi-nested-parse:: Module for keeping the connection to the reader. Sending and receiving information from the card through the reader. Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: cryptnoxpy.connection.Connection .. py:class:: Connection(index: int = 0, debug: bool = False) Bases: :py:obj:`contextlib.ContextDecorator` Connection to the reader. Sends and receives messages from the card using the reader. :param int index: Index of the reader to initialize the connection with :param bool debug: Show debug information during requests :var Card self.card: Information about the card. .. py:method:: _init_reader(self, index) .. py:method:: __del__(self) .. py:method:: send_apdu(self, apdu: List[int]) -> Tuple[List[int], int, int] Send data to the card in plain format :param int apdu: list of the APDU header :return bytes: Result of the query that was sent to the card :rtype: bytes :raises ConnectionException: Issue in the connection .. py:method:: send_encrypted(self, apdu: List[int], data: bytes, receive_long: bool = False) -> bytes Send data to the card in encrypted format :param int apdu: list of the APDU header :param data: bytes of the data payload (in clear, will be encrypted) :param bool receive_long: :return bytes: Result of the query that was sent to the card :rtype: bytes :raises CryptnoxException: General exceptions .. py:method:: _check_response_code(code1: int, code2: int) -> None :staticmethod: .. py:method:: _decode(self, rep: bytes, mac_value: bytes) -> bytes .. py:method:: _encrypt(self, apdu: List[int], data: bytes, receive_long: bool) -> Tuple[List[int], Union[int, bytes]] .. py:method:: _open_secure_channel(self, pairing_secret: bytes = b'', pairing_key_index: int = 0) -> None