mifareauth.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:TikiBot 作者: kikiorg 项目源码 文件源码
def _read_block(self, block):
        """Reads a block from a Mifare Card after authentication

           Returns the data read or raises an exception
        """
        if nfc.nfc_device_set_property_bool(self.__device, nfc.NP_EASY_FRAMING, True) < 0:
            raise Exception("Error setting Easy Framing property")
        abttx = (ctypes.c_uint8 * 2)()
        abttx[0] = self.MC_READ
        abttx[1] = block
        abtrx = (ctypes.c_uint8 * 250)()
        res = nfc.nfc_initiator_transceive_bytes(self.__device, ctypes.pointer(abttx), len(abttx),
                                                 ctypes.pointer(abtrx), len(abtrx), 0)
        if res < 0:
            raise IOError("Error reading data")
        return "".join([chr(abtrx[i]) for i in range(res)])
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号