I'm trying to write a byte array that was converted from a hex string into the memory of an NTAG203 RFID tag. I'm using a Raspberry Pi 3, a PN532 chip and the Adafruit PN532 python library.
hex_string = '59e7168f267df300018e15b0'
formatted_hex = bytearray.fromhex(hex_string)
byte_data = bytearray(16)
byte_data[3:15] = formatted_hex
if not pn532.mifare_classic_write_block(4, byte_data):
print('Error! Failed to write to the card.')
sys.exit(-1)
When I do pn532.mifare_classic_read_block(4)
to read the value from memory again it comes out like this:
print '0x{0}'.format(binascii.hexlify(<function call result>))
>>> 0x00000059440300fe0000000000000000
The value is chopped off and has trailing and leading zeroes. What is happening here?
I would like to be able to convert the value back into hex again to use it to search a database.