-
Notifications
You must be signed in to change notification settings - Fork 24
/
imoutai.js
67 lines (65 loc) · 2.22 KB
/
imoutai.js
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
var XORCipher = {
encode: function (t, e) {
return this.b64_encode(this.xor_encrypt(t, e))
},
decode: function (t, e) {
return this.xor_decrypt(this.b64_decode(t),e)
},
b64_table: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
b64_encode: function (t) {
var e = 0,
r = "";
if (!t) return t;
do {
var h = t[e++],
n = t[e++],
i = t[e++],
a = h << 16 | n << 8 | i;
h = a >> 18 & 63, n = a >> 12 & 63, i = a >> 6 & 63, a &= 63, r += this.b64_table.charAt(h) + this.b64_table.charAt(n) + this.b64_table.charAt(i) + this.b64_table.charAt(a)
} while (e < t.length);
return ((t = t.length % 3) ? r.slice(0, t - 3) : r) + "===".slice(t || 3)
},
b64_decode: function (t) {
var e = 0,
r = [];
if (!t) return t;
t += "";
do {
var h = this.b64_table.indexOf(t.charAt(e++)),
n = this.b64_table.indexOf(t.charAt(e++)),
i = this.b64_table.indexOf(t.charAt(e++)),
a = this.b64_table.indexOf(t.charAt(e++)),
c = h << 18 | n << 12 | i << 6 | a;
h = c >> 16 & 255, n = c >> 8 & 255, c &= 255, r.push(h), 64 !== i && (r.push(n), 64 !== a && r.push(c))
} while (e < t.length);
return r
},
keyCharAt: function (t, e) {
return t.charCodeAt(Math.floor(e % t.length))
},
xor_encrypt: function (t,e) {
char_array=Array.from(t)
var sb=[]
for(const c2 of char_array) {
e^=c2.charCodeAt(0);
sb.push(String.fromCharCode(e).charCodeAt(0))
}
return sb
},
xor_decrypt: function (t, e) {
for (var r = [], h = 0; h < t.length; h++)
{
r.push(String.fromCharCode(e ^ t[h]));
e=t[h]
}
return r.join("")
}
};
function Encrypt(str){
return XORCipher.encode(str,72)
}
function Decrypt(str){
return XORCipher.decode(str,72)
}
console.log(Encrypt("2ff70f4f558d14973f074c0a9293b"))
console.log(Decrypt("ehx6TX0bL0l8SXEVJBApHi1Le0x4GytKc0F4Syk="))