Security Encode & Decode

2021-06-04 16:01

阅读:680

标签:密码   dex   ring   bsp   doc   input   val   管理系统   NPU   

加密的方法是由某管理系统的登录密码加密方法修改得到的,解密的方法是本人写的。

 1 html>
 2     head>
 3         title>Powered By Leisureeentitle>
 4     head>
 5     script language="JavaScript">
 6         function securityEncode(){
 7             var pwd = document.getElementById("txt").value;
 8             var strDe = "RDpbLfCPsJZ7fiv";
 9             var dictionary = "yLwVl0zKqws7LgKPRQ84Mdt708T1qQ3Ha7xv3H7NyU84p21BriUWBU43odz3iP4rBL3cD02KZciX"+
10                       "TysVXiV8ngg6vL48rPJyAUw0HurW20xqxv9aYb4M9wK1Ae0wlro510qXeU07kV57fQMc8L6aLgML"+
11                       "wygtc0F10a0Dg70TOoouyFhdysuRMO51yY5ZlOZZLEal1h0t9YQW0Ko7oBwmCAHoic4HYbUyVeU3"+
12                       "sfQ1xtXcPcf1aT303wAQhv66qzW";
13             var output = "";
14             var lenMax, len1, len2, lenDict;
15             var cl = 0xBB, cr = 0xBB;
16             len1 = strDe.length;
17             len2 = pwd.length;
18             lenDict = dictionary.length;
19             lenMax = len1 > len2 ? len1 : len2;
20             for (var index = 0; index  lenMax; index++){
21                 cl = cr = 0xBB;
22                 if(index  len1)
23                     cl = strDe.charCodeAt(index);
24                 if(index  len2)
25                     cr = pwd.charCodeAt(index);
26                 output += dictionary.charAt((cl ^ cr) % lenDict);
27             }
28             document.getElementById("out").value = output;
29         }
30         function decode(){
31             var pwd = document.getElementById("txt").value;
32             var strDe = "RDpbLfCPsJZ7fiv";
33             var dictionary = "yLwVl0zKqws7LgKPRQ84Mdt708T1qQ3Ha7xv3H7NyU84p21BriUWBU43odz3iP4rBL3cD02KZciX"+
34                       "TysVXiV8ngg6vL48rPJyAUw0HurW20xqxv9aYb4M9wK1Ae0wlro510qXeU07kV57fQMc8L6aLgML"+
35                       "wygtc0F10a0Dg70TOoouyFhdysuRMO51yY5ZlOZZLEal1h0t9YQW0Ko7oBwmCAHoic4HYbUyVeU3"+
36                       "sfQ1xtXcPcf1aT303wAQhv66qzWy";//append ‘y‘
37             var output = "";
38             if(pwd.length  15)
39                 alert("pwd.length must great than or equals to 15.");
40             else if(pwd.length == 15){
41                 for(var iChar = 0; iChar  15; iChar++){
42                     var flag0xBB = false;
43                     output += (iChar + 1) + ": ";
44                     for(var iDic = 0; iDic  255; iDic++){
45                         if(dictionary.charCodeAt(iDic) == pwd.charCodeAt(iChar)){
46                             var keyChar = iDic ^ strDe.charCodeAt(iChar);
47                             if(keyChar >= 32 && keyChar  126)
48                                 output += String.fromCharCode(keyChar);
49                             else if(keyChar == 0xBB)
50                                 flag0xBB = true;
51                         }
52                     }
53                     output += "\n";
54                     if(flag0xBB)
55                         output += "Password may contains " + iChar + " char(s).\n";
56                 }
57             }
58             else{
59                 for(var iChar = 0; iChar  pwd.length; iChar++){
60                     output += (iChar + 1) + ": ";
61                     for(var iDic = 0; iDic  255; iDic++){
62                         if(dictionary.charCodeAt(iDic) == pwd.charCodeAt(iChar)){
63                             var keyChar = iDic ^ (iChar >= 15 ? 0xBB : strDe.charCodeAt(iChar));
64                             if(keyChar >= 32 && keyChar  126)
65                                 output += String.fromCharCode(keyChar);
66                         }
67                     }
68                     output += "\n";
69                 }
70             }
71             document.getElementById("out").value = output;
72         }
73     script>
74     body bgcolor="ABCDEF">
75         div align="center">
76             b>textarea id="txt" style="height:100;width:500;font-size:20px">123456789ABCDEFtextarea>br>
77             input type="button" onclick="securityEncode()" value="Encode">    
78             input type="button" onclick="decode()" value="Decode">br>
79             textarea id="out" style="height:400;width:500;font-size:20px">textarea>br>
80             Designer:Leisureeenb>br>
81         div>
82     body>
83 html>

 

其中加密算法的测试结果如下:

Sample Input:

Leisureeen

Sample Output:

378QdM7Ut3efbwK

解密算法的测试结果如下:

Sample Input:

378QdM7Ut3efbwK

Sample Output:

1: Lvei
2: OSeb
3: biZ#+
4: s
5: Yu
6: r
7: HTbe
8: ybe1
9: e
10: Tn}q
11: #
Password may contains 10 char(s).
12: 
Password may contains 11 char(s).
13: 
Password may contains 12 char(s).
14: k`
Password may contains 13 char(s).
15: qx1
Password may contains 14 char(s).

 

Security Encode & Decode

标签:密码   dex   ring   bsp   doc   input   val   管理系统   NPU   

原文地址:https://www.cnblogs.com/leisureeen/p/12341050.html


评论


亲,登录后才可以留言!