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;
}
原文地址:https://www.cnblogs.com/shadowme/p/6250111.html