After performing the des encryption operation, we found that the results obtained in windows and linux are different. it is found that this operation exists in the createkey process and is different from here. The network query result is int overflow, which is correct in windows. We recommend that you use the gmp extension, but the details are not found... after performing the des encryption operation, we found that the results obtained in windows and linux are different. it is found that this operation exists in the createkey process and is different from here.
The network query result is int overflow, which is correct in windows. It is recommended to use gmp extension, but no specific usage is found. please advise
Result of win:-176881664
Result of lin:-759700962142060544.
@ Eechen
Reply content:
After performing the des encryption operation, we found that the results obtained in windows and linux are different. it is found that this operation exists in the createkey process and is different from here.
The network query result is int overflow, which is correct in windows. It is recommended to use gmp extension, but no specific usage is found. please advise
Result of win:-176881664
Result of lin:-759700962142060544.
@ Eechen
Congratulations! you fell into a big pitfall of php.
If a given number exceeds the integer range, it is interpreted as float. Similarly, if the execution result exceeds the integer range, float is returned.
This problem has caused various incredible problems.
PHP does not support unsigned integers.
Reference php original
However, this problem occurs because the length of the long type in both of your systems is inconsistent (because the number of digits in the system is different ).
Therefore, if you want to solve this problem, you must manually process int to uint.
$ Flag = $ int & 0x80000000; // Retrieve the symbol bit to determine whether it is a negative number. if the int range is exceeded but the uint range is not exceeded, the symbol bit is 1, that is, if ($ flag) {$ int ^ = 0 xffffffff; $ int + = 1 ;}
BTW, the latest php7 corrected this problem, but php cannot shift a negative number.
I don't know where this code comes from. the code with the left and right negative numbers is computed by the CPU, so it is completely dependent on the machine and has little to do with the system. check whether this code can be corrected, alternatively, you can only use other methods to replace the left-right negative shift.
So from php7, an error will be reported if a negative number is displaced...