I found the needed snipped from a SHA1 implementation for PHP:
Use
$eax = (int)(zerofill($eax, 0x0c));
instead of
$eax = (int)(eax >> 0x0c);
and define the following function:
PHP Code:
function zeroFill($a, $b)
{
$z = hexdec(80000000);
if ($z & $a)
{
$a >>= 1;
$a &= (~$z);
$a |= 0x40000000;
$a >>= ($b-1);
}
else
{
$a >>= $b;
}
return $a;
}