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 @ 2016-02-23 16:54  来了啊老弟  阅读(2108)  评论(0编辑  收藏  举报