Search code examples
checksum

Checksum identification


I'm trying to understand some data traffic.

Here are some short packages I captured (Hex string):

Data      Checksum
------    ---------
87          0087
7639        7639
7739        7739
DA423030    A25A
DA423031    A25B
DA423130    A35A
DA424030    D25A
DA423040    A22A
DA423032    A258

Can anyone identify how the checksum is made up?

(Note: Adding zero-bytes at the beginning of the data does not change the checksum, but adding them at the end does change it.)


Solution

  • The solution is:

    1. Take the whole string up to the last 2 bytes, perform on it CRC-16/XMODEM.
    2. Perform on the result XOR with the last 2 bytes left.

    For example:

    Data      Checksum
    ------    ---------
    DA423030    A25A
    
    DA42 >> CRC-16/XMODEM >> 926A
    926A >> XOR With 3030 >> A25A