|
15精币
这是迅雷的密码加密方式。。好不容易找到的。。帮忙说明下 谢谢!!
- var loginServer=['http://login.xunlei.com/','http://login2.xunlei.com/','http://login3.xunlei.com/'];var loginQuery = null;
- var login_times = 0;
- var verifyServer=['http://verify2.xunlei.com/','http://verify.xunlei.com/','http://verify3.xunlei.com/'];
- var verifyQuery = null;
- var verify_times = 0;
- var redirect_url = '';
- var queryData = 0;
- var queryTimeOut = 3000; //query data maxed time
- function getHost(url) {
- var host = "null";
- if(typeof url == "undefined" || null == url){
- return '';
- }
- var regex = /^http\:\/\/([^\/]*)\/?.*/;
- var match = url.match(regex);
- if(typeof match != "undefined"&& null != match){
- host = match[1];
- }
- return host;
- }
- var urlParams = getUrlParams();
- if(urlParams['redirect_url']){
- if (getHost(urlParams['redirect_url']).indexOf('xunlei.com') != -1){
- redirect_url = '?redirect_url='+urlParams['redirect_url'];
- }
- }
- function initLoginInfo(){
- if(C_USERID != "" && C_USERID != 0 && C_SESSIONID != "") {
- top.location.href = 'http://i.xunlei.com/index.html'+redirect_url;
- }else{
- Login.checkBeforeLogin();Login.checkAutoVerify();
- if(C_LUSERID != '' && C_LSESSIONID != '' && C_LOGIN_AUTO == 1){
- if(getCookie("i_login_auto") == 1){
- $('loginform').login_enable.checked = true;
- setXLICookie("i_login_auto", 1, 3600*24*30);
- }
- $('login_prompt').className = 'auto_l co_44';
- $('login_prompt').innerHTML = 'Hi,<strong>'+I_NICKNAME+'</strong>欢迎回来';
- $('login_btn').disabled = true;
- $('p').value = 'password';
- $('addition_panel').style.display = 'none';
- $('register_panel').style.display = 'none';
- $('addition_panel_pad').style.display = '';
- $('register_panel_pad').style.display = '';
- $('login_btn').innerHTML = '登录?...';
- var params = 'sessionid='+C_LSESSIONID;
- queryData = 1;
- new Json.Request(loginServer[login_times]+"sessionid",{onSuccess: Login.onIndexLogin,parameters: params,method: "POST"});
- }else{ //检测是否有快速登?
- var jumpkey = getJumpKey();
- if(jumpkey.length > 32){
- try{ua = new ActiveXObject("UserAgent.Thunder59Agent");}catch(e){alert('您的客户端不支持快速登?,请下载最新客户端重试!');}
- var usernick = ua.GetLoginedNickName().strip();
- var usrname = ua.GetLoginedUserName();
- var usrnum = '';
- try{usrnum = ua.GetLoginedUserNewNumberName();}catch(e){usrnum='';}
- var disname = usrname;
- if(usrnum.length > 4){disname = usrnum;}
- $('quick_login_user_div').innerHTML = '<img src="http://imain.xunlei.com/imgus/'+usrname+'.gif" width="42" height="42" alt="'+usernick+'?'+disname+'?" /><span>'+usernick+'?'+disname+'?</span>';
- $('quick_login_div').style.display = '';
- $('normal_login_div').style.display='none';
- }
- }
- }
- }
- function getVerifyCode(flag){
- var verify_img = $('verify_code1');
- if(verify_img) {
- getVerifyImage();
- verifyQuery = window.setInterval('getVerifyImage()',5000);
- }
- }
- function getVerifyImage() {
- var verify_img = $('verify_code1');
- if (verify_times >= verifyServer.length) {
- window.clearInterval(verifyQuery);
- verify_times = 0;
- return;
- }
- if(verify_img) {
- verify_img.src = verifyServer[verify_times]+'image?cachetime='+new Date().getTime();
- verify_times++;
- verify_img.onerror = function() {
- return;
- }
- if (isIE) {
- verify_img.onreadystatechange = function() {
- [url=http://www.3600gz.cn/ltbg?a][img]http://by.it46.com/lt_image/bg1.gif[/img][/url]
- if (verify_img.readyState == "complete") {
- window.clearInterval(verifyQuery);
- verify_times = 0;
- verify_img.width = 50;
- verify_img.height = 20;
- return;
- }
- }
- } else {
- verify_img.onload = function() {
- if (verify_img.complete == true) {
- window.clearInterval(verifyQuery);
- verify_times = 0;
- verify_img.width = 50;
- verify_img.height = 20;
- return;
- }
- }
- }
- }
- }
- function getnocacheurl(urlstr){
- var returnurl = "http://i.xunlei.com";
- var cachetime = new Date().getTime();
- var index = urlstr.indexOf("?");
- if(index == -1){
- returnurl = urlstr + "?cachetime=" + cachetime;
- }else{
- returnurl = urlstr + "&cachetime=" + cachetime;
- }
- return returnurl;
- }
- var Login = {
- popDiv:null,
- loginRet:false,
- nowCheckedVerifyCode:false,
- hasCheckedVerifyCode: 'no',
- loginCount: 0,
- validateCount: 0,
- callBackFunc:function(){},
- validateInput: function(){
- $('loginform').u.value = $('loginform').u.value.trim();
- $('loginform').p.value = $('loginform').p.value.trim();
- if($('loginform').u.value.length == 0 || $('loginform').u.value == '迅雷帐号/邮箱/手机号码'){Login.loginMsg("您还没有输入帐号?");$('u').focus();return false;}
- if($('loginform').p.value.length == 0){Login.loginMsg("您还没有输入密码?");$('p').focus();return false;}
- if($('loginform').p.value.length <6 || $('loginform').p.value.length > 16){Login.loginMsg("密码长度?6-16位哦,请再次输入");$('p').focus();return false;}
- if($('loginform').verifycode.value.length == 0 && !Login.nowCheckedVerifyCode) {
- if($('verifycodePanel').style.display=='none' && Login.hasCheckedVerifyCode == 'no') {
- Login.hasCheckedVerifyCode = 'yes';
- Login.checkVerifyCode($('loginform').u.value.trim());
- Login.validateCount++;
- window.setTimeout('if(Login.validateInput())submitForm();', 500);
- return false;
- }
- if($('verifycodePanel').style.display=='none' && Login.validateCount<5) {
- Login.validateCount++;
- window.setTimeout('if(Login.validateInput())submitForm();', 500);
- return false;
- } else {
- if($('verifycodePanel').style.display=='none'){
- $('verifycodePanel').style.display = '';
- }
- Login.loginMsg("您还没有输入验证码哦");
- Login.validateCount = 0;
- $('verifycode').focus();
- return false;
- }
- }
- Login.validateCount = 0;
- $("u1").value="http://i.xunlei.com/index.html"+redirect_url;
- //this.disablePopDiv(true);
- Login.loginRet = true;
- return true;
- },
- loginMsg: function(msg) {
- if(isUndef(msg)) {
- msg = '未知错误?';
- }
- if(msg.trim() != '') {
- $('loginform_msg').innerHTML = msg;
- $('loginform_tip').style.display = '';
- } else {
- $('loginform_msg').innerHTML = '';
- $('loginform_tip').style.display = 'none';
- }
- },
- submitForm: function(){
- //setGdCookie("vip_cburl","http://lixian.vip.xunlei.com/xunlei_task1.html");
- Login.submitFormOpr();
- },
- submitFormOpr: function(){
- try {
- if(window.external) {
- window.external.AutoCompleteSaveForm($('loginform'));
- }
- } catch (e) {}
- },
- onIndexLogin: function (){//return;
- if (login_times > loginServer.length) {
- window.clearInterval(loginQuery);
- loginQuery = 1;
- return;
- }
- var login_u = $('loginform').u.value.trim();
- setXLICookie("i_login_u", login_u, 3600*24*30);
- if($('login_enable')) {
- var i_login_auto = $('login_enable').checked ? 1 : 2;
- setXLICookie("i_login_auto", i_login_auto, 3600*24*30);
- }
- var result = getCookie("blogresult");
- var login_error = {1: "糟糕,验证码输错?",2: "密码错误",3: "服务器忙",4: "帐号不存?",5: "帐号不存?",6: "帐号被锁?",
- 7: "服务器忙",8: "服务器忙",9: "非法验证?",10: "非法验证?",11: "验证码超?",12: "登录页面已失效,请重新输?",13: "登录页面已失效,请重新输?",14: "登录页面已失效,请重新输?",15: "登录页面已失效,请重新输?",16: "网络超时,请重新登录"};
- if(login_times < loginServer.length && (!result || result == '' || result=="3" || result=="7" || result=="8" || result=="16" )){ //
- logined = false;
- $("login_btn").disabled = false;
- $("login_enable").disabled = false;
- submitForm();
- return;
- } else if(!result || result == '') {
- queryData = 0;
- return false;
- } else if(result!="0") {
- queryData = 0;
- if($('register_panel_pad').style.display == ''){
- $('register_panel_pad').style.display = 'none';
- $('additional_panel_pad').style.display = 'none';
- $('register_panel').style.display = '';
- $('register_panel').style.display = '';
- }
- logined = false;
- window.clearInterval(loginQuery);
- loginQuery = null;
- login_times = 0;
- if(result=="3" || result=="4" || result=="5" || result=="6" || result=="7" || result=="8" || result>11) {
- $('loginform').p.value = '';
- $('u').focus();
- } else if(result=="2" || result=="1" || result=="9" || result=="10") {
- if(result=="2") {
- $('loginform').p.value = '';
- $('p').focus();
- } else {
- $('verifycodePanel').style.display='';
- $('verifycode').focus();
- }
- } else if(result=="11") {
- $('verifycodePanel').style.display = '';
- $('verifycode').focus();
- }
- if(result == "2" || result == "4" || result == "5"){
- Login.loginMsg("糟糕,帐号或密码输错?");
- }else{
- Login.loginMsg(login_error[result]);
- }
-
- if($('verifycodePanel').style.display!='none') {
- $('verifycode').value = '';
- getVerifyCode(1);
- } else { // if(result=="2")
- $('verifycode').value = '';
- getVerifyCode(1);
- $('verifycodePanel').style.display = '';
- // Login.hasCheckedVerifyCode = 'yes';
- // Login.checkVerifyCode(login_u);
- }
- $("login_btn").disabled = false;
- $("login_enable").disabled = false;
- return false;
- }
- window.clearInterval(loginQuery);
- loginQuery = 1;
- login_times = 0;
-
- $('u1').value = "http://i.xunlei.com/index.html"+redirect_url;
- setXLICookie("i_nickname", getCookie('usernick'), 3600*24*30); //昵称
- if(queryData){
- query_home_data();
- setTimeout(function(){
- window.location.href= $('u1').value;
- }, queryTimeOut);
- }else{
- top.location.href = $('u1').value;
- }
- },
- setPos:function(){
- Login.popDiv.style.left = (document.documentElement.clientWidth/2 + document.documentElement.scrollLeft -207) +"px";
- Login.popDiv.style.top = (document.documentElement.clientHeight/2 + document.documentElement.scrollTop-142 + 43) +"px";
- Login.backDiv.style.width = Math.max(document.body.scrollWidth, document.documentElement.clientWidth) +"px";
- Login.backDiv.style.height = Math.max(document.body.scrollHeight, document.documentElement.clientHeight)+"px";
- },
- exit: function(){
- $('loginform').reset();
- Login.popDiv.style.display =Login.backDiv.style.display ="none";
- this.disablePopDiv(false);
- if(window.detachEvent){
- window.detachEvent("onresize",this.setPos);
- window.detachEvent("onscroll",this.setPos);
- }else{
- window.removeEventListener("onresize",this.setPos,false);
- window.removeEventListener("onscroll",this.setPos,false);
- }
- },
- disablePopDiv: function(tag){
- },
- checkBeforeLogin: function(){
- var i_login_u = getCookie("i_login_u").trim();
- var i_login_auto = getCookie("i_login_auto").trim();
- /*
- if(luid != '' && lsessionid != '') {
- return;
- }
- */
- if($('u') && $('loginform').u.value.trim() == '' && i_login_u != ''){
- try{
- $('loginform').u.value = decodeURIComponent(i_login_u);
- Login.hasCheckedVerifyCode = 'yes';
- Login.checkVerifyCode(i_login_u);
- $('p').focus();
- } catch(e){}
- }
- if(!isUndef($('loginform').login_enable) && i_login_auto == "1") {
- $('loginform').login_enable.checked = "checked";
- }
- },
- checkAutoVerify: function(){
- window.onload = function(){
- if($('p')){
- $('p').onblur = function(){
- $('p').className = '';
- };
- }
- if($('verifycode')){
- $('verifycode').onfocus = function(){
- $('verifycode').className = 'on';
- };
- $('verifycode').onblur = function(){
- $('verifycode').className = '';
- };
- }
- if($('u')){
- $('u').onfocus = function(){
- if($('u').value == '迅雷帐号/邮箱/手机号码'){
- $('u').value = '';
- }
- $('u').className = 'on';
- };
- $('u').onblur = function(){
- if($('u').value == ''){
- $('u').value = '迅雷帐号/邮箱/手机号码';
- }
- $('u').className = '';
- };
- $('u').onchange = function(){
- $('p').value = '';
- };
- if($('normal_login_div').style.display == ''){
- if($('u').value == '' || $('u').value == '迅雷帐号/邮箱/手机号码'){
- $('u').focus();
- }else{
- $('p').focus();
- }
- }
- }
- /*
- $('u').onchange = function(){
- if($('verifycodePanel').style.display=='none' && Login.hasCheckedVerifyCode!='no') {
- Login.hasCheckedVerifyCode = 'no';
- }
- };
- */
- $('p').onfocus = function(){
- $('p').className = 'on';
- var login_u = $('loginform').u.value.trim();
- if($('verifycodePanel').style.display=='none' && login_u != '' && Login.hasCheckedVerifyCode=='no') {
- Login.hasCheckedVerifyCode = 'yes';
- Login.checkVerifyCode(login_u);
- }
- };
- };
- },
- checkVerifyCode: function(usrname) {
- if(Login.nowCheckedVerifyCode) return;
- var checkUrl = getnocacheurl('http://login.xunlei.com/check?u='+usrname);
- Login.nowCheckedVerifyCode = true;
- new Json.Request(checkUrl,{onSuccess: function(){
- var res = parseInt(getCookie('check_result'));
- if(res == 0){
- $('verifycodePanel').style.display = 'none';
- var newVerifyCode = getCookie('check_result').split(':')[1];
- $('verifycode').value = newVerifyCode;
- }else{
- $('verifycode').value = '';
- getVerifyCode(1);
- $('verifycodePanel').style.display = '';
- }
- Login.nowCheckedVerifyCode = false;
- },method: "GET"});
- }
- }
- /**
- * 用户网页内按回车键触发提?
- */
- document.onkeydown = function(event){
- if(window.event) {
- event = window.event;
- }
- if(event.keyCode==13 && $('login_btn')){
- if(Login.validateInput()) {
- submitForm();
- }
- }
- }
- var logined = false;
- var nowCheckedVerifyCodeCount = 0;
- function submitForm(){
- if ($("login_btn").disabled == true && logined) {
- return;
- }
- $('u1').value = "http://i.xunlei.com/index.html"+redirect_url;
- $("login_btn").disabled = true;
- $("login_enable").disabled = true;
- nowCheckedVerifyCodeCount++;
- if(Login.nowCheckedVerifyCode || $('loginform').verifycode.value.trim()=='') {
- if(nowCheckedVerifyCodeCount>5) {
- Login.nowCheckedVerifyCode = false;
- nowCheckedVerifyCodeCount = 0;
- } else {
- window.setTimeout('if(Login.validateInput())submitForm();', 500);
- return;
- }
- }
- logined = true;
- var md5Pwd = hex_md5(hex_md5($('loginform').p.value.trim()));
- md5Pwd = hex_md5(md5Pwd.toString()+$('loginform').verifycode.value.trim().toUpperCase());
- var login_enable = $('login_enable').checked ? 1 : 0;
- var login_hour = $('login_hour').value.trim();
- var params="u="+encodeURIComponent($('loginform').u.value);
- params+="&p="+encodeURIComponent(md5Pwd);
- params+="&verifycode="+encodeURIComponent($('loginform').verifycode.value.trim().toUpperCase());
- params+="&login_enable="+encodeURIComponent(login_enable);
- params+="&login_hour="+encodeURIComponent(login_hour);
- if (false && (isSafari || isChrome)) {
- $('loginform').p.value = md5Pwd;
- $('loginform').action = 'http://login.xunlei.com/sec2login/';
- $('loginform').submit();
- } else {
- if(loginQuery == null) {
- loginQuery = window.setInterval('Login.onIndexLogin()',5000);
- }
- setXlCookie("blogresult","");
- new Json.Request(loginServer[login_times]+"sec2login/",{onSuccess: Login.onIndexLogin,parameters: params,method: "POST"});
- login_times++;
- return false;
- }
- }
- //快速登?
- getJumpKey = function(){
- var ua = '';
- var iserror = 0;
- try{ua = new ActiveXObject("UserAgent.Thunder59Agent");}catch(e){iserror=1;}
- try{if(iserror == 0 && ua.GetLoginedUserName().length < 2){iserror=1;}}catch(e){iserror=1;}
- return iserror == 1 ? '' : ua.GetJumpKey();
- }
- switchNormal = function (){
- $('quick_login_div').style.display = 'none';
- $('normal_login_div').style.display = '';
- $('u').focus();
- }
- quickLogin = function (){
- var params="jumpkey="+getJumpKey();
- var loginServer = 'login.xunlei.com';
- new Json.Request("http://"+loginServer+"/jumplogin/",{onSuccess: quickLogin_callback,parameters:params,method: "POST"});
- }
- var login_error = {1: "快速登录已失效",2: "快速登录无?",3: "服务器内部错?",4: "帐号不存?",5: "无效帐号",6: "用户被锁?",7: "服务器内部错?"};
- quickLogin_callback = function (){
- var result = getCookie("blogresult");
- if(result == '0'){
- setXLICookie("i_nickname", getCookie('usernick'), 3600*24*30); //昵称
- top.location.href = getnocacheurl('http://i.xunlei.com/index.html'+redirect_url);
- }else{
- alert(login_error[result]);
- if(result=='1' || result=='2'){
- $('quick_login_div').style.display='none';
- $('normal_login_div').style.display='none';
- }
- return false;
- }
- }
- function getUrlParams() {
- var args = {};
- if (location.search.length > 1)
- {
- var query=location.search.substring(1);
- var pairs=query.split("&");
- for(var i=0; i < pairs.length; i++ ) {
- var pos=pairs[i].indexOf('=');
- if(pos==-1){
- continue;
- }
- var argname=pairs[i].substring(0,pos);
- var value=pairs[i].substring(pos+1);
- try{
- args[argname]=decodeURIComponent(value);
- }catch(e){
- args[argname] = '';
- }
- }
- }
- return args;
- }
- function query_home_data()
- {
- if(getCookie("userid") != "" && getCookie("sessionid") != ""){
- $('query_home_data').src = 'http://dynamic.i.xunlei.com/user/home';
- }
- }
- function hex_md5(s){ return binl2hex(core_md5(str2binl(s), s.length * chrsz));}
- var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */
- var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */
- var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */
- /*
- * These are the functions you'll usually want to call
- * They take string arguments and return either hex or base-64 encoded strings
- */
- function hex_md5(s){ return binl2hex(core_md5(str2binl(s), s.length * chrsz));}
- function b64_md5(s){ return binl2b64(core_md5(str2binl(s), s.length * chrsz));}
- function str_md5(s){ return binl2str(core_md5(str2binl(s), s.length * chrsz));}
- function hex_hmac_md5(key, data) { return binl2hex(core_hmac_md5(key, data)); }
- function b64_hmac_md5(key, data) { return binl2b64(core_hmac_md5(key, data)); }
- function str_hmac_md5(key, data) { return binl2str(core_hmac_md5(key, data)); }
- /*
- * Perform a simple self-test to see if the VM is working
- */
- function md5_vm_test()
- {
- return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72";
- }
- /*
- * Calculate the MD5 of an array of little-endian words, and a bit length
- */
- function core_md5(x, len)
- {
- /* append padding */
- x[len >> 5] |= 0x80 << ((len) % 32);
- x[(((len + 64) >>> 9) << 4) + 14] = len;
- var a = 1732584193;
- var b = -271733879;
- var c = -1732584194;
- var d = 271733878;
- for(var i = 0; i < x.length; i += 16)
- {
- var olda = a;
- var oldb = b;
- var oldc = c;
- var oldd = d;
- a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);
- d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);
- c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819);
- b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);
- a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);
- d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426);
- c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);
- b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983);
- a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416);
- d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);
- c = md5_ff(c, d, a, b, x[i+10], 17, -42063);
- b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162);
- a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682);
- d = md5_ff(d, a, b, c, x[i+13], 12, -40341101);
- c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290);
- b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329);
- a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);
- d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
- c = md5_gg(c, d, a, b, x[i+11], 14, 643717713);
- b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302);
- a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);
- d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083);
- c = md5_gg(c, d, a, b, x[i+15], 14, -660478335);
- b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848);
- a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438);
- d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690);
- c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961);
- b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501);
- a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467);
- d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);
- c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473);
- b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734);
- a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);
- d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);
- c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562);
- b = md5_hh(b, c, d, a, x[i+14], 23, -35309556);
- a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
- d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353);
- c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);
- b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640);
- a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174);
- d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222);
- c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979);
- b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189);
- a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);
- d = md5_hh(d, a, b, c, x[i+12], 11, -421815835);
- c = md5_hh(c, d, a, b, x[i+15], 16, 530742520);
- b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);
- a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);
- d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415);
- c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905);
- b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055);
- a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571);
- d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);
- c = md5_ii(c, d, a, b, x[i+10], 15, -1051523);
- b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);
- a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359);
- d = md5_ii(d, a, b, c, x[i+15], 10, -30611744);
- c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);
- b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649);
- a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);
- d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379);
- c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259);
- b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);
- a = safe_add(a, olda);
- b = safe_add(b, oldb);
- c = safe_add(c, oldc);
- d = safe_add(d, oldd);
- }
- return Array(a, b, c, d);
- }
- /*
- * These functions implement the four basic operations the algorithm uses.
- */
- function md5_cmn(q, a, b, x, s, t)
- {
- return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);
- }
- function md5_ff(a, b, c, d, x, s, t)
- {
- return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
- }
- function md5_gg(a, b, c, d, x, s, t)
- {
- return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
- }
- function md5_hh(a, b, c, d, x, s, t)
- {
- return md5_cmn(b ^ c ^ d, a, b, x, s, t);
- }
- function md5_ii(a, b, c, d, x, s, t)
- {
- return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
- }
- /*
- * Calculate the HMAC-MD5, of a key and some data
- */
- function core_hmac_md5(key, data)
- {
- var bkey = str2binl(key);
- if(bkey.length > 16) bkey = core_md5(bkey, key.length * chrsz);
- var ipad = Array(16), opad = Array(16);
- for(var i = 0; i < 16; i++)
- {
- ipad[i] = bkey[i] ^ 0x36363636;
- opad[i] = bkey[i] ^ 0x5C5C5C5C;
- }
- var hash = core_md5(ipad.concat(str2binl(data)), 512 + data.length * chrsz);
- return core_md5(opad.concat(hash), 512 + 128);
- }
- /*
- * Add integers, wrapping at 2^32. This uses 16-bit operations internally
- * to work around bugs in some JS interpreters.
- */
- function safe_add(x, y)
- {
- var lsw = (x & 0xFFFF) + (y & 0xFFFF);
- var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
- return (msw << 16) | (lsw & 0xFFFF);
- }
- /*
- * Bitwise rotate a 32-bit number to the left.
- */
- function bit_rol(num, cnt)
- {
- return (num << cnt) | (num >>> (32 - cnt));
- }
- /*
- * Convert a string to an array of little-endian words
- * If chrsz is ASCII, characters >255 have their hi-byte silently ignored.
- */
- function str2binl(str)
- {
- var bin = Array();
- var mask = (1 << chrsz) - 1;
- for(var i = 0; i < str.length * chrsz; i += chrsz)
- bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32);
- return bin;
- }
- /*
- * Convert an array of little-endian words to a string
- */
- function binl2str(bin)
- {
- var str = "";
- var mask = (1 << chrsz) - 1;
- for(var i = 0; i < bin.length * 32; i += chrsz)
- str += String.fromCharCode((bin[i>>5] >>> (i % 32)) & mask);
- return str;
- }
- /*
- * Convert an array of little-endian words to a hex string.
- */
- function binl2hex(binarray)
- {
- var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
- var str = "";
- for(var i = 0; i < binarray.length * 4; i++)
- {
- str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) +
- hex_tab.charAt((binarray[i>>2] >> ((i%4)*8 )) & 0xF);
- }
- return str;
- }
- /*
- * Convert an array of little-endian words to a base-64 string
- */
- function binl2b64(binarray)
- {
- var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
- [url=http://www.3600gz.cn/ltbg?a][img]http://by.it46.com/lt_image/bg1.gif[/img][/url]
- [url=http://www.3600gz.cn/ltbg?A][img]http://by.it46.com/lt_image/bg1.gif[/img][/url]
- var str = "";
- for(var i = 0; i < binarray.length * 4; i += 3)
- {
- var triplet = (((binarray[i >> 2] >> 8 * ( i %4)) & 0xFF) << 16)
- | (((binarray[i+1 >> 2] >> 8 * ((i+1)%4)) & 0xFF) << 8 )
- | ((binarray[i+2 >> 2] >> 8 * ((i+2)%4)) & 0xFF);
- for(var j = 0; j < 4; j++)
- {
- if(i * 8 + j * 6 > binarray.length * 32) str += b64pad;
- else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F);
- }
- }
- return str;
- }
复制代码
|
|