My webhost reports that PHP_INT_MAX is 2147483647, i.e. it's a 32-bit environment. I'm trying to convert a couple of mathematical operations that currently works in a 64-bit environment, so that they also work in the 32-bit environment.
$id = '76561197996545192';
$temp = '';
for ($i = 0; $i < 8; $i++)
{
$temp .= chr($id & 0xFF);
$id >>= 8;
}
$result= md5('BE' . $temp);
echo $result;
The above yields de46c6d30bfa6e097fca82f63c2f4f4c
in the 32-bit environment, but it should actually yield cd97cc68c1038b485b081ba2aa3ea6fa
(which it currently does in the 64-bit environment). I'm guessing that the bitshift operator is causing the mismatch, but I'm not sure (I'm not a php-expert, nor a mathematician, and I'm not the author of the original code :)
BCMath is installed in the 32-bit environment, and there may be other frameworks installed as well (I can check the phpinfo if needed).
How would I go about fixing this? Is it possible?
// Linus
Edit: Yes, I know the code looks weird, but it is working exactly as intended in a 64-bit environment.