Skip to content

Instantly share code, notes, and snippets.

View ZeroOne010101's full-sized avatar

ZeroOne010101

  • Germany
View GitHub Profile
@jacopo-j
jacopo-j / CRC-8_MIFARE-MAD.py
Created February 18, 2020 10:00
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])