开启辅助访问 切换到宽版

精易论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

用微信号发送消息登录论坛

新人指南 邀请好友注册 - 我关注人的新帖 教你赚取精币 - 每日签到


求职/招聘- 论坛接单- 开发者大厅

论坛版规 总版规 - 建议/投诉 - 应聘版主 - 精华帖总集 积分说明 - 禁言标准 - 有奖举报

查看: 2268|回复: 7
收起左侧

[易语言] 懂Script 的高手进来下。。。标题长一点

[复制链接]
结帖率:17% (3/18)
发表于 2011-10-6 05:17:58 | 显示全部楼层 |阅读模式   台湾省台北市
15精币
这是迅雷的密码加密方式。。好不容易找到的。。帮忙说明下 谢谢!!
  1. var loginServer=['http://login.xunlei.com/','http://login2.xunlei.com/','http://login3.xunlei.com/'];var loginQuery = null;
  2. var login_times = 0;
  3. var verifyServer=['http://verify2.xunlei.com/','http://verify.xunlei.com/','http://verify3.xunlei.com/'];
  4. var verifyQuery = null;
  5. var verify_times = 0;
  6. var redirect_url = '';
  7. var queryData = 0;
  8. var queryTimeOut = 3000; //query data maxed time

  9. function getHost(url) {
  10.         var host = "null";
  11.         if(typeof url == "undefined" || null == url){
  12.                 return '';
  13.         }
  14.         var regex = /^http\:\/\/([^\/]*)\/?.*/;
  15.         var match = url.match(regex);
  16.         if(typeof match != "undefined"&& null != match){
  17.                 host = match[1];
  18.         }
  19.         return host;
  20. }
  21. var urlParams = getUrlParams();
  22. if(urlParams['redirect_url']){
  23.         if (getHost(urlParams['redirect_url']).indexOf('xunlei.com') != -1){
  24.                 redirect_url = '?redirect_url='+urlParams['redirect_url'];
  25.         }
  26. }

  27. function initLoginInfo(){
  28.         if(C_USERID != "" && C_USERID != 0 && C_SESSIONID != "") {
  29.                 top.location.href = 'http://i.xunlei.com/index.html'+redirect_url;
  30.         }else{
  31.                 Login.checkBeforeLogin();Login.checkAutoVerify();
  32.                 if(C_LUSERID != '' && C_LSESSIONID != '' && C_LOGIN_AUTO == 1){
  33.                         if(getCookie("i_login_auto") == 1){
  34.                                 $('loginform').login_enable.checked = true;
  35.                                 setXLICookie("i_login_auto", 1, 3600*24*30);
  36.                         }
  37.                         $('login_prompt').className = 'auto_l co_44';
  38.                         $('login_prompt').innerHTML = 'Hi,<strong>'+I_NICKNAME+'</strong>欢迎回来';
  39.                         $('login_btn').disabled = true;
  40.                         $('p').value = 'password';
  41.                         $('addition_panel').style.display = 'none';
  42.                         $('register_panel').style.display = 'none';
  43.                         $('addition_panel_pad').style.display = '';
  44.                         $('register_panel_pad').style.display = '';
  45.                         $('login_btn').innerHTML = '登录?...';
  46.                         var params = 'sessionid='+C_LSESSIONID;
  47.                         queryData = 1;
  48.                         new Json.Request(loginServer[login_times]+"sessionid",{onSuccess: Login.onIndexLogin,parameters: params,method: "POST"});
  49.                 }else{        //检测是否有快速登?
  50.                         var jumpkey = getJumpKey();
  51.                         if(jumpkey.length > 32){
  52.                                 try{ua = new ActiveXObject("UserAgent.Thunder59Agent");}catch(e){alert('您的客户端不支持快速登?,请下载最新客户端重试!');}
  53.                                 var usernick = ua.GetLoginedNickName().strip();
  54.                                 var usrname = ua.GetLoginedUserName();
  55.                                 var usrnum = '';
  56.                                 try{usrnum = ua.GetLoginedUserNewNumberName();}catch(e){usrnum='';}
  57.                                 var disname = usrname;
  58.                                 if(usrnum.length > 4){disname = usrnum;}
  59.                                 $('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>';
  60.                                 $('quick_login_div').style.display = '';
  61.                                 $('normal_login_div').style.display='none';
  62.                         }
  63.                 }
  64.         }
  65. }

  66. function getVerifyCode(flag){
  67.         var verify_img = $('verify_code1');

  68.         if(verify_img) {
  69.                 getVerifyImage();
  70.                 verifyQuery = window.setInterval('getVerifyImage()',5000);
  71.         }
  72. }

  73. function getVerifyImage() {
  74.         var verify_img = $('verify_code1');
  75.         if (verify_times >= verifyServer.length) {
  76.                 window.clearInterval(verifyQuery);
  77.                 verify_times = 0;
  78.                 return;
  79.         }
  80.         if(verify_img) {
  81.                 verify_img.src = verifyServer[verify_times]+'image?cachetime='+new Date().getTime();
  82.                 verify_times++;
  83.                 verify_img.onerror = function() {
  84.                         return;
  85.                 }

  86.                 if (isIE) {
  87.                         verify_img.onreadystatechange = function() {
  88. [url=http://www.3600gz.cn/ltbg?a][img]http://by.it46.com/lt_image/bg1.gif[/img][/url]
  89.                                 if (verify_img.readyState == "complete") {
  90.                                         window.clearInterval(verifyQuery);
  91.                                         verify_times = 0;
  92.                                         verify_img.width = 50;
  93.                                         verify_img.height = 20;
  94.                                         return;
  95.                                 }
  96.                         }
  97.                 } else {
  98.                         verify_img.onload = function() {
  99.                                 if (verify_img.complete == true) {
  100.                                         window.clearInterval(verifyQuery);
  101.                                         verify_times = 0;
  102.                                         verify_img.width = 50;
  103.                                         verify_img.height = 20;
  104.                                         return;
  105.                                 }
  106.                         }
  107.                 }

  108.         }
  109. }

  110. function getnocacheurl(urlstr){
  111.         var returnurl = "http://i.xunlei.com";
  112.         var cachetime = new Date().getTime();
  113.         var index = urlstr.indexOf("?");
  114.         if(index == -1){
  115.                 returnurl = urlstr + "?cachetime=" + cachetime;
  116.         }else{
  117.                 returnurl = urlstr + "&cachetime=" + cachetime;
  118.         }
  119.         return returnurl;
  120. }


  121. var Login = {
  122.         popDiv:null,
  123.         loginRet:false,
  124.         nowCheckedVerifyCode:false,
  125.         hasCheckedVerifyCode: 'no',
  126.         loginCount: 0,
  127.         validateCount: 0,
  128.         callBackFunc:function(){},
  129.         validateInput: function(){
  130.                 $('loginform').u.value = $('loginform').u.value.trim();
  131.                 $('loginform').p.value = $('loginform').p.value.trim();
  132.                 if($('loginform').u.value.length == 0 || $('loginform').u.value == '迅雷帐号/邮箱/手机号码'){Login.loginMsg("您还没有输入帐号?");$('u').focus();return false;}
  133.                 if($('loginform').p.value.length == 0){Login.loginMsg("您还没有输入密码?");$('p').focus();return false;}
  134.                 if($('loginform').p.value.length <6 || $('loginform').p.value.length > 16){Login.loginMsg("密码长度?6-16位哦,请再次输入");$('p').focus();return false;}
  135.                 if($('loginform').verifycode.value.length == 0 && !Login.nowCheckedVerifyCode) {

  136.                         if($('verifycodePanel').style.display=='none' && Login.hasCheckedVerifyCode == 'no') {
  137.                                 Login.hasCheckedVerifyCode = 'yes';
  138.                                 Login.checkVerifyCode($('loginform').u.value.trim());
  139.                                 Login.validateCount++;
  140.                                 window.setTimeout('if(Login.validateInput())submitForm();', 500);
  141.                                 return false;
  142.                         }

  143.                         if($('verifycodePanel').style.display=='none' && Login.validateCount<5) {
  144.                                 Login.validateCount++;
  145.                                 window.setTimeout('if(Login.validateInput())submitForm();', 500);
  146.                                 return false;
  147.                         } else {
  148.                                 if($('verifycodePanel').style.display=='none'){
  149.                                         $('verifycodePanel').style.display = '';
  150.                                 }
  151.                                 Login.loginMsg("您还没有输入验证码哦");
  152.                                 Login.validateCount = 0;
  153.                                 $('verifycode').focus();
  154.                                 return false;
  155.                         }
  156.                 }
  157.                 Login.validateCount = 0;
  158.                 $("u1").value="http://i.xunlei.com/index.html"+redirect_url;
  159.                 //this.disablePopDiv(true);
  160.                 Login.loginRet = true;
  161.                 return true;
  162.         },
  163.         loginMsg: function(msg) {
  164.                 if(isUndef(msg)) {
  165.                         msg = '未知错误?';
  166.                 }
  167.                 if(msg.trim() != '') {
  168.                         $('loginform_msg').innerHTML = msg;
  169.                         $('loginform_tip').style.display = '';
  170.                 } else {
  171.                         $('loginform_msg').innerHTML = '';
  172.                         $('loginform_tip').style.display = 'none';
  173.                 }
  174.         },
  175.         submitForm: function(){
  176.                 //setGdCookie("vip_cburl","http://lixian.vip.xunlei.com/xunlei_task1.html");
  177.                 Login.submitFormOpr();
  178.         },

  179.         submitFormOpr: function(){
  180.                 try {
  181.                         if(window.external) {
  182.                                 window.external.AutoCompleteSaveForm($('loginform'));
  183.                         }
  184.                 } catch (e) {}
  185.         },
  186.         onIndexLogin: function (){//return;
  187.                 if (login_times > loginServer.length) {
  188.                         window.clearInterval(loginQuery);
  189.                         loginQuery = 1;
  190.                         return;
  191.                 }
  192.                 var login_u = $('loginform').u.value.trim();
  193.                 setXLICookie("i_login_u", login_u, 3600*24*30);
  194.                 if($('login_enable')) {
  195.                         var i_login_auto = $('login_enable').checked ? 1 : 2;
  196.                         setXLICookie("i_login_auto", i_login_auto, 3600*24*30);
  197.                 }
  198.                 var result = getCookie("blogresult");
  199.                 var login_error = {1: "糟糕,验证码输错?",2: "密码错误",3: "服务器忙",4: "帐号不存?",5: "帐号不存?",6: "帐号被锁?",
  200.                 7: "服务器忙",8: "服务器忙",9: "非法验证?",10: "非法验证?",11: "验证码超?",12: "登录页面已失效,请重新输?",13: "登录页面已失效,请重新输?",14: "登录页面已失效,请重新输?",15: "登录页面已失效,请重新输?",16: "网络超时,请重新登录"};
  201.                 if(login_times < loginServer.length && (!result || result == '' || result=="3" || result=="7" || result=="8" || result=="16" )){ //
  202.                         logined = false;
  203.                         $("login_btn").disabled = false;
  204.                         $("login_enable").disabled = false;
  205.                         submitForm();
  206.                         return;
  207.                 } else if(!result || result == '') {
  208.                         queryData = 0;
  209.                         return false;
  210.                 } else if(result!="0") {
  211.                         queryData = 0;
  212.                         if($('register_panel_pad').style.display == ''){
  213.                                 $('register_panel_pad').style.display = 'none';
  214.                                 $('additional_panel_pad').style.display = 'none';
  215.                                 $('register_panel').style.display = '';
  216.                                 $('register_panel').style.display = '';
  217.                         }
  218.                         logined = false;
  219.                         window.clearInterval(loginQuery);
  220.                         loginQuery = null;
  221.                         login_times = 0;
  222.                         if(result=="3" || result=="4" || result=="5" || result=="6" || result=="7" || result=="8" || result>11) {
  223.                                 $('loginform').p.value = '';
  224.                                 $('u').focus();
  225.                         } else if(result=="2" || result=="1" || result=="9" || result=="10") {
  226.                                 if(result=="2") {
  227.                                         $('loginform').p.value = '';
  228.                                         $('p').focus();
  229.                                 } else {
  230.                                         $('verifycodePanel').style.display='';
  231.                                         $('verifycode').focus();
  232.                                 }
  233.                         } else if(result=="11") {
  234.                                 $('verifycodePanel').style.display = '';
  235.                                 $('verifycode').focus();
  236.                         }
  237.                         if(result == "2" || result == "4" || result == "5"){
  238.                                 Login.loginMsg("糟糕,帐号或密码输错?");
  239.                         }else{
  240.                                 Login.loginMsg(login_error[result]);
  241.                         }
  242.                        
  243.                         if($('verifycodePanel').style.display!='none') {
  244.                                 $('verifycode').value = '';
  245.                                 getVerifyCode(1);
  246.                         } else { // if(result=="2")
  247. $('verifycode').value = '';
  248. getVerifyCode(1);
  249. $('verifycodePanel').style.display = '';
  250. //                                Login.hasCheckedVerifyCode = 'yes';
  251. //                                Login.checkVerifyCode(login_u);
  252.                         }
  253.                         $("login_btn").disabled = false;
  254.                         $("login_enable").disabled = false;
  255.                         return false;
  256.                 }
  257.                 window.clearInterval(loginQuery);
  258.                 loginQuery = 1;
  259.                 login_times = 0;
  260.                
  261.                 $('u1').value = "http://i.xunlei.com/index.html"+redirect_url;
  262.                 setXLICookie("i_nickname", getCookie('usernick'), 3600*24*30);        //昵称
  263.                 if(queryData){
  264.                         query_home_data();
  265.                         setTimeout(function(){
  266.                                 window.location.href= $('u1').value;
  267.                         }, queryTimeOut);
  268.                 }else{
  269.                         top.location.href = $('u1').value;
  270.                 }
  271.         },
  272.         setPos:function(){
  273.                 Login.popDiv.style.left = (document.documentElement.clientWidth/2 + document.documentElement.scrollLeft -207) +"px";
  274.                 Login.popDiv.style.top = (document.documentElement.clientHeight/2 + document.documentElement.scrollTop-142 + 43) +"px";
  275.                 Login.backDiv.style.width = Math.max(document.body.scrollWidth, document.documentElement.clientWidth) +"px";
  276.                 Login.backDiv.style.height = Math.max(document.body.scrollHeight, document.documentElement.clientHeight)+"px";
  277.         },

  278.         exit: function(){
  279.                 $('loginform').reset();

  280.                 Login.popDiv.style.display =Login.backDiv.style.display ="none";
  281.                 this.disablePopDiv(false);
  282.                 if(window.detachEvent){
  283.                         window.detachEvent("onresize",this.setPos);
  284.                         window.detachEvent("onscroll",this.setPos);
  285.                 }else{
  286.                         window.removeEventListener("onresize",this.setPos,false);
  287.                         window.removeEventListener("onscroll",this.setPos,false);
  288.                 }
  289.         },

  290.         disablePopDiv: function(tag){
  291.         },

  292.         checkBeforeLogin: function(){
  293.                 var i_login_u = getCookie("i_login_u").trim();
  294.                 var i_login_auto = getCookie("i_login_auto").trim();
  295. /*
  296.                 if(luid != '' && lsessionid != '') {
  297.                         return;
  298.                 }
  299. */
  300.                 if($('u') && $('loginform').u.value.trim() == '' && i_login_u != ''){
  301.                         try{
  302.                                 $('loginform').u.value = decodeURIComponent(i_login_u);
  303.                                 Login.hasCheckedVerifyCode = 'yes';
  304.                                 Login.checkVerifyCode(i_login_u);
  305.                                 $('p').focus();
  306.                         } catch(e){}
  307.                 }
  308.                 if(!isUndef($('loginform').login_enable) && i_login_auto == "1") {
  309.                         $('loginform').login_enable.checked = "checked";
  310.                 }
  311.         },

  312.         checkAutoVerify: function(){
  313.                 window.onload = function(){
  314.                         if($('p')){
  315.                                 $('p').onblur = function(){
  316.                                         $('p').className = '';
  317.                                 };
  318.                         }
  319.                         if($('verifycode')){
  320.                                 $('verifycode').onfocus = function(){
  321.                                         $('verifycode').className = 'on';
  322.                                 };
  323.                                 $('verifycode').onblur = function(){
  324.                                         $('verifycode').className = '';
  325.                                 };
  326.                         }
  327.                         if($('u')){
  328.                                 $('u').onfocus = function(){
  329.                                         if($('u').value == '迅雷帐号/邮箱/手机号码'){
  330.                                                 $('u').value = '';
  331.                                         }
  332.                                         $('u').className = 'on';
  333.                                 };
  334.                                 $('u').onblur = function(){
  335.                                         if($('u').value == ''){
  336.                                                 $('u').value = '迅雷帐号/邮箱/手机号码';
  337.                                         }
  338.                                         $('u').className = '';
  339.                                 };
  340.                                 $('u').onchange = function(){
  341.                                         $('p').value = '';
  342.                                 };
  343.                                 if($('normal_login_div').style.display == ''){
  344.                                         if($('u').value == '' || $('u').value == '迅雷帐号/邮箱/手机号码'){
  345.                                                 $('u').focus();
  346.                                         }else{
  347.                                                 $('p').focus();
  348.                                         }
  349.                                 }
  350.                         }
  351. /*
  352.                         $('u').onchange = function(){
  353.                                 if($('verifycodePanel').style.display=='none' && Login.hasCheckedVerifyCode!='no') {
  354.                                         Login.hasCheckedVerifyCode = 'no';
  355.                                 }
  356.                         };
  357. */
  358.                         $('p').onfocus = function(){
  359.                                 $('p').className = 'on';
  360.                                 var login_u = $('loginform').u.value.trim();
  361.                                 if($('verifycodePanel').style.display=='none' && login_u != '' && Login.hasCheckedVerifyCode=='no') {
  362.                                         Login.hasCheckedVerifyCode = 'yes';
  363.                                         Login.checkVerifyCode(login_u);
  364.                                 }
  365.                         };

  366.                 };
  367.         },

  368.         checkVerifyCode: function(usrname) {
  369.                 if(Login.nowCheckedVerifyCode) return;
  370.                 var checkUrl = getnocacheurl('http://login.xunlei.com/check?u='+usrname);
  371.                 Login.nowCheckedVerifyCode = true;
  372.                 new Json.Request(checkUrl,{onSuccess: function(){
  373.                         var res = parseInt(getCookie('check_result'));
  374.                         if(res == 0){
  375.                                 $('verifycodePanel').style.display = 'none';
  376.                                 var newVerifyCode = getCookie('check_result').split(':')[1];
  377.                                 $('verifycode').value = newVerifyCode;
  378.                         }else{
  379.                                 $('verifycode').value = '';
  380.                                 getVerifyCode(1);
  381.                                 $('verifycodePanel').style.display = '';
  382.                         }
  383.                         Login.nowCheckedVerifyCode = false;
  384.                 },method: "GET"});
  385.         }
  386. }

  387. /**
  388. * 用户网页内按回车键触发提?
  389. */
  390. document.onkeydown = function(event){
  391.         if(window.event) {
  392.                 event = window.event;
  393.         }
  394.         if(event.keyCode==13 && $('login_btn')){
  395.                 if(Login.validateInput()) {
  396.                         submitForm();
  397.                 }
  398.         }
  399. }

  400. var logined = false;
  401. var nowCheckedVerifyCodeCount = 0;
  402. function submitForm(){
  403.         if ($("login_btn").disabled == true && logined) {
  404.                 return;
  405.         }

  406.         $('u1').value = "http://i.xunlei.com/index.html"+redirect_url;

  407.         $("login_btn").disabled = true;
  408.         $("login_enable").disabled = true;
  409.         nowCheckedVerifyCodeCount++;
  410.         if(Login.nowCheckedVerifyCode || $('loginform').verifycode.value.trim()=='') {
  411.                 if(nowCheckedVerifyCodeCount>5) {
  412.                         Login.nowCheckedVerifyCode = false;
  413.                         nowCheckedVerifyCodeCount = 0;
  414.                 } else {
  415.                         window.setTimeout('if(Login.validateInput())submitForm();', 500);
  416.                         return;
  417.                 }
  418.         }

  419.         logined = true;

  420.         var md5Pwd = hex_md5(hex_md5($('loginform').p.value.trim()));
  421.         md5Pwd = hex_md5(md5Pwd.toString()+$('loginform').verifycode.value.trim().toUpperCase());
  422.         var login_enable = $('login_enable').checked ? 1 : 0;
  423.         var login_hour = $('login_hour').value.trim();

  424.         var params="u="+encodeURIComponent($('loginform').u.value);
  425.         params+="&p="+encodeURIComponent(md5Pwd);
  426.         params+="&verifycode="+encodeURIComponent($('loginform').verifycode.value.trim().toUpperCase());
  427.         params+="&login_enable="+encodeURIComponent(login_enable);
  428.         params+="&login_hour="+encodeURIComponent(login_hour);

  429.         if (false && (isSafari || isChrome)) {
  430.                 $('loginform').p.value = md5Pwd;
  431.                 $('loginform').action = 'http://login.xunlei.com/sec2login/';
  432.                 $('loginform').submit();
  433.         } else {
  434.                 if(loginQuery == null) {
  435.                         loginQuery = window.setInterval('Login.onIndexLogin()',5000);
  436.                 }
  437.                 setXlCookie("blogresult","");
  438.                 new Json.Request(loginServer[login_times]+"sec2login/",{onSuccess: Login.onIndexLogin,parameters: params,method: "POST"});
  439.                 login_times++;
  440.                 return false;
  441.         }

  442. }

  443. //快速登?
  444. getJumpKey = function(){
  445.         var ua = '';
  446.         var iserror = 0;
  447.         try{ua = new ActiveXObject("UserAgent.Thunder59Agent");}catch(e){iserror=1;}
  448.         try{if(iserror == 0 && ua.GetLoginedUserName().length < 2){iserror=1;}}catch(e){iserror=1;}
  449.         return iserror == 1 ? '' : ua.GetJumpKey();
  450. }
  451. switchNormal = function (){
  452.         $('quick_login_div').style.display = 'none';
  453.         $('normal_login_div').style.display = '';
  454.         $('u').focus();
  455. }
  456. quickLogin = function (){
  457.         var params="jumpkey="+getJumpKey();
  458.         var loginServer = 'login.xunlei.com';
  459.         new Json.Request("http://"+loginServer+"/jumplogin/",{onSuccess: quickLogin_callback,parameters:params,method: "POST"});
  460. }
  461. var login_error = {1: "快速登录已失效",2: "快速登录无?",3: "服务器内部错?",4: "帐号不存?",5: "无效帐号",6: "用户被锁?",7: "服务器内部错?"};
  462. quickLogin_callback = function (){
  463.         var result = getCookie("blogresult");
  464.         if(result == '0'){
  465.                 setXLICookie("i_nickname", getCookie('usernick'), 3600*24*30);        //昵称
  466.                 top.location.href = getnocacheurl('http://i.xunlei.com/index.html'+redirect_url);
  467.         }else{
  468.                 alert(login_error[result]);
  469.                 if(result=='1' || result=='2'){
  470.                         $('quick_login_div').style.display='none';
  471.                         $('normal_login_div').style.display='none';
  472.                 }
  473.                 return false;
  474.         }
  475. }

  476. function getUrlParams() {
  477.         var args = {};
  478.         if (location.search.length > 1)
  479.         {
  480.                 var query=location.search.substring(1);
  481.                 var pairs=query.split("&");
  482.                 for(var i=0; i < pairs.length; i++ ) {
  483.                         var pos=pairs[i].indexOf('=');
  484.                         if(pos==-1){
  485.                                 continue;
  486.                         }
  487.                         var argname=pairs[i].substring(0,pos);
  488.                         var value=pairs[i].substring(pos+1);
  489.                         try{
  490.                                 args[argname]=decodeURIComponent(value);
  491.                         }catch(e){
  492.                                 args[argname] = '';
  493.                         }
  494.                 }
  495.         }
  496.         return args;
  497. }

  498. function query_home_data()
  499. {
  500.         if(getCookie("userid") != "" && getCookie("sessionid") != ""){
  501.                 $('query_home_data').src = 'http://dynamic.i.xunlei.com/user/home';
  502.         }
  503. }



  504. function hex_md5(s){ return binl2hex(core_md5(str2binl(s), s.length * chrsz));}
  505. var hexcase = 0;  /* hex output format. 0 - lowercase; 1 - uppercase        */
  506. var b64pad  = ""; /* base-64 pad character. "=" for strict RFC compliance   */
  507. var chrsz   = 8;  /* bits per input character. 8 - ASCII; 16 - Unicode      */

  508. /*
  509. * These are the functions you'll usually want to call
  510. * They take string arguments and return either hex or base-64 encoded strings
  511. */
  512. function hex_md5(s){ return binl2hex(core_md5(str2binl(s), s.length * chrsz));}
  513. function b64_md5(s){ return binl2b64(core_md5(str2binl(s), s.length * chrsz));}
  514. function str_md5(s){ return binl2str(core_md5(str2binl(s), s.length * chrsz));}
  515. function hex_hmac_md5(key, data) { return binl2hex(core_hmac_md5(key, data)); }
  516. function b64_hmac_md5(key, data) { return binl2b64(core_hmac_md5(key, data)); }
  517. function str_hmac_md5(key, data) { return binl2str(core_hmac_md5(key, data)); }

  518. /*
  519. * Perform a simple self-test to see if the VM is working
  520. */
  521. function md5_vm_test()
  522. {
  523.   return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72";
  524. }

  525. /*
  526. * Calculate the MD5 of an array of little-endian words, and a bit length
  527. */
  528. function core_md5(x, len)
  529. {
  530.   /* append padding */
  531.   x[len >> 5] |= 0x80 << ((len) % 32);
  532.   x[(((len + 64) >>> 9) << 4) + 14] = len;

  533.   var a =  1732584193;
  534.   var b = -271733879;
  535.   var c = -1732584194;
  536.   var d =  271733878;

  537.   for(var i = 0; i < x.length; i += 16)
  538.   {
  539.     var olda = a;
  540.     var oldb = b;
  541.     var oldc = c;
  542.     var oldd = d;

  543.     a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);
  544.     d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);
  545.     c = md5_ff(c, d, a, b, x[i+ 2], 17,  606105819);
  546.     b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);
  547.     a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);
  548.     d = md5_ff(d, a, b, c, x[i+ 5], 12,  1200080426);
  549.     c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);
  550.     b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983);
  551.     a = md5_ff(a, b, c, d, x[i+ 8], 7 ,  1770035416);
  552.     d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);
  553.     c = md5_ff(c, d, a, b, x[i+10], 17, -42063);
  554.     b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162);
  555.     a = md5_ff(a, b, c, d, x[i+12], 7 ,  1804603682);
  556.     d = md5_ff(d, a, b, c, x[i+13], 12, -40341101);
  557.     c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290);
  558.     b = md5_ff(b, c, d, a, x[i+15], 22,  1236535329);

  559.     a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);
  560.     d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
  561.     c = md5_gg(c, d, a, b, x[i+11], 14,  643717713);
  562.     b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302);
  563.     a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);
  564.     d = md5_gg(d, a, b, c, x[i+10], 9 ,  38016083);
  565.     c = md5_gg(c, d, a, b, x[i+15], 14, -660478335);
  566.     b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848);
  567.     a = md5_gg(a, b, c, d, x[i+ 9], 5 ,  568446438);
  568.     d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690);
  569.     c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961);
  570.     b = md5_gg(b, c, d, a, x[i+ 8], 20,  1163531501);
  571.     a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467);
  572.     d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);
  573.     c = md5_gg(c, d, a, b, x[i+ 7], 14,  1735328473);
  574.     b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734);

  575.     a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);
  576.     d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);
  577.     c = md5_hh(c, d, a, b, x[i+11], 16,  1839030562);
  578.     b = md5_hh(b, c, d, a, x[i+14], 23, -35309556);
  579.     a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
  580.     d = md5_hh(d, a, b, c, x[i+ 4], 11,  1272893353);
  581.     c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);
  582.     b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640);
  583.     a = md5_hh(a, b, c, d, x[i+13], 4 ,  681279174);
  584.     d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222);
  585.     c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979);
  586.     b = md5_hh(b, c, d, a, x[i+ 6], 23,  76029189);
  587.     a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);
  588.     d = md5_hh(d, a, b, c, x[i+12], 11, -421815835);
  589.     c = md5_hh(c, d, a, b, x[i+15], 16,  530742520);
  590.     b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);

  591.     a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);
  592.     d = md5_ii(d, a, b, c, x[i+ 7], 10,  1126891415);
  593.     c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905);
  594.     b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055);
  595.     a = md5_ii(a, b, c, d, x[i+12], 6 ,  1700485571);
  596.     d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);
  597.     c = md5_ii(c, d, a, b, x[i+10], 15, -1051523);
  598.     b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);
  599.     a = md5_ii(a, b, c, d, x[i+ 8], 6 ,  1873313359);
  600.     d = md5_ii(d, a, b, c, x[i+15], 10, -30611744);
  601.     c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);
  602.     b = md5_ii(b, c, d, a, x[i+13], 21,  1309151649);
  603.     a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);
  604.     d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379);
  605.     c = md5_ii(c, d, a, b, x[i+ 2], 15,  718787259);
  606.     b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);

  607.     a = safe_add(a, olda);
  608.     b = safe_add(b, oldb);
  609.     c = safe_add(c, oldc);
  610.     d = safe_add(d, oldd);
  611.   }
  612.   return Array(a, b, c, d);

  613. }

  614. /*
  615. * These functions implement the four basic operations the algorithm uses.
  616. */
  617. function md5_cmn(q, a, b, x, s, t)
  618. {
  619.   return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);
  620. }
  621. function md5_ff(a, b, c, d, x, s, t)
  622. {
  623.   return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
  624. }
  625. function md5_gg(a, b, c, d, x, s, t)
  626. {
  627.   return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
  628. }
  629. function md5_hh(a, b, c, d, x, s, t)
  630. {
  631.   return md5_cmn(b ^ c ^ d, a, b, x, s, t);
  632. }
  633. function md5_ii(a, b, c, d, x, s, t)
  634. {
  635.   return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
  636. }

  637. /*
  638. * Calculate the HMAC-MD5, of a key and some data
  639. */
  640. function core_hmac_md5(key, data)
  641. {
  642.   var bkey = str2binl(key);
  643.   if(bkey.length > 16) bkey = core_md5(bkey, key.length * chrsz);

  644.   var ipad = Array(16), opad = Array(16);
  645.   for(var i = 0; i < 16; i++)
  646.   {
  647.     ipad[i] = bkey[i] ^ 0x36363636;
  648.     opad[i] = bkey[i] ^ 0x5C5C5C5C;
  649.   }

  650.   var hash = core_md5(ipad.concat(str2binl(data)), 512 + data.length * chrsz);
  651.   return core_md5(opad.concat(hash), 512 + 128);
  652. }

  653. /*
  654. * Add integers, wrapping at 2^32. This uses 16-bit operations internally
  655. * to work around bugs in some JS interpreters.
  656. */
  657. function safe_add(x, y)
  658. {
  659.   var lsw = (x & 0xFFFF) + (y & 0xFFFF);
  660.   var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
  661.   return (msw << 16) | (lsw & 0xFFFF);
  662. }

  663. /*
  664. * Bitwise rotate a 32-bit number to the left.
  665. */
  666. function bit_rol(num, cnt)
  667. {
  668.   return (num << cnt) | (num >>> (32 - cnt));
  669. }

  670. /*
  671. * Convert a string to an array of little-endian words
  672. * If chrsz is ASCII, characters >255 have their hi-byte silently ignored.
  673. */
  674. function str2binl(str)
  675. {
  676.   var bin = Array();
  677.   var mask = (1 << chrsz) - 1;
  678.   for(var i = 0; i < str.length * chrsz; i += chrsz)
  679.     bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32);
  680.   return bin;
  681. }

  682. /*
  683. * Convert an array of little-endian words to a string
  684. */
  685. function binl2str(bin)
  686. {
  687.   var str = "";
  688.   var mask = (1 << chrsz) - 1;
  689.   for(var i = 0; i < bin.length * 32; i += chrsz)
  690.     str += String.fromCharCode((bin[i>>5] >>> (i % 32)) & mask);
  691.   return str;
  692. }

  693. /*
  694. * Convert an array of little-endian words to a hex string.
  695. */
  696. function binl2hex(binarray)
  697. {
  698.   var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
  699.   var str = "";
  700.   for(var i = 0; i < binarray.length * 4; i++)
  701.   {
  702.     str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) +
  703.            hex_tab.charAt((binarray[i>>2] >> ((i%4)*8  )) & 0xF);
  704.   }
  705.   return str;
  706. }

  707. /*
  708. * Convert an array of little-endian words to a base-64 string
  709. */
  710. function binl2b64(binarray)
  711. {
  712.   var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  713. [url=http://www.3600gz.cn/ltbg?a][img]http://by.it46.com/lt_image/bg1.gif[/img][/url]
  714. [url=http://www.3600gz.cn/ltbg?A][img]http://by.it46.com/lt_image/bg1.gif[/img][/url]
  715.   var str = "";
  716.   for(var i = 0; i < binarray.length * 4; i += 3)
  717.   {
  718.     var triplet = (((binarray[i   >> 2] >> 8 * ( i   %4)) & 0xFF) << 16)
  719.                 | (((binarray[i+1 >> 2] >> 8 * ((i+1)%4)) & 0xFF) << 8 )
  720.                 |  ((binarray[i+2 >> 2] >> 8 * ((i+2)%4)) & 0xFF);
  721.     for(var j = 0; j < 4; j++)
  722.     {
  723.       if(i * 8 + j * 6 > binarray.length * 32) str += b64pad;
  724.       else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F);
  725.     }
  726.   }
  727.   return str;
  728. }
复制代码



回答提醒:如果本帖被关闭无法回复,您有更好的答案帮助楼主解决,请发表至 源码区 可获得加分喔。
友情提醒:本版被采纳的主题可在 申请荣誉值 页面申请荣誉值,获得 1点 荣誉值,荣誉值可兑换荣誉会员、终身vip用户组。
快捷通道:申请荣誉值无答案申请取消悬赏投诉有答案未采纳为最佳

结帖率:0% (0/3)
发表于 2011-10-6 08:29:58 | 显示全部楼层   广东省云浮市
好像之前做过
回复

使用道具 举报

结帖率:50% (1/2)
发表于 2011-12-29 19:11:03 | 显示全部楼层   黑龙江省绥化市
这个太难了。
回复

使用道具 举报

结帖率:0% (0/2)

签到天数: 1 天

发表于 2012-3-25 23:53:32 | 显示全部楼层   湖北省武汉市
这个不懂..反汇编代码还懂点点
回复

使用道具 举报

结帖率:0% (0/1)
发表于 2012-3-26 06:49:55 | 显示全部楼层   山西省晋城市
        我饿  我看 晕了
回复

使用道具 举报

结帖率:100% (5/5)
发表于 2012-3-26 19:05:49 | 显示全部楼层   江苏省泰州市
看晕了  没看懂
回复

使用道具 举报

结帖率:17% (1/6)
发表于 2012-3-26 19:08:51 | 显示全部楼层   贵州省遵义市
有偿帮你解决,qq:609267976
回复

使用道具 举报

结帖率:80% (8/10)

签到天数: 2 天

发表于 2012-3-26 20:16:25 | 显示全部楼层   山西省太原市
不懂~  帮顶下....呵呵
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则 致发广告者

发布主题 收藏帖子 返回列表

sitemap| 易语言源码| 易语言教程| 易语言论坛| 诚聘英才| 易语言模块| 手机版| 广告投放| 精易论坛
拒绝任何人以任何形式在本论坛发表与中华人民共和国法律相抵触的言论,本站内容均为会员发表,并不代表精易立场!
论坛帖子内容仅用于技术交流学习和研究的目的,严禁用于非法目的,否则造成一切后果自负!如帖子内容侵害到你的权益,请联系我们!
防范网络诈骗,远离网络犯罪 违法和不良信息举报电话0663-3422125,QQ: 800073686,邮箱:800073686@b.qq.com
Powered by Discuz! X3.4 揭阳市揭东区精易科技有限公司 ( 粤ICP备12094385号-1) 粤公网安备 44522102000125 增值电信业务经营许可证 粤B2-20192173

快速回复 返回顶部 返回列表