Code Bye

HttpClient 58同城登录加密的js

关于登录部分的代码太长了,所以决定 把js部分分离开来,本来想把加密的js,上传到下载的,不过想想,这样太坑爹了了,本来就一个简单的js,还去片积分,太不像话了,下面就具体来讲讲58同城登录部分的加密和相关加密的技术:

58同城的登录,一共采用了2中加密方式,第一种加密方式,是58同城自己的,另外一种加密技术,叫做rsa加密:

下面先把第一部分的加密的js,贴出来:(加密的方法,在我的另外一篇文中里面有提及,可以去我的博客主页看看)

var hexcase = 0;
var b64pad = “”;
var chrsz = 8;
function hex_md5(a) {
return binl2hex(core_md5(str2binl(a), a.length * chrsz));
}
function b64_md5(a) {
return binl2b64(core_md5(str2binl(a), a.length * chrsz));
}
function hex_hmac_md5(a, c) {
return binl2hex(core_hmac_md5(a, c));
}
function b64_hmac_md5(a, c) {
return binl2b64(core_hmac_md5(a, c));
}
function calcMD5(a) {
return binl2hex(core_md5(str2binl(a), a.length * chrsz));
}
function hex_md5_16(c) {
var a = hex_md5(c);
a = a.substring(8, 24);
return reverse(a);
}
function core_md5(r, k) {
r[k >> 5] |= 128 << ((k) % 32);
r[(((k + 64) >>> 9) << 4) + 14] = k;
var q = 1732584193;
var p = -271733879;
var m = -1732584194;
var l = 271733878;
for (var g = 0; g < r.length; g += 16) {
var j = q;
var h = p;
var f = m;
var e = l;
q = md5_ff(q, p, m, l, r[g + 0], 7, -680876936);
l = md5_ff(l, q, p, m, r[g + 1], 12, -389564586);
m = md5_ff(m, l, q, p, r[g + 2], 17, 606105819);
p = md5_ff(p, m, l, q, r[g + 3], 22, -1044525330);
q = md5_ff(q, p, m, l, r[g + 4], 7, -176418897);
l = md5_ff(l, q, p, m, r[g + 5], 12, 1200080426);
m = md5_ff(m, l, q, p, r[g + 6], 17, -1473231341);
p = md5_ff(p, m, l, q, r[g + 7], 22, -45705983);
q = md5_ff(q, p, m, l, r[g + 8], 7, 1770035416);
l = md5_ff(l, q, p, m, r[g + 9], 12, -1958414417);
m = md5_ff(m, l, q, p, r[g + 10], 17, -42063);
p = md5_ff(p, m, l, q, r[g + 11], 22, -1990404162);
q = md5_ff(q, p, m, l, r[g + 12], 7, 1804603682);
l = md5_ff(l, q, p, m, r[g + 13], 12, -40341101);
m = md5_ff(m, l, q, p, r[g + 14], 17, -1502002290);
p = md5_ff(p, m, l, q, r[g + 15], 22, 1236535329);
q = md5_gg(q, p, m, l, r[g + 1], 5, -165796510);
l = md5_gg(l, q, p, m, r[g + 6], 9, -1069501632);
m = md5_gg(m, l, q, p, r[g + 11], 14, 643717713);
p = md5_gg(p, m, l, q, r[g + 0], 20, -373897302);
q = md5_gg(q, p, m, l, r[g + 5], 5, -701558691);
l = md5_gg(l, q, p, m, r[g + 10], 9, 38016083);
m = md5_gg(m, l, q, p, r[g + 15], 14, -660478335);
p = md5_gg(p, m, l, q, r[g + 4], 20, -405537848);
q = md5_gg(q, p, m, l, r[g + 9], 5, 568446438);
l = md5_gg(l, q, p, m, r[g + 14], 9, -1019803690);
m = md5_gg(m, l, q, p, r[g + 3], 14, -187363961);
p = md5_gg(p, m, l, q, r[g + 8], 20, 1163531501);
q = md5_gg(q, p, m, l, r[g + 13], 5, -1444681467);
l = md5_gg(l, q, p, m, r[g + 2], 9, -51403784);
m = md5_gg(m, l, q, p, r[g + 7], 14, 1735328473);
p = md5_gg(p, m, l, q, r[g + 12], 20, -1926607734);
q = md5_hh(q, p, m, l, r[g + 5], 4, -378558);
l = md5_hh(l, q, p, m, r[g + 8], 11, -2022574463);
m = md5_hh(m, l, q, p, r[g + 11], 16, 1839030562);
p = md5_hh(p, m, l, q, r[g + 14], 23, -35309556);
q = md5_hh(q, p, m, l, r[g + 1], 4, -1530992060);
l = md5_hh(l, q, p, m, r[g + 4], 11, 1272893353);
m = md5_hh(m, l, q, p, r[g + 7], 16, -155497632);
p = md5_hh(p, m, l, q, r[g + 10], 23, -1094730640);
q = md5_hh(q, p, m, l, r[g + 13], 4, 681279174);
l = md5_hh(l, q, p, m, r[g + 0], 11, -358537222);
m = md5_hh(m, l, q, p, r[g + 3], 16, -722521979);
p = md5_hh(p, m, l, q, r[g + 6], 23, 76029189);
q = md5_hh(q, p, m, l, r[g + 9], 4, -640364487);
l = md5_hh(l, q, p, m, r[g + 12], 11, -421815835);
m = md5_hh(m, l, q, p, r[g + 15], 16, 530742520);
p = md5_hh(p, m, l, q, r[g + 2], 23, -995338651);
q = md5_ii(q, p, m, l, r[g + 0], 6, -198630844);
l = md5_ii(l, q, p, m, r[g + 7], 10, 1126891415);
m = md5_ii(m, l, q, p, r[g + 14], 15, -1416354905);
p = md5_ii(p, m, l, q, r[g + 5], 21, -57434055);
q = md5_ii(q, p, m, l, r[g + 12], 6, 1700485571);
l = md5_ii(l, q, p, m, r[g + 3], 10, -1894986606);
m = md5_ii(m, l, q, p, r[g + 10], 15, -1051523);
p = md5_ii(p, m, l, q, r[g + 1], 21, -2054922799);
q = md5_ii(q, p, m, l, r[g + 8], 6, 1873313359);
l = md5_ii(l, q, p, m, r[g + 15], 10, -30611744);
m = md5_ii(m, l, q, p, r[g + 6], 15, -1560198380);
p = md5_ii(p, m, l, q, r[g + 13], 21, 1309151649);
q = md5_ii(q, p, m, l, r[g + 4], 6, -145523070);
l = md5_ii(l, q, p, m, r[g + 11], 10, -1120210379);
m = md5_ii(m, l, q, p, r[g + 2], 15, 718787259);
p = md5_ii(p, m, l, q, r[g + 9], 21, -343485551);
q = safe_add(q, j);
p = safe_add(p, h);
m = safe_add(m, f);
l = safe_add(l, e);
}
return Array(q, p, m, l);
}
function md5_cmn(h, e, d, c, g, f) {
return safe_add(bit_rol(safe_add(safe_add(e, h), safe_add(c, f)), g), d);
}
function md5_ff(g, f, l, k, e, j, h) {
return md5_cmn((f & l) | ((~f) & k), g, f, e, j, h);
}
function md5_gg(g, f, l, k, e, j, h) {
return md5_cmn((f & k) | (l & (~k)), g, f, e, j, h);
}
function md5_hh(g, f, l, k, e, j, h) {
return md5_cmn(f ^ l ^ k, g, f, e, j, h);
}
function md5_ii(g, f, l, k, e, j, h) {
return md5_cmn(l ^ (f | (~k)), g, f, e, j, h);
}
function core_hmac_md5(d, g) {
var f = str2binl(d);
if (f.length > 16) {
f = core_md5(f, d.length * chrsz);
}
var a = Array(16),
e = Array(16);
for (var c = 0; c < 16; c++) {
a[c] = f[c] ^ 909522486;
e[c] = f[c] ^ 1549556828;
}
var h = core_md5(a.concat(str2binl(g)), 512 + g.length * chrsz);
return core_md5(e.concat(h), 512 + 128);
}
function safe_add(a, e) {
var d = (a & 65535) + (e & 65535);
var c = (a >> 16) + (e >> 16) + (d >> 16);
return (c << 16) | (d & 65535);
}
function bit_rol(a, c) {
return (a << c) | (a >>> (32 – c));
}
function str2binl(e) {
var d = Array();
var a = (1 << chrsz) – 1;
for (var c = 0; c < e.length * chrsz; c += chrsz) {
d[c >> 5] |= (e.charCodeAt(c / chrsz) & a) << (c % 32);
}
return d;
}
function binl2hex(d) {
var c = hexcase ? “0123456789ABCDEF”: “0123456789abcdef”;
var e = “”;
for (var a = 0; a < d.length * 4; a++) {
e += c.charAt((d[a >> 2] >> ((a % 4) * 8 + 4)) & 15) + c.charAt((d[a >> 2] >> ((a % 4) * 8)) & 15);
}
return e;
}
function binl2b64(e) {
var d = “ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/”;
var g = “”;
for (var c = 0; c < e.length * 4; c += 3) {
var f = (((e[c >> 2] >> 8 * (c % 4)) & 255) << 16) | (((e[c + 1 >> 2] >> 8 * ((c + 1) % 4)) & 255) << 8) | ((e[c + 2 >> 2] >> 8 * ((c + 2) % 4)) & 255);
for (var a = 0; a < 4; a++) {
if (c * 8 + a * 6 > e.length * 32) {
g += b64pad;
} else {
g += d.charAt((f >> 6 * (3 – a)) & 63);
}
}
}
return g;
}
function reverse(d) {
var a = “”;
for (var c = d.length – 1; c >= 0; c–) {
a += d.charAt(c);
}
return a;
}
function getm32str(c, a) {
if (a.length != 13) {
alert(“timesign error !!!”);
return “”;
}
return hex_md5(hex_md5(c) + a.substring(5, 11));
}
function getm16str(c, a) {
if (a.length != 13) {
alert(“timesign error !!!”);
return “”;
}
return hex_md5(hex_md5_16(c) + a.substring(5, 11));
}

没做整理,所以贴完代码后,总觉得,乱七八糟的,谅解一下了

第二种,加密,叫rsa加密算法,很多网站都采用了这个加密算法,比如起点小说网,盛大游戏网等等等等,这个主题代码太多了,我就上传个附件吧

大家去这个网址下载:(rsa.pack.js):

http://download.csdn.net/detail/hu474676693/8660613

好了,大家有啥问题,可以给我留言,加密算法有啥难度,也可以联系我啊

转自 http://blog.csdn.net/hu474676693/article/details/45483715


CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明HttpClient 58同城登录加密的js