经常在做webqq机器人,但是最头痛的问题就是腾讯经常加一些验证串来防止robot,现在共享出最新的腾讯密码加密算法和hash
算法
hash算法
def webqq_hash(i, a): if isinstance(i, (str, unicode)): i = int(i) class b: def __init__(self, _b, i): self.s = _b or 0 self.e = i or 0 r = [i >> 24 & 255, i >> 16 & 255, i >> 8 & 255, i & 255] j = [ord(_a) for _a in a] e = [b(0, len(j) - 1)] while len(e) > 0: c = e.pop() if not (c.s >= c.e or c.s < 0 or c.e > len(j)): if c.s+1 == c.e: if (j[c.s] > j[c.e]) : l = j[c.s] j[c.s] = j[c.e] j[c.e] = l else: l = c.s J = c.e f=j[c.s] while c.s < c.e: while c.s < c.e and j[c.e]>=f: c.e -= 1 r[0] = r[0] + 3&255 if c.s < c.e: j[c.s] = j[c.e] c.s += 1 r[1] = r[1] * 13 + 43 & 255 while c.s < c.e and j[c.s] <= f: c.s += 1 r[2] = r[2] - 3 & 255 if c.s < c.e: j[c.e] = j[c.s] c.e -= 1 r[3] = (r[0] ^ r[1]^r[2]^r[3]+1) & 255 j[c.s] = f e.append(b(l, c.s-1)) e.append(b(c.s + 1, J)) j = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"] e = "" for c in range(len(r)): e += j[r[c]>>4&15] e += j[r[c]&15] return e def newhash(b,j): a=j+"password error" i="" E=[] while True: if len(i)<=len(a): i+=b if len(i)==len(a): break else: i=i[0:len(a)] break for c in range(len(i)): E.append(ord(str(i[c]))^ord(str(a[c]))) a = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"] i = "" for c in range(len(E)): i+=a[E[c] >> 4 & 15] i+= a[E[c] & 15] return i
这个算法加密出的串是获取好友列表和群列表都需要的
密码加密算法
#md5加密函数 def PCMd5(self,s): h=hashlib.md5() h.update(s) return h.hexdigest() #16进制转字符 def hex2asc(self,s): _str="".join(s.split(r'\x')) length=len(_str) data='' for i in range(0,length,2): data+=chr(int(_str[i:i+2],16)) return data
#密码加密函数 ''' v1 是 ptui_checkVC('0','!LJV','\x00\x00\x00\x00\x00\xa1\x92\x12') 第一个参数 V2 是 ptui_checkVC('0','!LJV','\x00\x00\x00\x00\x00\xa1\x92\x12') 第二个 ''' def PasswordSecret(self,password,v1,v2,md5=True): if md5==True: password=self.PCMd5(password).upper() length=len(password) temp='' for i in range(0,length,2): temp+=r'\x'+password[i:i+2] return self.PCMd5(self.PCMd5(self.hex2asc(temp)+self.hex2asc(v2)).upper()+v1).upper()
腾讯webqq最新密码加密算法,hash算法,布布扣,bubuko.com
原文地址:http://blog.csdn.net/zhujunxxxxx/article/details/36035151