Time33哈希算法

Time33哈希算法算法

算法:对字符串的每一个字符,迭代的乘以33ui

公式:   hash(i) = hash(i-1)*33 + str[i] ;spa

在使用时,存在一个问题,对类似的字符串生成的hashcode也相似,code

能够对原始字符串,进行MD5,再hashcode。orm

uint32_t time33(char const *str, int len) 
    { 
        unsigned long  hash = 0; 
        for (int i = 0; i < len; i++) { 
            hash = hash *33 + (unsigned long) str[i]; 
        } 
        return hash; 
    }
相关文章
相关标签/搜索