Calculate the form of PHP CRC check Code (PHP xor)

Source: Internet
Author: User
How to calculate the PHP CRC check Code (PHP xor)

For example, I have a string "139c", using a calculator to calculate the check code, copy the 13^9c= to the calculator with 16 binary calculation to calculate 8F is correct

Calculate with PHP:


echo Dechex (0x13^0x9c); The result is 8f, correct

echo "";

$s 1 = ' 0x13 ';
$s 2 = ' 0x9c ';
Echo Dechex ($s 1^ $s 2);//result is 0, error

echo "";

$s 3 = ' 13 ';
$s 4 = ' 9c ';
Echo Dechex ($s 3^ $s 4); Result is 0, error



Assigning a value to a variable is not the same as the result of the direct write, I wonder ... Would you please give me some pointers, or have a calculation function available?
------to solve the idea----------------------
$s 1 = 0x13;
$s 2 = 0x9c;
Echo Dechex ($s 1^ $s 2);
8f
No problem
------to solve the idea----------------------

$s 1 = hexdec (' 0x13 ');
$s 2 = hexdec (' 0x9c ');
Echo Dechex ($s 1^ $s 2); 8F

$s 3 = hexdec (' 13 ');
$s 4 = hexdec (' 9c ');
Echo Dechex ($s 3^ $s 4); 8F

This is normal.
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.