How to use the CRC16 recently used in the PHPCRC16 verification code algorithm? now I want to calculate the CRC16 verification code by 010301180001. using other tools, the verification code is 05F1. The final complete code is 01030118000105F1. I need to use a php program and write a function to calculate this 05F1 code, on the Internet, it is hard to find out how to use the C php CRC16 checksum algorithm in PHP.
Recently used CRC16,
Now I want to calculate the CRC16 verification code of 010301180001. with other tools, the verification code is 05F1.
The complete code is
01030118000105F1
Now I need to use a php program to write a function to calculate this 05F1. it is difficult to find the CRC16 application instance in php on the internet. Last night I found that php.net has such an official introduction.
Http://cn.php.net/manual/en/function.crc32.php
PHP code
I made this code to verify Transmition with Vantage Pro2 ( weather station ) based on CRC16-CCITT standard.
>8) ^ ord($ptr[$i]))] ^ (($crc<<8) & 0x00FFFF); return $crc;}?>
In the official example above, how can I replace 010301180001 with $ test?
Please help me apply this 010301180001. how can we get 05F1?
Thank you!
------ Solution --------------------
Tested, the #1 code meets your requirements.
Test Code
PHP code
$ S = pack ('H * ', '000000'); $ t = crc16 (s); printf (' = % 02x % 02x', $ t % 010301180001, floor ($ t/256 ));
------ Solution --------------------
$ Cs = sprintf ('= % 02x % 02x', $ t % 256, floor ($ t/256 ));