예제 #1
0
 public static function hashCode($s)
 {
     if ($s == null || strlen($s) == 0) {
         return "0";
     }
     $hash = "0";
     $h = "0";
     if (bccomp($h, "0") == 0) {
         $off = "0";
         $val = TPSecurityUtils::unistr_to_ords($s);
         $len = count($val);
         for ($i = 0; $i < $len; $i++) {
             $temp = $h;
             for ($j = 0; $j < 30; $j++) {
                 $temp = TPSecurityUtils::addNums($temp, $h);
                 //				echo "---------> :" . $temp. "\n";
             }
             $h = TPSecurityUtils::addNums($temp, $val[$off++]);
             //			echo "MAIN:" . $h. "\n";
         }
         $hash = $h;
     }
     return $hash;
 }