-
Notifications
You must be signed in to change notification settings - Fork 0
/
123.html
221 lines (203 loc) · 7.27 KB
/
123.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
</body>
</html>
<script>
/* 加密
var L = L || {};
L.hex64Instance = undefined ;
;(function() {
//
// 密文字符集(size:65)。
// [0-9A-Za-z$_~]
//
// var _hexCHS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz$_~';
var _hexCHS = 'JKijklmnoz$_01234ABCDEFGHI56789LMNOPQRpqrstuvwxySTUVWXYZabcdefgh~';
if(_hexCHS.length !== 65){L.Logger.error('密文字符集长度必须是65位,当前长度为:'+_hexCHS.length );return ;}
//
// Base64 变形加密法
// 算法与 Base64 类似,即将 8 位字节用 6 位表示。
// 规则:
// 1. 码值 <= 0xff 的用 1 个字节表示;
// 2. 码值 > 0xff 的用 2 字节表示;
// 3. 单/双字节序列间用 0x1d 进行分隔;
// 4. 首字为双字节时即前置 0x1d 分隔符。
//
// @param array key - [0-63] 互斥值数组,length == 64
//
const Hex64 = function( key )
{
this._key = [], this._tbl = {};
for (var _i=0; _i<64; ++_i) {
this._key[_i] = _hexCHS.charAt(key[_i]);
this._tbl[this._key[_i]] = _i;
}
this._pad = _hexCHS.charAt(64);
};
// 加密
Hex64.prototype.enc = function( s )
{
var _rs = '';
var _c1, _c2, _c3, _n1, _n2, _n3, _n4;
var _i = 0;
var _a = Hex64._2to1(s);
var _en = _a.length % 3, _sz = _a.length - _en;
while (_i < _sz) {
_c1 = _a[_i++];
_c2 = _a[_i++];
_c3 = _a[_i++];
_n1 = _c1 >> 2;
_n2 = ((_c1 & 3) << 4) | (_c2 >> 4);
_n3 = ((_c2 & 15) << 2) | (_c3 >> 6);
_n4 = _c3 & 63;
_rs += this._key[_n1]
+ this._key[_n2]
+ this._key[_n3]
+ this._key[_n4];
}
if (_en > 0) {
_c1 = _a[_i++];
_c2 = _en > 1 ? _a[_i] : 0;
_n1 = _c1 >> 2;
_n2 = ((_c1 & 3) << 4) | (_c2 >> 4);
_n3 = (_c2 & 15) << 2;
_rs += this._key[_n1] + this._key[_n2]
+ (_n3 ? this._key[_n3] : this._pad)
+ this._pad;
}
return _rs.replace(/.{76}/g, function(s) {
return s + '\n';
});
};
// 解密
Hex64.prototype.dec = function( s )
{
var _sa = [],
_n1, _n2, _n3, _n4,
_i = 0, _c = 0;
s = s.replace(/[^0-9A-Za-z$_~]/g, '');
while (_i < s.length) {
_n1 = this._tbl[s.charAt(_i++)];
_n2 = this._tbl[s.charAt(_i++)];
_n3 = this._tbl[s.charAt(_i++)];
_n4 = this._tbl[s.charAt(_i++)];
_sa[_c++] = (_n1 << 2) | (_n2 >> 4);
_sa[_c++] = ((_n2 & 15) << 4) | (_n3 >> 2);
_sa[_c++] = ((_n3 & 3) << 6) | _n4;
}
var _e2 = s.slice(-2);
if (_e2.charAt(0) == this._pad) {
_sa.length = _sa.length - 2;
} else if (_e2.charAt(1) == this._pad) {
_sa.length = _sa.length - 1;
}
return Hex64._1to2(_sa);
};
//
// 辅助:
// Unicode 字符串 -> 单字节码值数组
// 注意:
// 原串中值为 0x1d 的字节(非字符)会被删除。
//
// @param string s - 字符串(UCS-16)
// @return array - 单字节码值数组
//
Hex64._2to1 = function( s )
{
var _2b = false, _n = 0, _sa = [];
if (s.charCodeAt(0) > 0xff) {
_2b = true;
_sa[_n++] = 0x1d;
}
for (var _i=0; _i<s.length; ++_i) {
var _c = s.charCodeAt(_i);
if (_c == 0x1d) continue;
if (_c <= 0xff) {
if (_2b) {
_sa[_n++] = 0x1d;
_2b = false;
}
_sa[_n++] = _c;
} else {
if (! _2b) {
_sa[_n++] = 0x1d;
_2b = true;
}
_sa[_n++] = _c >> 8;
_sa[_n++] = _c & 0xff;
}
}
return _sa;
};
//
// 辅助:
// 单字节码值数组 -> Unicode 字符串
//
// @param array a - 单字节码值数组
// @return string - 还原后的字符串(UCS-16)
//
Hex64._1to2 = function( a )
{
var _2b = false, _rs = '';
for (var _i=0; _i<a.length; ++_i) {
var _c = a[_i];
if (_c == 0x1d) {
_2b = !_2b;
continue;
}
if (_2b) {
_rs += String.fromCharCode(_c * 256 + a[++_i]);
} else {
_rs += String.fromCharCode(_c);
}
}
return _rs;
};
// var _k3 = [38,48,18,11,26,19,55,58,10,33,34,49,14,25,44,52,61,16,2,56,23,29,45,9,3,12,39,30,42,47,22,21,60,1,54,28,57,17,27,15,40,46,43,13,0,51,35,63,36,50,6,32,4,31,62,5,24,8,53,59,41,20,7,37];
var _k3 = [15,40,46,43,13,0,51,35,63,36,50,6,32,4,31,62,5,24,8,53,59,41,20,7,37,38,48,18,11,26,19,55,58,10,33,34,49,14,25,44,52,61,16,2,56,23,29,45,9,3,12,39,30,42,47,22,21,60,1,54,28,57,17,27];
if(_k3.length !== 64){L.Logger.error('互斥值数组长度必须是65位,当前长度为:'+_k3.length );return ;}
L.hex64Instance = new Hex64(_k3);
})();
function jia(str , encryptRandom ) {
if(!str){return str;}
encryptRandom = encryptRandom != undefined ? encryptRandom : 'talk_2017_@beijing' ;
var out = L.hex64Instance.enc(str);
out = encryptRandom + out + encryptRandom ;
return out
}
function jie(str , encryptRandom ){
if(!str){return str;}
encryptRandom = encryptRandom != undefined ? encryptRandom : 'talk_2017_@beijing' ;
var regExp = new RegExp( encryptRandom , 'gm' ) ;
str = str.replace( regExp , '' );
var out = L.hex64Instance.dec(str);
return out
}
*/
// 解析url
function getUrlParams(key , url) {
var href = window.location.href ;
href = url || href;
// let urlAdd = decodeURI(href);
var urlAdd = decodeURIComponent(href);
var urlIndex = urlAdd.indexOf("?");
var urlSearch = urlAdd.substring(urlIndex + 1);
var reg = new RegExp("(^|&)" + key + "=([^&]*)(&|$)", "i"); //reg表示匹配出:$+url传参数名字=值+$,并且$可以不存在,这样会返回一个数组
var arr = urlSearch.match(reg);
if(arr != null) {
return arr[2];
} else {
return "";
}
}
console.log(window.location.href.replace('66','456'));
var str='https://login.taobao.com/member/login.jhtml?result=1'
var reg=/(&|\?)result=\d/;
let aa = str.replace(reg,'');
console.log(aa);
</script>