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
|
var picList = {
base64EncodeChars: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',
base64DecodeChars: new Array(-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1, -1, 0, 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, -1, -1, -1, -1, -1, -1, 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, -1, -1, -1, -1, -1),
base64encode: function (r) {
for (var e, a, t, o = r.length, h = 0, c = ''; h < o;) {
if (e = 255 & r.charCodeAt(h++), h == o) {
c = (c += this.base64EncodeChars.charAt(e >> 2)) + this.base64EncodeChars.charAt((3 & e) << 4) + '==';
break;
}
if (a = r.charCodeAt(h++), h == o) {
c = (c = (c += this.base64EncodeChars.charAt(e >> 2)) + this.base64EncodeChars.charAt((3 & e) << 4 | (240 & a) >> 4)) + this.base64EncodeChars.charAt((15 & a) << 2) + '=';
break;
}
t = r.charCodeAt(h++), c = (c = (c = (c += this.base64EncodeChars.charAt(e >> 2)) + this.base64EncodeChars.charAt((3 & e) << 4 | (240 & a) >> 4)) + this.base64EncodeChars.charAt((15 & a) << 2 | (192 & t) >> 6)) + this.base64EncodeChars.charAt(63 & t);
}
return c;
},
base64decode: function (r) {
for (var e, a, t, o, h = r.length, c = 0, s = ''; c < h;) {
for (; e = this.base64DecodeChars[255 & r.charCodeAt(c++)], c < h && -1 == e;);
if (-1 == e)
break;
for (; a = this.base64DecodeChars[255 & r.charCodeAt(c++)], c < h && -1 == a;);
if (-1 == a)
break;
s += String.fromCharCode(e << 2 | (48 & a) >> 4);
do {
if (61 == (t = 255 & r.charCodeAt(c++)))
return s;
} while (t = this.base64DecodeChars[t], c < h && -1 == t);
if (-1 == t)
break;
s += String.fromCharCode((15 & a) << 4 | (60 & t) >> 2);
do {
if (61 == (o = 255 & r.charCodeAt(c++)))
return s;
} while (o = this.base64DecodeChars[o], c < h && -1 == o);
if (-1 == o)
break;
s += String.fromCharCode((3 & t) << 6 | o);
}
return s;
},
utf16to8: function (r) {
for (var e, a = '', t = r.length, o = 0; o < t; o++)
1 <= (e = r.charCodeAt(o)) && e <= 127 ? a += r.charAt(o) : a = 2047 < e ? (a = (a += String.fromCharCode(224 | e >> 12 & 15)) + String.fromCharCode(128 | e >> 6 & 63)) + String.fromCharCode(128 | e >> 0 & 63) : (a += String.fromCharCode(192 | e >> 6 & 31)) + String.fromCharCode(128 | e >> 0 & 63);
return a;
},
utf8to16: function (r) {
for (var e, a, t, o = '', h = r.length, c = 0; c < h;)
switch ((e = r.charCodeAt(c++)) >> 4) {
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
o += r.charAt(c - 1);
break;
case 12:
case 13:
a = r.charCodeAt(c++), o += String.fromCharCode((31 & e) << 6 | 63 & a);
break;
case 14:
a = r.charCodeAt(c++), t = r.charCodeAt(c++), o += String.fromCharCode((15 & e) << 12 | (63 & a) << 6 | (63 & t) << 0);
}
return o;
},
randomStr: function (r) {
for (var e = 'poiuytrewqasdfghjklmnbvcxzQWERTYUIOPLKJHGFDSAZXCVBNM123456789', a = '', t = 0; t < r; t++)
a += e.charAt(Math.ceil(100000000 * Math.random()) % e.length);
return a;
},
encode: function (r) {
$.ECOND.picture && $.ECOND.picture, r += this.randomStr(5);
for (var e, a = (str = picList.base64encode(picList.utf16to8(r))).split(''), t = 0; t < Math.floor(a.length / 2); t++)
t % 2 == 0 && (e = a[t], a[t] = a[a.length - 1 - t], a[a.length - 1 - t] = e);
return $.ECOND.picture && '' != $.ECOND.picture ? a.join('') + 'cEe' : a.join('') + 'eEc';
},
encode2: function (r) {
return picList.base64encode(picList.utf16to8(r));
}
};
|