function charCodeAt($str,$index){ $char=mb_substr($str,$index,1,'UTF-8'); if(mb_check_encoding($char,'UTF-8')){ $ret=mb_convert_encoding($char,'UTF-32BE','UTF-8'); return hexdec(bin2hex($ret)); }else{ return null; } } function getGTK($skey){ $hash=5381; $len=strlen($skey); for($i=0;$i<$len;++$i){ $hash+=($hash<<5)+charCodeAt($skey,$i); } return $hash&0x7fffffff; }
拿去试试吧,我也不知道什么时候写了这玩意