php hash算法

来源:互联网 发布:阿里云推荐码怎么获取 编辑:程序博客网 时间:2024/05/17 23:48

/** 
 * CRC32 Hash function 
 * @param $str 
 * @return int 
 */ 
function hash32($str) 

    return crc32($str) >> 16 & 0x7FFFFFFF; 
}


/** 
 * Times33 Hash function 
 * @param $str 
 * @return int 
 */ 
function hash33($str) 

    $hash = 0; 
    for($i=0; $i<strlen($str); $i++) { 
        $hash += 33 * $hash + ord($str{$i}); 
    } 
    return $hash & 0x7FFFFFFF; 
}


原创粉丝点击