QQ gtk,bkn算法

public long GetGTK(string sKey)
{
    int hash = 5381;
    for (int i = 0, len = sKey.Length; i < len; ++i)
    {
        hash += (hash << 5) + (int)sKey[i];
    }
    return (hash & 0x7fffffff);
}
 
 
long GetBkn(string skey)
{
    var hash = 5381;
    for (int i = 0, len = skey.Length; i < len; ++i) 
        hash += (hash << 5) + (int)skey[i];
    return hash & 2147483647;
}

 

posted @ 2017-01-04 20:14  清风的小窝  阅读(2224)  评论(0编辑  收藏  举报