|

- var base64EncodeChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
- var 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);
-
- function base64encode(str) {
- var out, i, len;
- var c1, c2, c3;
-
- len = str.length;
- i = 0;
- out = "";
- while(i < len) {
- c1 = str.charCodeAt(i++) & 0xff;
- if(i == len)
- {
- out += base64EncodeChars.charAt(c1 >> 2);
- out += base64EncodeChars.charAt((c1 & 0x3) << 4);
- out += "==";
- break;
- }
- c2 = str.charCodeAt(i++);
- if(i == len)
- {
- out += base64EncodeChars.charAt(c1 >> 2);
- out += base64EncodeChars.charAt(((c1 & 0x3)<< 4) | ((c2 & 0xF0) >> 4));
- out += base64EncodeChars.charAt((c2 & 0xF) << 2);
- out += "=";
- break;
- }
- c3 = str.charCodeAt(i++);
- out += base64EncodeChars.charAt(c1 >> 2);
- out += base64EncodeChars.charAt(((c1 & 0x3)<< 4) | ((c2 & 0xF0) >> 4));
- out += base64EncodeChars.charAt(((c2 & 0xF) << 2) | ((c3 & 0xC0) >>6));
- out += base64EncodeChars.charAt(c3 & 0x3F);
- }
- return out;
- }
-
- function base64decode(str) {
- var c1, c2, c3, c4;
- var i, len, out;
-
- len = str.length;
- i = 0;
- out = "";
- while(i < len) {
- /* c1 */
- do {
- c1 = base64DecodeChars[str.charCodeAt(i++) & 0xff];
- } while(i < len && c1 == -1);
- if(c1 == -1)
- break;
-
- /* c2 */
- do {
- c2 = base64DecodeChars[str.charCodeAt(i++) & 0xff];
- } while(i < len && c2 == -1);
- if(c2 == -1)
- break;
-
- out += String.fromCharCode((c1 << 2) | ((c2 & 0x30) >> 4));
-
- /* c3 */
- do {
- c3 = str.charCodeAt(i++) & 0xff;
- if(c3 == 61)
- return out;
- c3 = base64DecodeChars[c3];
- } while(i < len && c3 == -1);
- if(c3 == -1)
- break;
-
- out += String.fromCharCode(((c2 & 0XF) << 4) | ((c3 & 0x3C) >> 2));
-
- /* c4 */
- do {
- c4 = str.charCodeAt(i++) & 0xff;
- if(c4 == 61)
- return out;
- c4 = base64DecodeChars[c4];
- } while(i < len && c4 == -1);
- if(c4 == -1)
- break;
- out += String.fromCharCode(((c3 & 0x03) << 6) | c4);
- }
- return out;
- }
-
- function utf16to8(str) {
- var out, i, len, c;
-
- out = "";
- len = str.length;
- for(i = 0; i < len; i++) {
- c = str.charCodeAt(i);
- if ((c >= 0x0001) && (c <= 0x007F)) {
- out += str.charAt(i);
- } else if (c > 0x07FF) {
- out += String.fromCharCode(0xE0 | ((c >> 12) & 0x0F));
- out += String.fromCharCode(0x80 | ((c >> 6) & 0x3F));
- out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F));
- } else {
- out += String.fromCharCode(0xC0 | ((c >> 6) & 0x1F));
- out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F));
- }
- }
- return out;
- }
-
- function utf8to16(str) {
- var out, i, len, c;
- var char2, char3;
-
- out = "";
- len = str.length;
- i = 0;
- while(i < len) {
- c = str.charCodeAt(i++);
- switch(c >> 4)
- {
- case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7:
- // 0xxxxxxx
- out += str.charAt(i-1);
- break;
- case 12: case 13:
- // 110x xxxx 10xx xxxx
- char2 = str.charCodeAt(i++);
- out += String.fromCharCode(((c & 0x1F) << 6) | (char2 & 0x3F));
- break;
- case 14:
- // 1110 xxxx 10xx xxxx 10xx xxxx
- char2 = str.charCodeAt(i++);
- char3 = str.charCodeAt(i++);
- out += String.fromCharCode(((c & 0x0F) << 12) |
- ((char2 & 0x3F) << 6) |
- ((char3 & 0x3F) << 0));
- break;
- }
- }
-
- return out;
- }
-
- function CharToHex(str) {
- var out, i, len, c, h;
-
- out = "";
- len = str.length;
- i = 0;
- while(i < len)
- {
- c = str.charCodeAt(i++);
- h = c.toString(16);
- if(h.length < 2)
- h = "0" + h;
-
- out += "\\x" + h + " ";
- if(i > 0 && i % 8 == 0)
- out += "\r\n";
- }
-
- return out;
- }
- //这是 https://www.ctyun.cn/auth/#/login 登录密码的加密js
- //encrypt("[email protected]","666666");
- function encrypt(t,e){
- var n = c(t, 0, 24);
- return base64encode(s(n.key, e, 1, 0, 0, 1));
- }
- c = function c(t, e, n) {
- return {
- key: u(t.slice(e, n)),
- vector: 1
- };
- }
- u = function u(t) {
- for (var e = t.length; e < 24; e++) {
- t += "0";
- }
- return t;
- }
- s = function s(t, e, n, r, i, o) {
-
- n && (e = unescape(encodeURIComponent(e)));
- var s, c, u, l, d, f, h, p, v, m, g, b, y, _, x = new Array(16843776,0,65536,16843780,16842756,66564,4,65536,1024,16843776,16843780,1024,16778244,16842756,16777216,4,1028,16778240,16778240,66560,66560,16842752,16842752,16778244,65540,16777220,16777220,65540,0,1028,66564,16777216,65536,16843780,4,16842752,16843776,16777216,16777216,1024,16842756,65536,66560,16777220,1024,4,16778244,66564,16843780,65540,16842752,16778244,16777220,1028,66564,16843776,1028,16778240,16778240,0,65540,66560,0,16842756), w = new Array(-2146402272,-2147450880,32768,1081376,1048576,32,-2146435040,-2147450848,-2147483616,-2146402272,-2146402304,-2147483648,-2147450880,1048576,32,-2146435040,1081344,1048608,-2147450848,0,-2147483648,32768,1081376,-2146435072,1048608,-2147483616,0,1081344,32800,-2146402304,-2146435072,32800,0,1081376,-2146435040,1048576,-2147450848,-2146435072,-2146402304,32768,-2146435072,-2147450880,32,-2146402272,1081376,32,32768,-2147483648,32800,-2146402304,1048576,-2147483616,1048608,-2147450848,-2147483616,1048608,1081344,0,-2147450880,32800,-2147483648,-2146435040,-2146402272,1081344), C = new Array(520,134349312,0,134348808,134218240,0,131592,134218240,131080,134217736,134217736,131072,134349320,131080,134348800,520,134217728,8,134349312,512,131584,134348800,134348808,131592,134218248,131584,131072,134218248,8,134349320,512,134217728,134349312,134217728,131080,520,131072,134349312,134218240,0,512,131080,134349320,134218240,134217736,512,0,134348808,134218248,131072,134217728,134349320,8,131592,131584,134217736,134348800,134218248,520,134348800,131592,8,134348808,131584), k = new Array(8396801,8321,8321,128,8396928,8388737,8388609,8193,0,8396800,8396800,8396929,129,0,8388736,8388609,1,8192,8388608,8396801,128,8388608,8193,8320,8388737,1,8320,8388736,8192,8396928,8396929,129,8388736,8388609,8396800,8396929,129,0,0,8396800,8320,8388736,8388737,1,8396801,8321,8321,128,8396929,129,1,8192,8388609,8193,8396928,8388737,8193,8320,8388608,8396801,128,8388608,8192,8396928), A = new Array(256,34078976,34078720,1107296512,524288,256,1073741824,34078720,1074266368,524288,33554688,1074266368,1107296512,1107820544,524544,1073741824,33554432,1074266112,1074266112,0,1073742080,1107820800,1107820800,33554688,1107820544,1073742080,0,1107296256,34078976,33554432,1107296256,524544,524288,1107296512,256,33554432,1073741824,34078720,1107296512,1074266368,33554688,1073741824,1107820544,34078976,1074266368,256,33554432,1107820544,1107820800,524544,1107296256,1107820800,34078720,0,1074266112,1107296256,524544,33554688,1073742080,524288,0,1074266112,34078976,1073742080), I = new Array(536870928,541065216,16384,541081616,541065216,16,541081616,4194304,536887296,4210704,4194304,536870928,4194320,536887296,536870912,16400,0,4194320,536887312,16384,4210688,536887312,16,541065232,541065232,0,4210704,541081600,16400,4210688,541081600,536870912,536887296,16,541065232,4210688,541081616,4194304,16400,536870928,4194304,536887296,536870912,16400,536870928,541081616,4210688,541065216,4210704,541081600,0,541065232,16,16384,541065216,4210704,16384,4194320,536887312,0,541081600,536870912,4194320,536887312), S = new Array(2097152,69206018,67110914,0,2048,67110914,2099202,69208064,69208066,2097152,0,67108866,2,67108864,69206018,2050,67110912,2099202,2097154,67110912,67108866,69206016,69208064,2097154,69206016,2048,2050,69208066,2099200,2,67108864,2099200,67108864,2099200,2097152,67110914,67110914,69206018,69206018,2,2097154,67108864,67110912,2097152,69208064,2050,2099202,69208064,2050,67108866,69208066,69206016,2099200,0,2,69208066,0,2099202,69206016,2048,67108866,67110912,2048,2097154), E = new Array(268439616,4096,262144,268701760,268435456,268439616,64,268435456,262208,268697600,268701760,266240,268701696,266304,4096,64,268697600,268435520,268439552,4160,266240,262208,268697664,268701696,4160,0,0,268697664,268435520,268439552,266304,262144,266304,262144,268701696,4096,64,268697664,4096,266304,268439552,64,268435520,268697600,268697664,268435456,262144,268439616,0,268701760,262208,268435520,268697600,268439552,268439616,0,268701760,266240,266240,4160,4160,262208,268435456,268701696), M = a(t), $ = 0, T = e.length, P = 0, O = 32 == M.length ? 3 : 9;
- p = 3 == O ? n ? new Array(0,32,2) : new Array(30,-2,-2) : n ? new Array(0,32,2,62,30,-2,64,96,2) : new Array(94,62,-2,32,64,2,30,-2,-2),
- 2 == o ? e += " " : 1 == o ? n && (u = 8 - T % 8,
- e += String.fromCharCode(u, u, u, u, u, u, u, u),
- 8 === u && (T += 8)) : o || (e += "\0\0\0\0\0\0\0\0");
- var D = ""
- , R = "";
- for (1 == r && (v = i.charCodeAt($++) << 24 | i.charCodeAt($++) << 16 | i.charCodeAt($++) << 8 | i.charCodeAt($++),
- g = i.charCodeAt($++) << 24 | i.charCodeAt($++) << 16 | i.charCodeAt($++) << 8 | i.charCodeAt($++),
- $ = 0); $ < T; ) {
- for (f = e.charCodeAt($++) << 24 | e.charCodeAt($++) << 16 | e.charCodeAt($++) << 8 | e.charCodeAt($++),
- h = e.charCodeAt($++) << 24 | e.charCodeAt($++) << 16 | e.charCodeAt($++) << 8 | e.charCodeAt($++),
- 1 == r && (n ? (f ^= v,
- h ^= g) : (m = v,
- b = g,
- v = f,
- g = h)),
- f ^= (u = 252645135 & (f >>> 4 ^ h)) << 4,
- f ^= (u = 65535 & (f >>> 16 ^ (h ^= u))) << 16,
- f ^= u = 858993459 & ((h ^= u) >>> 2 ^ f),
- f ^= u = 16711935 & ((h ^= u << 2) >>> 8 ^ f),
- f = (f ^= (u = 1431655765 & (f >>> 1 ^ (h ^= u << 8))) << 1) << 1 | f >>> 31,
- h = (h ^= u) << 1 | h >>> 31,
- c = 0; c < O; c += 3) {
- for (y = p[c + 1],
- _ = p[c + 2],
- s = p[c]; s != y; s += _) {
- l = h ^ M[s],
- d = (h >>> 4 | h << 28) ^ M[s + 1],
- u = f,
- f = h,
- h = u ^ (w[l >>> 24 & 63] | k[l >>> 16 & 63] | I[l >>> 8 & 63] | E[63 & l] | x[d >>> 24 & 63] | C[d >>> 16 & 63] | A[d >>> 8 & 63] | S[63 & d]);
- }
- u = f,
- f = h,
- h = u;
- }
- h = h >>> 1 | h << 31,
- h ^= u = 1431655765 & ((f = f >>> 1 | f << 31) >>> 1 ^ h),
- h ^= (u = 16711935 & (h >>> 8 ^ (f ^= u << 1))) << 8,
- h ^= (u = 858993459 & (h >>> 2 ^ (f ^= u))) << 2,
- h ^= u = 65535 & ((f ^= u) >>> 16 ^ h),
- h ^= u = 252645135 & ((f ^= u << 16) >>> 4 ^ h),
- f ^= u << 4,
- 1 == r && (n ? (v = f,
- g = h) : (f ^= m,
- h ^= b)),
- R += String.fromCharCode(f >>> 24, f >>> 16 & 255, f >>> 8 & 255, 255 & f, h >>> 24, h >>> 16 & 255, h >>> 8 & 255, 255 & h),
- 512 == (P += 8) && (D += R,
- R = "",
- P = 0);
- }
- if (D += R,
- !n) {
- if (1 === o) {
- var j = D.length
- , L = 0;
- j && (L = D.charCodeAt(j - 1)),
- L <= 8 && (D = D.substring(0, j - L));
- }
- D = decodeURIComponent(escape(D));
- }
- return D;
- }
- a = function a(t) {
- for (var e, n, r, i = new Array(0,4,536870912,536870916,65536,65540,536936448,536936452,512,516,536871424,536871428,66048,66052,536936960,536936964), o = new Array(0,1,1048576,1048577,67108864,67108865,68157440,68157441,256,257,1048832,1048833,67109120,67109121,68157696,68157697), s = new Array(0,8,2048,2056,16777216,16777224,16779264,16779272,0,8,2048,2056,16777216,16777224,16779264,16779272), a = new Array(0,2097152,134217728,136314880,8192,2105344,134225920,136323072,131072,2228224,134348800,136445952,139264,2236416,134356992,136454144), c = new Array(0,262144,16,262160,0,262144,16,262160,4096,266240,4112,266256,4096,266240,4112,266256), u = new Array(0,1024,32,1056,0,1024,32,1056,33554432,33555456,33554464,33555488,33554432,33555456,33554464,33555488), l = new Array(0,268435456,524288,268959744,2,268435458,524290,268959746,0,268435456,524288,268959744,2,268435458,524290,268959746), d = new Array(0,65536,2048,67584,536870912,536936448,536872960,536938496,131072,196608,133120,198656,537001984,537067520,537004032,537069568), f = new Array(0,262144,0,262144,2,262146,2,262146,33554432,33816576,33554432,33816576,33554434,33816578,33554434,33816578), h = new Array(0,268435456,8,268435464,0,268435456,8,268435464,1024,268436480,1032,268436488,1024,268436480,1032,268436488), p = new Array(0,32,0,32,1048576,1048608,1048576,1048608,8192,8224,8192,8224,1056768,1056800,1056768,1056800), v = new Array(0,16777216,512,16777728,2097152,18874368,2097664,18874880,67108864,83886080,67109376,83886592,69206016,85983232,69206528,85983744), m = new Array(0,4096,134217728,134221824,524288,528384,134742016,134746112,16,4112,134217744,134221840,524304,528400,134742032,134746128), g = new Array(0,4,256,260,0,4,256,260,1,5,257,261,1,5,257,261), b = t.length > 8 ? 3 : 1, y = new Array(32 * b), _ = new Array(0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0), x = 0, w = 0, C = 0; C < b; C++) {
- var k = t.charCodeAt(x++) << 24 | t.charCodeAt(x++) << 16 | t.charCodeAt(x++) << 8 | t.charCodeAt(x++)
- , A = t.charCodeAt(x++) << 24 | t.charCodeAt(x++) << 16 | t.charCodeAt(x++) << 8 | t.charCodeAt(x++);
- k ^= (r = 252645135 & (k >>> 4 ^ A)) << 4,
- k ^= r = 65535 & ((A ^= r) >>> -16 ^ k),
- k ^= (r = 858993459 & (k >>> 2 ^ (A ^= r << -16))) << 2,
- k ^= r = 65535 & ((A ^= r) >>> -16 ^ k),
- k ^= (r = 1431655765 & (k >>> 1 ^ (A ^= r << -16))) << 1,
- k ^= r = 16711935 & ((A ^= r) >>> 8 ^ k),
- r = (k ^= (r = 1431655765 & (k >>> 1 ^ (A ^= r << 8))) << 1) << 8 | (A ^= r) >>> 20 & 240,
- k = A << 24 | A << 8 & 16711680 | A >>> 8 & 65280 | A >>> 24 & 240,
- A = r;
- for (var I = 0; I < _.length; I++) {
- _[I] ? (k = k << 2 | k >>> 26,
- A = A << 2 | A >>> 26) : (k = k << 1 | k >>> 27,
- A = A << 1 | A >>> 27),
- A &= -15,
- e = i[(k &= -15) >>> 28] | o[k >>> 24 & 15] | s[k >>> 20 & 15] | a[k >>> 16 & 15] | c[k >>> 12 & 15] | u[k >>> 8 & 15] | l[k >>> 4 & 15],
- r = 65535 & ((n = d[A >>> 28] | f[A >>> 24 & 15] | h[A >>> 20 & 15] | p[A >>> 16 & 15] | v[A >>> 12 & 15] | m[A >>> 8 & 15] | g[A >>> 4 & 15]) >>> 16 ^ e),
- y[w++] = e ^ r,
- y[w++] = n ^ r << 16;
- }
- }
- return y;
- }
复制代码
|
|