PHP md5 same digital data string inconsistencies

PHP as MD5 encryption method used in the same encryption and digital character numeric string inconsistencies arise

Case

  

echo 'int   :'.md5 (1046191101562142034).PHP_EOL;
echo 'string:'.md5 ('1046191101562142034').PHP_EOL;

//结果

int   :87ab7e2de7b9732e606ed81c4b0c9606
string:87ab7e2de7b9732e606ed81c4b0c9606

  

At this time the result was consistent

But when we figure there will be more than the increase a phenomenon inconsistent results

Case

echo 'int   :'.md5 (10461911015621420340).PHP_EOL;
echo 'string:'.md5 ('10461911015621420340').PHP_EOL;

//结果

int   :386dea57fc50309fdec13307d6cc47da
string:79cb1355eaede60858cb31dc40e60b53

  

The reason this occurs is because PHP_INT_MAX values ​​9223372036854775807

When there is a number greater than the value of PHP itself will do overflow handling

echo 'ori int: 10461911015621420340'.PHP_EOL; 
echo 'int int:'. intVal (10461911015621420340) .PHP_EOL; 

//结果

ori int: 10461911015621420340 
int int: -7,984,833,058,088,130,560

  

So the actual value of encryption is not the same result naturally is not the same

Guess you like

Origin www.cnblogs.com/SarcasMe/p/11128280.html