Simple CHECKSUM algorithm to find from examples of data and CRC

  algorithm, c++, checksum, crc

I have a 24-bit checksum to decode. The input data is 3 bytes.
The checksum is also 3 bytes. It looks like ‘data’ is an xor operation
being performed between the value of ‘Data’ and the value 0x9F5A68.
or each byte separately: ‘data’ byte[0] xor 0x95, ‘data’ byte[1] xor 0x5A and ‘data’ byte[2] xor 0x68.

But for further data values the xor value changes and we get different results.

Perhaps different data byte values give a different value for the xor operation,
which gives a different checksum value than we would expect at the beginning.

Is there any way to derive the formula by which it is calculated?

It seems that the range of 3 bytes from 0x00 to 0xFFFFFF is maybe divided into some ranges, beyond which the XOR value changes. Would it be calculated that way?

I have generated a lot of pairs for comparison. here they are:

Data:    -->   CheckSum:
00 00 01 -->   9F 5A 69    // XOR 0x9F5A68
00 00 02 -->   9F 5A 6A 
00 00 03 -->   9F 5A 6B
00 00 04 -->   9F 5A 6C
00 00 05 -->   9F 5A 6D
00 00 06 -->   9F 5A 6E
00 00 07 -->   9F 5A 6F
00 00 08 -->   9F 5A 60
00 00 09 -->   9F 5A 61
00 00 0A -->   9F 5A 62
00 00 0B -->   9F 5A 63
00 00 0C -->   9F 5A 64
00 00 0D -->   9F 5A 65
00 00 0E -->   9F 5A 66
00 00 0F -->   9F 5A 67
00 00 10 -->   9F 5A 78
00 00 11 -->   9F 5A 79
00 00 12 -->   9F 5A 7A
00 00 13 -->   9F 5A 7B
00 00 14 -->   9F 5A 7C
00 00 15 -->   9F 5A 7D
00 00 16 -->   9F 5A 7E
00 00 17 -->   9F 5A 7F  
00 00 18 -->   9F 5A 70
00 00 19 -->   9F 5A 71
00 00 1A -->   9F 5A 72   
00 01 00 -->   9F 5B 68
00 02 00 -->   9F 58 68
00 03 00 -->   9F 59 68
00 04 00 -->   9F 5E 68   
00 05 00 -->   9F 5F 68
00 06 00 -->   9F 5C 68
00 07 00 -->   9F 5D 68
00 08 00 -->   9F 52 68
00 09 00 -->   9F 53 68
00 0A 00 -->   9F 50 68
01 01 01 -->   9F 5B 69  
0A 0A 0A -->   95 50 62 
11 11 11 -->   8E 4B 79  
B7 1B 00 -->   28 41 68 

here is another xor value for further data bytes:

64 00 64 --> 75 E0 10  // XOR 11 E0 74
64 C8 64 --> 75 28 10  // XOR 11 E0 74 

00 64 64 --> 21 74 E3  // XOR 21 10 87 

64 64 64 --> 9E 30 4D  // XOR FA 54 29 
65 65 65 --> 9F 31 4C  // XOR FA 54 29 

63 63 63 --> 42 73 E4  // XOR 21 10 87 
63 64 63 --> 42 74 E4  // XOR 21 10 87 
63 64 64 --> 42 74 E3  // XOR 21 10 87 
64 63 63 --> 45 73 E4  // XOR 21 10 87 

99 99 99 --> FD DC 1A  // XOR 64 45 83 
C8 C8 C8 --> AC 8D 4B  // XOR 64 45 83 

C7 C7 C7 --> 95 E9 74  // XOR 52 2E B3 

C9 C9 C9 --> AD 8C 4A  // XOR 64 45 83 

DE DE DE --> 8C F0 6D  // XOR 52 2E B3 

EE EE EE --> DA 0C EF  // XOR 34 E2 01 
FF FF FF --> CB 1D FE  // XOR 34 E2 01 

BB BB BB --> 22 E7 0B  // XOR 99 5C B0 

Source: Windows Questions C++

LEAVE A COMMENT