18.05.2011, 16:54
PHP код:
function num_hash($string)
{
$length = strlen($string);
$s1 = 1;
$s2 = 0;
for($n = 0; $n < $length; $n++)
{
$s1 = ($s1 + ord($string[$n])) % 65521;
$s2 = ($s2 + $s1) % 65521;
}
echo ($s2 << 16) + $s1;
}