Closed jfern2011 closed 5 years ago
0x8005 and 0xA001 are the same polynomials bit with the bits swapped. Which one is used depends on the algorithm and the first bit it works on which differs in the C language version in the library and the PHP language version on the website. If you run the tstcrc program which is generated when you compile the sources, the output of the program can be tested with the tstcrc -a call. For "123456789" the result is 0xBB3D, just as on the website.
0x8005 = 0b1000 0000 0000 0101 0xA001 = 0b1010 0000 0000 0001
Your website https://www.lammertbies.nl/comm/info/crc-calculation.html states that the polynomial function for CRC-16 is 0x8005, but in fact checksum.h defines CRC_POLY_16 as 0xA001. Hence, crc_16() does not give the same value as your online CRC calculator for "123456789", 0xBB3D.