地址 :http://game.pps.tv/events/cqss_sign
调用encryptedString('password')
RSA加密,通过function(a) 定义 window={};
再定义RSAUtils=window.RSAUtils || a.RSAUtils;
window={}; (function (a) { var z; if (typeof a.RSAUtils === "undefined") { z = a.RSAUtils = {}; } var l = 2; var m = 16; var o = m; var k = 1 << 16; var h = k >>> 1; var n = k * k; var w = k - 1; var x = 9999999999999998; var v; var A; var g, f; var e = a.BigInt = function (B) { if (typeof B === "boolean" && B === true) { this.digits = null; } else { this.digits = A.slice(0); } this.isNeg = false; }; z.setMaxDigits = function (C) { v = C; A = new Array(v); for (var B = 0; B < A.length; B++) { A[B] = 0; } g = new e(); f = new e(); f.digits[0] = 1; }; z.setMaxDigits(20); var p = 15; z.biFromNumber = function (B) { var D = new e(); D.isNeg = B < 0; B = Math.abs(B); var C = 0; while (B > 0) { D.digits[C++] = B & w; B = Math.floor(B / k); } return D; }; var u = z.biFromNumber(1000000000000000); z.biFromDecimal = function (G) { var E = G.charAt(0) == "-"; var D = E ? 1 : 0; var F; while (D < G.length && G.charAt(D) == "0") { ++D; } if (D == G.length) { F = new e(); } else { var B = G.length - D; var C = B % p; if (C == 0) { C = p; } F = z.biFromNumber(Number(G.substr(D, C))); D += C; while (D < G.length) { F = z.biAdd(z.biMultiply(F, u), z.biFromNumber(Number(G.substr(D, p)))); D += p; } F.isNeg = E; } return F; }; z.biCopy = function (B) { var C = new e(true); C.digits = B.digits.slice(0); C.isNeg = B.isNeg; return C; }; z.reverseStr = function (D) { var C = ""; for (var B = D.length - 1; B > -1; --B) { C += D.charAt(B); } return C; }; var q = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]; z.biToString = function (F, D) { var B = new e(); B.digits[0] = D; var C = z.biDivideModulo(F, B); var E = q[C[1].digits[0]]; while (z.biCompare(C[0], g) == 1) { C = z.biDivideModulo(C[0], B); digit = C[1].digits[0]; E += q[C[1].digits[0]]; } return (F.isNeg ? "-" : "") + z.reverseStr(E); }; z.biToDecimal = function (E) { var B = new e(); B.digits[0] = 10; var C = z.biDivideModulo(E, B); var D = String(C[1].digits[0]); while (z.biCompare(C[0], g) == 1) { C = z.biDivideModulo(C[0], B); D += String(C[1].digits[0]); } return (E.isNeg ? "-" : "") + z.reverseStr(D); }; var r = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"]; z.digitToHex = function (C) { var B = 15; var D = ""; for (i = 0; i < 4; ++i) { D += r[C & B]; C >>>= 4; } return z.reverseStr(D); }; z.biToHex = function (E) { var D = ""; var C = z.biHighIndex(E); for (var B = z.biHighIndex(E); B > -1; --B) { D += z.digitToHex(E.digits[B]); } return D; }; z.charToHex = function (D) { var I = 48; var G = I + 9; var E = 97; var F = E + 25; var B = 65; var C = 65 + 25; var H; if (D >= I && D <= G) { H = D - I; } else { if (D >= B && D <= C) { H = 10 + D - B; } else { if (D >= E && D <= F) { H = 10 + D - E; } else { H = 0; } } } return H; }; z.hexToDigit = function (D) { var C = 0; var E = Math.min(D.length, 4); for (var B = 0; B < E; ++B) { C <<= 4; C |= z.charToHex(D.charCodeAt(B)); } return C; }; z.biFromHex = function (E) { var D = new e(); var F = E.length; for (var B = F, C = 0; B > 0; B -= 4, ++C) { D.digits[C] = z.hexToDigit(E.substr(Math.max(B - 4, 0), Math.min(B, 4))); } return D; }; z.biFromString = function (K, I) { var F = K.charAt(0) == "-"; var G = F ? 1 : 0; var J = new e(); var H = new e(); H.digits[0] = 1; for (var E = K.length - 1; E >= G; E--) { var C = K.charCodeAt(E); var D = z.charToHex(C); var B = z.biMultiplyDigit(H, D); J = z.biAdd(J, B); H = z.biMultiplyDigit(H, I); } J.isNeg = F; return J; }; z.biDump = function (B) { return (B.isNeg ? "-" : "") + B.digits.join(" "); }; z.biAdd = function (F, G) { var E; if (F.isNeg != G.isNeg) { G.isNeg = !G.isNeg; E = z.biSubtract(F, G); G.isNeg = !G.isNeg; } else { E = new e(); var B = 0; var D; for (var C = 0; C < F.digits.length; ++C) { D = F.digits[C] + G.digits[C] + B; E.digits[C] = D % k; B = Number(D >= k); } E.isNeg = F.isNeg; } return E; }; z.biSubtract = function (F, G) { var E; if (F.isNeg != G.isNeg) { G.isNeg = !G.isNeg; E = z.biAdd(F, G); G.isNeg = !G.isNeg; } else { E = new e(); var D, B; B = 0; for (var C = 0; C < F.digits.length; ++C) { D = F.digits[C] - G.digits[C] + B; E.digits[C] = D % k; if (E.digits[C] < 0) { E.digits[C] += k; } B = 0 - Number(D < 0); } if (B == -1) { B = 0; for (var C = 0; C < F.digits.length; ++C) { D = 0 - E.digits[C] + B; E.digits[C] = D % k; if (E.digits[C] < 0) { E.digits[C] += k; } B = 0 - Number(D < 0); } E.isNeg = !F.isNeg; } else { E.isNeg = F.isNeg; } } return E; }; z.biHighIndex = function (C) { var B = C.digits.length - 1; while (B > 0 && C.digits[B] == 0) { --B; } return B; }; z.biNumBits = function (F) { var D = z.biHighIndex(F); var B = F.digits[D]; var C = (D + 1) * o; var E; for (E = C; E > C - o; --E) { if ((B & 32768) != 0) { break; } B <<= 1; } return E; }; z.biMultiply = function (J, K) { var F = new e(); var B; var E = z.biHighIndex(J); var G = z.biHighIndex(K); var H, I, D; for (var C = 0; C <= G; ++C) { B = 0; D = C; for (j = 0; j <= E; ++j, ++D) { I = F.digits[D] + J.digits[j] * K.digits[C] + B; F.digits[D] = I & w; B = I >>> m; } F.digits[C + E + 1] = B; } F.isNeg = J.isNeg != K.isNeg; return F; }; z.biMultiplyDigit = function (F, G) { var D, B, E; result = new e(); D = z.biHighIndex(F); B = 0; for (var C = 0; C <= D; ++C) { E = result.digits[C] + F.digits[C] * G + B; result.digits[C] = E & w; B = E >>> m; } result.digits[1 + D] = B; return result; }; z.arrayCopy = function (H, I, B, C, G) { var F = Math.min(I + G, H.length); for (var D = I, E = C; D < F; ++D, ++E) { B[E] = H[D]; } }; var s = [0, 32768, 49152, 57344, 61440, 63488, 64512, 65024, 65280, 65408, 65472, 65504, 65520, 65528, 65532, 65534, 65535]; z.biShiftLeft = function (I, F) { var C = Math.floor(F / o); var G = new e(); z.arrayCopy(I.digits, 0, G.digits, C, G.digits.length - C); var B = F % o; var H = o - B; for (var D = G.digits.length - 1, E = D - 1; D > 0; --D, --E) { G.digits[D] = ((G.digits[D] << B) & w) | ((G.digits[E] & s[B]) >>> (H)); } G.digits[0] = ((G.digits[D] << B) & w); G.isNeg = I.isNeg; return G; }; var t = [0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535]; z.biShiftRight = function (I, G) { var C = Math.floor(G / o); var H = new e(); z.arrayCopy(I.digits, C, H.digits, 0, I.digits.length - C); var B = G % o; var F = o - B; for (var D = 0, E = D + 1; D < H.digits.length - 1; ++D, ++E) { H.digits[D] = (H.digits[D] >>> B) | ((H.digits[E] & t[B]) << F); } H.digits[H.digits.length - 1] >>>= B; H.isNeg = I.isNeg; return H; }; z.biMultiplyByRadixPower = function (D, B) { var C = new e(); z.arrayCopy(D.digits, 0, C.digits, B, C.digits.length - B); return C; }; z.biDivideByRadixPower = function (D, B) { var C = new e(); z.arrayCopy(D.digits, B, C.digits, 0, C.digits.length - B); return C; }; z.biModuloByRadixPower = function (D, B) { var C = new e(); z.arrayCopy(D.digits, 0, C.digits, 0, B); return C; }; z.biCompare = function (C, D) { if (C.isNeg != D.isNeg) { return 1 - 2 * Number(C.isNeg); } for (var B = C.digits.length - 1; B >= 0; --B) { if (C.digits[B] != D.digits[B]) { if (C.isNeg) { return 1 - 2 * Number(C.digits[B] > D.digits[B]); } else { return 1 - 2 * Number(C.digits[B] < D.digits[B]); } } } return 0; }; z.biDivideModulo = function (Q, R) { var H = z.biNumBits(Q); var P = z.biNumBits(R); var I = R.isNeg; var J, K; if (H < P) { if (Q.isNeg) { J = z.biCopy(f); J.isNeg = !R.isNeg; Q.isNeg = false; R.isNeg = false; K = biSubtract(R, Q); Q.isNeg = true; R.isNeg = I; } else { J = new e(); K = z.biCopy(Q); } return [J, K]; } J = new e(); K = Q; var O = Math.ceil(P / o) - 1; var F = 0; while (R.digits[O] < h) { R = z.biShiftLeft(R, 1); ++F; ++P; O = Math.ceil(P / o) - 1; } K = z.biShiftLeft(K, F); H += F; var G = Math.ceil(H / o) - 1; var B = z.biMultiplyByRadixPower(R, G - O); while (z.biCompare(K, B) != -1) { ++J.digits[G - O]; K = z.biSubtract(K, B); } for (var E = G; E > O; --E) { var L = (E >= K.digits.length) ? 0 : K.digits[E]; var M = (E - 1 >= K.digits.length) ? 0 : K.digits[E - 1]; var N = (E - 2 >= K.digits.length) ? 0 : K.digits[E - 2]; var S = (O >= R.digits.length) ? 0 : R.digits[O]; var T = (O - 1 >= R.digits.length) ? 0 : R.digits[O - 1]; if (L == S) { J.digits[E - O - 1] = w; } else { J.digits[E - O - 1] = Math.floor((L * k + M) / S); } var C = J.digits[E - O - 1] * ((S * k) + T); var D = (L * n) + ((M * k) + N); while (C > D) { --J.digits[E - O - 1]; C = J.digits[E - O - 1] * ((S * k) | T); D = (L * k * k) + ((M * k) + N); } B = z.biMultiplyByRadixPower(R, E - O - 1); K = z.biSubtract(K, z.biMultiplyDigit(B, J.digits[E - O - 1])); if (K.isNeg) { K = z.biAdd(K, B); --J.digits[E - O - 1]; } } K = z.biShiftRight(K, F); J.isNeg = Q.isNeg != I; if (Q.isNeg) { if (I) { J = z.biAdd(J, f); } else { J = z.biSubtract(J, f); } R = z.biShiftRight(R, F); K = z.biSubtract(R, K); } if (K.digits[0] == 0 && z.biHighIndex(K) == 0) { K.isNeg = false; } return [J, K]; }; z.biDivide = function (B, C) { return z.biDivideModulo(B, C)[0]; }; z.biModulo = function (B, C) { return z.biDivideModulo(B, C)[1]; }; z.biMultiplyMod = function (C, D, B) { return z.biModulo(z.biMultiply(C, D), B); }; z.biPow = function (D, E) { var C = f; var B = D; while (true) { if ((E & 1) != 0) { C = z.biMultiply(C, B); } E >>= 1; if (E == 0) { break; } B = z.biMultiply(B, B); } return C; }; z.biPowMod = function (F, G, D) { var E = f; var B = F; var C = G; while (true) { if ((C.digits[0] & 1) != 0) { E = z.biMultiplyMod(E, B, D); } C = z.biShiftRight(C, 1); if (C.digits[0] == 0 && z.biHighIndex(C) == 0) { break; } B = z.biMultiplyMod(B, B, D); } return E; }; a.BarrettMu = function (C) { this.modulus = z.biCopy(C); this.k = z.biHighIndex(this.modulus) + 1; var B = new e(); B.digits[2 * this.k] = 1; this.mu = z.biDivide(B, this.modulus); this.bkplus1 = new e(); this.bkplus1.digits[this.k + 1] = 1; this.modulo = b; this.multiplyMod = c; this.powMod = d; }; function b(K) { var B = z; var C = B.biDivideByRadixPower(K, this.k - 1); var D = B.biMultiply(C, this.mu); var E = B.biDivideByRadixPower(D, this.k + 1); var G = B.biModuloByRadixPower(K, this.k + 1); var I = B.biMultiply(E, this.modulus); var H = B.biModuloByRadixPower(I, this.k + 1); var F = B.biSubtract(G, H); if (F.isNeg) { F = B.biAdd(F, this.bkplus1); } var J = B.biCompare(F, this.modulus) >= 0; while (J) { F = B.biSubtract(F, this.modulus); J = B.biCompare(F, this.modulus) >= 0; } return F; } function c(B, D) { var C = z.biMultiply(B, D); return this.modulo(C); } function d(E, F) { var D = new e(); D.digits[0] = 1; var B = E; var C = F; while (true) { if ((C.digits[0] & 1) != 0) { D = this.multiplyMod(D, B); } C = z.biShiftRight(C, 1); if (C.digits[0] == 0 && z.biHighIndex(C) == 0) { break; } B = this.multiplyMod(B, B); } return D; } var y = function (D, C, E) { var B = z; this.e = B.biFromHex(D); this.d = B.biFromHex(C); this.m = B.biFromHex(E); this.chunkSize = 2 * B.biHighIndex(this.m); this.radix = 16; this.barrett = new a.BarrettMu(this.m); }; z.getKeyPair = function (C, B, D) { return new y(C, B, D); }; if (typeof a.twoDigit === "undefined") { a.twoDigit = function (B) { return (B < 10 ? "0" : "") + String(B); }; } z.encryptedString = function (I, K) { var B = []; var L = K.length; var F = 0; while (F < L) { B[F] = K.charCodeAt(F); F++; } while (B.length % I.chunkSize != 0) { B[F++] = 0; } var C = B.length; var J = ""; var G, H, D; for (F = 0; F < C; F += I.chunkSize) { D = new e(); G = 0; for (H = F; H < F + I.chunkSize; ++G) { D.digits[G] = B[H++]; D.digits[G] += B[H++] << 8; } var E = I.barrett.powMod(D, I.e); var M = I.radix == 16 ? z.biToHex(E) : z.biToString(E, I.radix); J += M + " "; } return J.substring(0, J.length - 1); }; z.decryptedString = function (G, I) { var D = I.split(" "); var H = ""; var E, F, C; for (E = 0; E < D.length; ++E) { var B; if (G.radix == 16) { B = z.biFromHex(D[E]); } else { B = z.biFromString(D[E], G.radix); } C = G.barrett.powMod(B, G.d); for (F = 0; F <= z.biHighIndex(C); ++F) { H += String.fromCharCode(C.digits[F] & 255, C.digits[F] >> 8); } } if (H.charCodeAt(H.length - 1) == 0) { H = H.substring(0, H.length - 1); } return H; }; z.setMaxDigits(130); })(window); RSAUtils=window.RSAUtils || a.RSAUtils; function encryptedString(password) { var key_modulus = "ab86b6371b5318aaa1d3c9e612a9f1264f372323c8c0f19875b5fc3b3fd3afcc1e5bec527aa94bfa85bffc157e4245aebda05389a5357b75115ac94f074aefcd"; var key = RSAUtils.getKeyPair("10001", "", key_modulus); return RSAUtils.encryptedString(key, encodeURIComponent(password)).replace(/\s/g, "-"); }