Hi, all.
I moved my web site to dedicated server and find out password encrypt function stop working.
So, I debugged and narrowed down the following statment.
$tp2=2022886285 & -2147483649;
My old shared hosting returns proper value: 2022886285
Please check: http://www.community4pets.com/ver1/SitePortal/test.php
phpinfo: http://www.community4pets.com/phpinfo.php
And
new dedicated server returns: 0.
Please check: http://67.19.58.250/~myps1978/community ... l/test.php
phpinfo: http://67.19.58.250/~myps1978/phpinfo.php
New dedicated server: CentOS 5.4 Enterprise.
I don't know os of shared one.
However, I tested the statement on window server using ASP.NET.
It returns proper value.
I guess the bit operation problem comes from OS setting related character set.
any comment helps.
And code used in test.php
Code: Select all
<?
function get_password_str($pass) {
$nr = 1345345333;
$add = 7;
$nr2 = 0x12345671;
$size = strlen($pass);
echo "size:".$size."<br />";
for($i=0;$i<$size;$i++)
{
/* skipp space in password */
if($pass[$i] == ' ' || $pass[$i] == '\t') continue;
$tmp = ord($pass[$i]);
$nr ^= ((($nr & 63)+$add)*$tmp) + ($nr << ;
$nr2 += ($nr2 << ^ $nr;
$add += $tmp;
}
echo "nr:".$nr."<br />";
echo "nr2:".$nr2."<br />";
//Following two line is problem.
//bit operation doesn't work.
$result1=$nr & ((1 << 31) -1); /* Don't use sign bit (str2int) */
$result2=$nr2 & ((1 << 31) -1);
echo "result1:".$result1."<br />";
echo "result2:".$result2."<br />";
$result = sprintf("%08x%08x",$result1,$result2);
return $result;
}
?>
<html>
<head>
<title>TEST</title>
<link rel="stylesheet" type="text/css" href="<?=$petportal_url?>css/default.css">
</head>
<body>
<?php
echo get_password_str("sky")."<br />";
echo "Expected Value: 7892cb8d2631b067"."<br />";
//$psss is not defined so the value is empty string.
//that's why strlen($pass) returns null.
echo "pass:".$psss."<br />";
echo strlen($pass)."<br />";
echo "-----------------test1.---------------<BR>";
$nr = 2022886285;
$nr2 = 4935757927;
$result1=$nr & ((1 << 31) -1);
$result2=$nr2 & ((1 << 31) -1);
echo "result1:".$result1."<br />";
echo "result2:".$result2."<br />";
echo "-----------------test2.---------------<BR>";
$nr = 2022886285;
$nr2 = 4935757927;
$result1= 2022886285 & ((1 << 31) -1);
$result2= 4935757927 & ((1 << 31) -1);
echo "result1:".$result1."<br />";
echo "result2:".$result2."<br />";
$tp = (1 << 31) -1;
echo "tp:".$tp."<br />";
$tp2 = 2022886285 & -2147483649;
echo "tp2=2022886285 & -2147483649:".$tp2."<br />";
$tp3 = 9 & 8;
echo "tp3= 9 & 8:".$tp3."<br />";
$tp4 = ((1 << 31) -1);
echo "tp4= ((1 << 31) -1):".$tp4."<br />";
?>
</body>
</html>[php][/php][url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1 wrote:3. Do not make multiple, identical posts. This is viewed as spam and will be deleted.