Created
February 18, 2020 10:00
-
-
Save jacopo-j/361b5a4ec0733a6efe6a76d4863760d3 to your computer and use it in GitHub Desktop.
Algorithm for calculating CRC-8 checksum for MIFARE Application Directory (MAD)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you very much, good sir!