Des encryption operations, found in Windows and Linux results are not the same, found that the CreateKey process has this operation, starting from here is not the same.
The network query was informed that an int overflow caused the correct under Windows. It is recommended to operate through the GMP extension, but no specific usage is found, please advise
Win results: 176881664
Lin Results: 759700962142060544
@eechen
Reply content:
Des encryption operations, found in Windows and Linux results are not the same, found that the CreateKey process has this operation, starting from here is not the same.
The network query was informed that an int overflow caused the correct under Windows. It is recommended to operate through the GMP extension, but no specific usage is found, please advise
Win results: 176881664
Lin Results: 759700962142060544
@eechen
Congratulations on falling into a big hole in PHP.
If a given number exceeds the range of integers, it will be interpreted as float. Similarly, float is returned if the result of the operation is outside the integer range.
This is the problem that has led to a variety of bizarre problems.
PHP does not support unsigned integers.
Reference PHP Original
However, you have this problem because the length of your two systems (PHP int type is long in the kernel) is inconsistent (because the number of system bits is not the same).
Therefore, if you want to work around this problem, you must manually process the int to uint.
$flag=$int&0x80000000;//取出符号位,判断是否是负数,溢出int范围,但没溢出uint范围时,符号位为1,即为负数if($flag){ $int ^= 0xffffffff; $int += 1;}
BTW, the latest PHP7 fixes this problem, but PHP cannot shift a negative number.
Do not know where this code is from, the left and right to move the negative number of the code is done by the CPU, so it is completely dependent on the machine, and the system is not a big relationship, see if you can fix this code, or can only use other methods to replace the left and right to move negative numbers.
So starting from the PHP7, the displacement of a negative number will be directly error ...