求高手帮忙,帮我反写个程序,谢谢
<?function sample($s)
{
$hexchars = '0123456789ABCDEF';
if ( !$s || strlen($s) <= 0 )
{
echo "null string.";
return "";
}
$len = strlen($s);
$ret = '';
$curc = 0;
$nextc = ord(substr($s, 0, 1));
for ($i=1; $i<$len; $i++ )
{
$curc = $nextc;
$nextc = ord(substr($s, $i, 1));
$curc ^= $nextc;
//echo '<br> 0x'. substr($hexchars, ($curc & 0xF0) >> 4, 1) . substr($hexchars, $curc & 0x0F, 1);
$ret .= substr($hexchars, ($curc & 0xF0) >> 4, 1);
$ret .= substr($hexchars, $curc & 0x0F, 1);
}
$curc = $nextc ^ 0x7C;
$ret .= substr($hexchars, ($curc & 0xF0) >> 4, 1);
echo $ret;
echo "<br>";
$ret .= substr($hexchars, $curc & 0x0F, 1);
return $ret;
}
$a="srvaddr=127.0.0.1";
$b=sample($a);
echo $b;
function sample2($s)
{
//现在就想写个程序,把这个$b给还原成$a,请高手帮忙写个
}
$c=sample2($b);
echo $c;
?>