-
-
Save est/974102f3aaff88d332b5 to your computer and use it in GitHub Desktop.
webqq ptwebqq hash implemented in Python & Javascript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
u = function(x, K) { | |
x += ""; | |
for (var N = [], T = 0; T < K.length; T++) | |
N[T % 4] ^= K.charCodeAt(T); | |
var U = ["EC", "OK"], V = []; | |
V[0] = x >> 24 & 255 ^ U[0].charCodeAt(0); | |
V[1] = x >> 16 & 255 ^ U[0].charCodeAt(1); | |
V[2] = x >> 8 & 255 ^ U[1].charCodeAt(0); | |
V[3] = x & 255 ^ U[1].charCodeAt(1); | |
U = []; | |
for (T = 0; T < 8; T++) | |
U[T] = T % 2 == 0 ? N[T >> 1] : V[T >> 1]; | |
N = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"]; | |
V = ""; | |
for (T = 0; T < U.length; T++) { | |
V += N[U[T] >> 4 & 15]; | |
V += N[U[T] & 15] | |
} | |
return V | |
} | |
/* source: http://pub.idqqimg.com/smartqq/js/mq.js | |
test in your browser, login to w.qq.com, open console | |
u(mq.presenter.buddylist.model.getSelfUin(), mq.ptwebqq) | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def hash_func(uin, ptwebqq): | |
V = struct.pack('!I', int(uin) & 0xFFFFFFFF ^ 1162039115) | |
N = [0] * 4 | |
for i, c in enumerate(ptwebqq): | |
N[i % 4] ^= ord(c) | |
return ''.join('%02x%02x' % l for l in zip(N, map(ord, V))) | |
## alternative python implementation https://github.com/yuhua6379/webqq/blob/master/login_new.py#L43 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment