Skip to content

Instantly share code, notes, and snippets.

@jacopo-j
Created February 18, 2020 10:00
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jacopo-j/361b5a4ec0733a6efe6a76d4863760d3 to your computer and use it in GitHub Desktop.
Save jacopo-j/361b5a4ec0733a6efe6a76d4863760d3 to your computer and use it in GitHub Desktop.
Algorithm for calculating CRC-8 checksum for MIFARE Application Directory (MAD)
def checksum(data):
crc = 0xc7
for byte in data:
crc ^= byte
for _ in range(8):
msb = crc & 0x80
crc = (crc << 1) & 0xff
if msb:
crc ^= 0x1d
return bytes([crc])
@ZeroOne010101
Copy link

Thank you very much, good sir!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment