Makefile: display firmware size
[RRG-proxmark3.git] / tools / xorcheck.py
blob205e41ccb51ab31155f7f77d6b68aa7e5fa113f7
1 #!/usr/bin/env python3
3 # xorcheck.py - find xor values for 8-bit LRC
5 # Adam Laurie <adam@algroup.co.uk>
6 # http://rfidiot.org/
8 # This code is copyright (c) Adam Laurie, 2009, All rights reserved.
9 # For non-commercial use only, the following terms apply - for all other
10 # uses, please contact the author:
12 # This code is free software; you can redistribute it and/or modify
13 # it under the terms of the GNU General Public License as published by
14 # the Free Software Foundation; either version 2 of the License, or
15 # (at your option) any later version.
17 # This code is distributed in the hope that it will be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # GNU General Public License for more details.
23 import sys
24 import os
26 if(len(sys.argv) < 3):
27 print("""
28 \t{0} - Generate final byte for XOR LRC
30 Usage: {0} <ID Byte1> <ID Byte2> ... <LRC>
32 \tSpecifying the bytes of a UID with a known LRC will find the last byte value
33 \tneeded to generate that LRC with a rolling XOR. All bytes should be specified in HEX.
35 Example:
37 \t{0} 04 00 80 64 ba
39 Should produce the output:
41 \tTarget (BA) requires final LRC XOR byte value: 5A\n""".format(sys.argv[0]))
42 os._exit(True)
44 target= int(sys.argv[len(sys.argv) - 1],16)
46 lrc= 0x00
47 for i in range(len(sys.argv) - 1):
48 lrc ^= int(sys.argv[i + 1],16)
49 print('\nTarget (%02X) requires final LRC XOR byte value: %02X\n' % (target,lrc))