]>
git.zerfleddert.de Git - proxmark3-svn/blob - tools/xorcheck.py
9cbc7a1e7ade0f203a415eae635c8e4ed6c7830e
3 # xorcheck.py - find xor values for 8-bit CRC
5 # Adam Laurie <adam@algroup.co.uk>
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.
26 if(len(sys
.argv
) < 3):
28 print '\t'+sys
.argv
[0] + ' - Generate final byte for XOR CRC'
30 print 'Usage: ' + sys
.argv
[0] + ' <ID Byte1> <ID Byte2> ... <CRC>'
32 print '\tSpecifying the bytes of a UID with a known CRC will find the last byte value'
33 print '\tneeded to generate that CRC with a rolling XOR. All bytes should be specified in HEX.'
37 print '\txorcheck.py 04 00 80 64 ba'
39 print 'Should produce the output:'
41 print '\tTarget (BA) matched with final byte value: 5A'
45 target
= int(sys
.argv
[len(sys
.argv
) - 1],16)
47 for candidate
in range(256):
49 for i
in range(len(sys
.argv
) - 2):
50 crc ^
= int(sys
.argv
[i
+ 1],16)
54 print 'Target (%02X) matched with final byte value: %02X' % (target
,candidate
)