webQQ 中hash值的計算 python實現 2015年7月

來源:互聯網
上載者:User

標籤:webqq   hash   python   

目前,在擷取群列表時,需要post一個hash值,計算函數在js中,具體位置詳見注釋部分。


另外,此部分更改的頻率很快,應該很快就變了。


#!/usr/bin/env python# -*- coding: UTF-8 -*-def getHashCode(b, j):    """    get the hash num to achieve the grouplist info (record:gcode)    source function:        http://0.web.qstatic.com/webqqpic/pubapps/0/50/eqq.all.js    source function definition:        P=function(b,j)        Args:         b : real QQ num         j : ptwebqq (get it by cookies)    Returns:         string : hashValue    Raises:         No raises    Author:         zhang    Date:         2015-7-31    """    a = [0,0,0,0]    for i in range(0,len(j)):        a[i%4] ^= ord(j[i])    w = ["EC","OK"]    d = [0,0,0,0]    d[0] = int(b) >> 24 & 255 ^ ord(w[0][0])    d[1] = int(b) >> 16 & 255 ^ ord(w[0][1])    d[2] = int(b) >> 8 & 255 ^ ord(w[1][0])    d[3] = int(b) & 255 ^ ord(w[1][1])    w = [0,0,0,0,0,0,0,0]    for i in range(0,8):        if i%2 == 0:            w[i] = a[i>>1]        else:            w[i] = d[i>>1]    a = ["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"]    d = ""    for i in range(0,len(w)):        d += a[w[i]>>4&15]        d += a[w[i]&15]    return d    if __name__ == "__main__":    b = "1958317603"    j = "8bb6208103fb248b333db1a17c7c688297379b614f6e48123cbee0d5d6a53160"        hashV = getHashCode(b,j)    print hashV


著作權聲明:本文為博主原創文章,未經博主允許不得轉載。

webQQ 中hash值的計算 python實現 2015年7月

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.