首页 > 代码库 > QQ gtk,bkn算法

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;
}

 

QQ gtk,bkn算法