I could do with some help with checksums.
I am reading some RFID tags which have 13 bytes. The first is always 02 and the last is 03. The penultimate one is supposedly the sum code.
So for example, with this set of bytes 02,53,65,48,48,49,66,48,52,55,48,53,03
53 is supposed to be the sum code of the preceding 10 bytes. But I don't know how this is calculated. There seem to be lots of different algorithms for generating checksums, and I hardly know anything about the subject.
I'd like to be able to check that the 12th byte is correct for the other 10, but how?
If the manufacturer reveals the algorithm used to generate the check byte, that is all you need to know.
If not, you need to reverse engineer the algorithm. That can be trivial (like a simple sum) or quite a challenge (some CRC variation, or proprietary), so first check all the available documentation for your gizmo, writing to the manufacturer if necessary.
robertjenkins:
Oh! I thought it was some fancy logic operation!
there are different types of checksums. some are simply "+". others involve shifting and combining with pseudo random sequences. correct checksums are no guarantee that the values are correct
Exclusive or is performing a "binary inversion" which is widely used in crytography for both encryption, hashing and calculation of checksums. The rest is just numbers which may be represented in different ways.
The confusion here is because some people are talking about bit operations and some about byte operations. The OP only really needs to be concerned about byte operations, and the correct solution has been put forward.