Commit ced5769b authored by xinzhedeai's avatar xinzhedeai

爱山东获取用户信息 加密授权版本

parent 27e5d7cd
...@@ -7,6 +7,10 @@ ...@@ -7,6 +7,10 @@
content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0, viewprot-fit:cover"> content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0, viewprot-fit:cover">
<title>高区应急系统-首页</title> <title>高区应急系统-首页</title>
<script type="text/javascript" src="./js/includeHead.js"></script> <script type="text/javascript" src="./js/includeHead.js"></script>
<script type="text/javascript" src="//cdn.bootcdn.net/ajax/libs/eruda/2.4.1/eruda.js"></script>
<script>
eruda.init();
</script>
<style> <style>
.wrapper .item { .wrapper .item {
width: 7.5rem; width: 7.5rem;
...@@ -49,6 +53,10 @@ ...@@ -49,6 +53,10 @@
</style> </style>
</head> </head>
<body> <body>
<script type="text/javascript" src="https://isdapp.shandong.gov.cn/jmopen/jssdk/index.js"></script>
<script type="text/javascript" src="js/jssdk2/aes.js"></script>
<script type='text/javascript' src="js/jssdk2/sm2/build/SM.js"></script>
<script type="text/javascript" src="js/jssdk2/index.js"></script>
<div id="app"> <div id="app">
<div class="wrapper"> <div class="wrapper">
<div class=""> <div class="">
......
...@@ -9,10 +9,20 @@ window.addEventListener("load", function() { ...@@ -9,10 +9,20 @@ window.addEventListener("load", function() {
} }
}, },
mounted() { mounted() {
http2.post({
serviceId: 'gqyjglptthHiddenDanger',
interfacePublicKey: "041a0802713d674bfc3db46293d83e2b3ebe99cd0ee9b5ae507a0aa07f41cd8bf1407d8c16fab3ceb28bfa233452417373ac0c7864e085895a27b4ebf14b2eb3b1",
interfacePrivateKey: "73ae80b0f34740ce795821bf4354f1621e4ab7d01d9f3f7fc7c05e52c527c528",
reqParams: {id: '4234234'}
}, function(res){
if(res){
console.log('接口回调数据', JSON.parse(res))
}
})
}, },
methods: { methods: {
nav(type){ nav(type){
gemhoUtil.navigatePage('./views/'+ type +'.html') gemhoUtil.navigatePage('./src/'+ type +'.html')
}, },
}, },
}); });
......
/** 爱山东网管请求封装
* 请求拦截、相应拦截、错误统一处理
*/
// const appmark = "sdzwapp"
var http2 = {
post: function(params, fn) {
/**
* 网关验签接口
* @param {1} = appid应用唯一标识
* @param {2} = interfaceid接口唯一标识
* @param {3} = interfacecontent接口参数,请使用json格式, 例如:{"siteid":"2","cateid":"1"}
* @param {4} = fromport端口来源"0":PC;"1":APP;"2":支付宝;"3":微信
* @param {5} = signurl签名接口地址
* @param {6} = gatewayurl网关接口地址
* @param {7} = extraData 额外参数,附件,请求头一类的参数
*
*/
// var params = '{"ticket":"' + ticket + '"}'
// const interfaceContent = {
// app_id: appmark,
// servicename: "ticketValidate",
// params: params
// }
// var params = '{"ticket":"' + ticket + '"}'
// debugger
const interfaceContent = {
// app_id: appmark,
// servicename: param.serviceId, // "ticketValidate",
params: SM.decrypt(JSON.stringify(params.reqParams), params.interfacePublicKey)
}
const data = SM.encrypt(JSON.stringify(params.reqParams), params.interfacePublicKey)
// const data = JSON.stringify(params.reqParams)
console.log('http2方法进来了', JSON.stringify(params.reqParams))
const headers = {
Authorization: "Bearer eyJhbGciOiJIUzUxMiJ9.eyJqdGkiOiI0ODA3ODFkZmQxYmE0MmM0OGQyZDQ5NTllYzcyYTUwNCIsInVzZXIiOiJqYyIsInN1YiI6ImpjIn0.WfLq11T7iWPiMuzqDY2N54aIqdv-ciYCe6pINqQAeBdqlMiJmkufsqlD2YMmUzsHA-o4WerkiSYnPzexEMiAJA"
}
const extraData = {
header: {
Authorization: "Bearer eyJhbGciOiJIUzUxMiJ9.eyJqdGkiOiI0ODA3ODFkZmQxYmE0MmM0OGQyZDQ5NTllYzcyYTUwNCIsInVzZXIiOiJqYyIsInN1YiI6ImpjIn0.WfLq11T7iWPiMuzqDY2N54aIqdv-ciYCe6pINqQAeBdqlMiJmkufsqlD2YMmUzsHA-o4WerkiSYnPzexEMiAJA"
},
}
// vaildInterfacefn("jisnzjk", "ticketvalidate", JSON.stringify(interfaceContent), "1", "https://" + urldomaincreatesign, "https://" + urldomaingateway).then((value) => {
// vaildInterfaceWithHeadersfn(appid, interfaceid, interfacecontent, fromport, headers, signurl, gatewayurl)
// vaildInterfaceWithHeadersfn("gqyjglptxiefn", params.serviceId, data, "1", headers, "https://" + urldomaincreatesign, "https://" + urldomaingateway).then((value) => {
// vaildInterfacefn("gqyjglptxiefn", params.serviceId, data, "1", "https://" + urldomaincreatesign, "https://" + urldomaingateway).then((value) => {
vaildInterfacefn("gqyjglptxiefn", params.serviceId, data, "1", extraData).then((value) => {
if(value.code === '401'){
vant.Dialog.alert({
title: '信息提示',
message: value.msg,
})
return
}
console.log('vaildInterfacefn响应', value)
/**
* code: 200
data: "048b04671ad85e52e" // value 值就是接口返回的data值
msg: "请求成功"
success: true
*/
let sm2_encrypt_result = value
let sm2_decrypt_result = sm2_Decrypt(sm2_encrypt_result, params.interfacePrivateKey)
console.log('vaildInterfacefn响应解密', sm2_decrypt_result)
fn && fn(sm2_decrypt_result)
})
},
}
\ No newline at end of file
...@@ -19,7 +19,7 @@ document.write('<script type="text/javascript" src="' + contextPath + '/js/vue.m ...@@ -19,7 +19,7 @@ document.write('<script type="text/javascript" src="' + contextPath + '/js/vue.m
<script type="text/javascript" src="' + contextPath + '/js/flexible.js"></script>\ <script type="text/javascript" src="' + contextPath + '/js/flexible.js"></script>\
<script type="text/javascript" src="' + contextPath + '/js/util.js?rev=' + jsVersion + '"></script>\ <script type="text/javascript" src="' + contextPath + '/js/util.js?rev=' + jsVersion + '"></script>\
<script type="text/javascript" src="' + contextPath + '/js/common.js?rev=' + jsVersion + '"></script>\ <script type="text/javascript" src="' + contextPath + '/js/common.js?rev=' + jsVersion + '"></script>\
<script type="text/javascript" src="' + contextPath + '/js/http.js?rev=' + jsVersion + '"></script>'); <script type="text/javascript" src="' + contextPath + '/js/http2.js?rev=' + jsVersion + '"></script>');
......
/*
CryptoJS v3.1.2
code.google.com/p/crypto-js
(c) 2009-2013 by Jeff Mott. All rights reserved.
code.google.com/p/crypto-js/wiki/License
*/
var CryptoJS = CryptoJS || function(u, p) {
var d = {},
l = d.lib = {},
s = function() {},
t = l.Base = {
extend: function(a) {
s.prototype = this;
var c = new s;
a && c.mixIn(a);
c.hasOwnProperty("init") || (c.init = function() {
c.$super.init.apply(this, arguments)
});
c.init.prototype = c;
c.$super = this;
return c
},
create: function() {
var a = this.extend();
a.init.apply(a, arguments);
return a
},
init: function() {},
mixIn: function(a) {
for(var c in a) a.hasOwnProperty(c) && (this[c] = a[c]);
a.hasOwnProperty("toString") && (this.toString = a.toString)
},
clone: function() {
return this.init.prototype.extend(this)
}
},
r = l.WordArray = t.extend({
init: function(a, c) {
a = this.words = a || [];
this.sigBytes = c != p ? c : 4 * a.length
},
toString: function(a) {
return(a || v).stringify(this)
},
concat: function(a) {
var c = this.words,
e = a.words,
j = this.sigBytes;
a = a.sigBytes;
this.clamp();
if(j % 4)
for(var k = 0; k < a; k++) c[j + k >>> 2] |= (e[k >>> 2] >>> 24 - 8 * (k % 4) & 255) << 24 - 8 * ((j + k) % 4);
else if(65535 < e.length)
for(k = 0; k < a; k += 4) c[j + k >>> 2] = e[k >>> 2];
else c.push.apply(c, e);
this.sigBytes += a;
return this
},
clamp: function() {
var a = this.words,
c = this.sigBytes;
a[c >>> 2] &= 4294967295 <<
32 - 8 * (c % 4);
a.length = u.ceil(c / 4)
},
clone: function() {
var a = t.clone.call(this);
a.words = this.words.slice(0);
return a
},
random: function(a) {
for(var c = [], e = 0; e < a; e += 4) c.push(4294967296 * u.random() | 0);
return new r.init(c, a)
}
}),
w = d.enc = {},
v = w.Hex = {
stringify: function(a) {
var c = a.words;
a = a.sigBytes;
for(var e = [], j = 0; j < a; j++) {
var k = c[j >>> 2] >>> 24 - 8 * (j % 4) & 255;
e.push((k >>> 4).toString(16));
e.push((k & 15).toString(16))
}
return e.join("")
},
parse: function(a) {
for(var c = a.length, e = [], j = 0; j < c; j += 2) e[j >>> 3] |= parseInt(a.substr(j,
2), 16) << 24 - 4 * (j % 8);
return new r.init(e, c / 2)
}
},
b = w.Latin1 = {
stringify: function(a) {
var c = a.words;
a = a.sigBytes;
for(var e = [], j = 0; j < a; j++) e.push(String.fromCharCode(c[j >>> 2] >>> 24 - 8 * (j % 4) & 255));
return e.join("")
},
parse: function(a) {
for(var c = a.length, e = [], j = 0; j < c; j++) e[j >>> 2] |= (a.charCodeAt(j) & 255) << 24 - 8 * (j % 4);
return new r.init(e, c)
}
},
x = w.Utf8 = {
stringify: function(a) {
try {
return decodeURIComponent(escape(b.stringify(a)))
} catch(c) {
throw Error("Malformed UTF-8 data");
}
},
parse: function(a) {
return b.parse(unescape(encodeURIComponent(a)))
}
},
q = l.BufferedBlockAlgorithm = t.extend({
reset: function() {
this._data = new r.init;
this._nDataBytes = 0
},
_append: function(a) {
"string" == typeof a && (a = x.parse(a));
this._data.concat(a);
this._nDataBytes += a.sigBytes
},
_process: function(a) {
var c = this._data,
e = c.words,
j = c.sigBytes,
k = this.blockSize,
b = j / (4 * k),
b = a ? u.ceil(b) : u.max((b | 0) - this._minBufferSize, 0);
a = b * k;
j = u.min(4 * a, j);
if(a) {
for(var q = 0; q < a; q += k) this._doProcessBlock(e, q);
q = e.splice(0, a);
c.sigBytes -= j
}
return new r.init(q, j)
},
clone: function() {
var a = t.clone.call(this);
a._data = this._data.clone();
return a
},
_minBufferSize: 0
});
l.Hasher = q.extend({
cfg: t.extend(),
init: function(a) {
this.cfg = this.cfg.extend(a);
this.reset()
},
reset: function() {
q.reset.call(this);
this._doReset()
},
update: function(a) {
this._append(a);
this._process();
return this
},
finalize: function(a) {
a && this._append(a);
return this._doFinalize()
},
blockSize: 16,
_createHelper: function(a) {
return function(b, e) {
return(new a.init(e)).finalize(b)
}
},
_createHmacHelper: function(a) {
return function(b, e) {
return(new n.HMAC.init(a,
e)).finalize(b)
}
}
});
var n = d.algo = {};
return d
}(Math);
(function() {
var u = CryptoJS,
p = u.lib.WordArray;
u.enc.Base64 = {
stringify: function(d) {
var l = d.words,
p = d.sigBytes,
t = this._map;
d.clamp();
d = [];
for(var r = 0; r < p; r += 3)
for(var w = (l[r >>> 2] >>> 24 - 8 * (r % 4) & 255) << 16 | (l[r + 1 >>> 2] >>> 24 - 8 * ((r + 1) % 4) & 255) << 8 | l[r + 2 >>> 2] >>> 24 - 8 * ((r + 2) % 4) & 255, v = 0; 4 > v && r + 0.75 * v < p; v++) d.push(t.charAt(w >>> 6 * (3 - v) & 63));
if(l = t.charAt(64))
for(; d.length % 4;) d.push(l);
return d.join("")
},
parse: function(d) {
var l = d.length,
s = this._map,
t = s.charAt(64);
t && (t = d.indexOf(t), -1 != t && (l = t));
for(var t = [], r = 0, w = 0; w <
l; w++)
if(w % 4) {
var v = s.indexOf(d.charAt(w - 1)) << 2 * (w % 4),
b = s.indexOf(d.charAt(w)) >>> 6 - 2 * (w % 4);
t[r >>> 2] |= (v | b) << 24 - 8 * (r % 4);
r++
}
return p.create(t, r)
},
_map: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
}
})();
(function(u) {
function p(b, n, a, c, e, j, k) {
b = b + (n & a | ~n & c) + e + k;
return(b << j | b >>> 32 - j) + n
}
function d(b, n, a, c, e, j, k) {
b = b + (n & c | a & ~c) + e + k;
return(b << j | b >>> 32 - j) + n
}
function l(b, n, a, c, e, j, k) {
b = b + (n ^ a ^ c) + e + k;
return(b << j | b >>> 32 - j) + n
}
function s(b, n, a, c, e, j, k) {
b = b + (a ^ (n | ~c)) + e + k;
return(b << j | b >>> 32 - j) + n
}
for(var t = CryptoJS, r = t.lib, w = r.WordArray, v = r.Hasher, r = t.algo, b = [], x = 0; 64 > x; x++) b[x] = 4294967296 * u.abs(u.sin(x + 1)) | 0;
r = r.MD5 = v.extend({
_doReset: function() {
this._hash = new w.init([1732584193, 4023233417, 2562383102, 271733878])
},
_doProcessBlock: function(q, n) {
for(var a = 0; 16 > a; a++) {
var c = n + a,
e = q[c];
q[c] = (e << 8 | e >>> 24) & 16711935 | (e << 24 | e >>> 8) & 4278255360
}
var a = this._hash.words,
c = q[n + 0],
e = q[n + 1],
j = q[n + 2],
k = q[n + 3],
z = q[n + 4],
r = q[n + 5],
t = q[n + 6],
w = q[n + 7],
v = q[n + 8],
A = q[n + 9],
B = q[n + 10],
C = q[n + 11],
u = q[n + 12],
D = q[n + 13],
E = q[n + 14],
x = q[n + 15],
f = a[0],
m = a[1],
g = a[2],
h = a[3],
f = p(f, m, g, h, c, 7, b[0]),
h = p(h, f, m, g, e, 12, b[1]),
g = p(g, h, f, m, j, 17, b[2]),
m = p(m, g, h, f, k, 22, b[3]),
f = p(f, m, g, h, z, 7, b[4]),
h = p(h, f, m, g, r, 12, b[5]),
g = p(g, h, f, m, t, 17, b[6]),
m = p(m, g, h, f, w, 22, b[7]),
f = p(f, m, g, h, v, 7, b[8]),
h = p(h, f, m, g, A, 12, b[9]),
g = p(g, h, f, m, B, 17, b[10]),
m = p(m, g, h, f, C, 22, b[11]),
f = p(f, m, g, h, u, 7, b[12]),
h = p(h, f, m, g, D, 12, b[13]),
g = p(g, h, f, m, E, 17, b[14]),
m = p(m, g, h, f, x, 22, b[15]),
f = d(f, m, g, h, e, 5, b[16]),
h = d(h, f, m, g, t, 9, b[17]),
g = d(g, h, f, m, C, 14, b[18]),
m = d(m, g, h, f, c, 20, b[19]),
f = d(f, m, g, h, r, 5, b[20]),
h = d(h, f, m, g, B, 9, b[21]),
g = d(g, h, f, m, x, 14, b[22]),
m = d(m, g, h, f, z, 20, b[23]),
f = d(f, m, g, h, A, 5, b[24]),
h = d(h, f, m, g, E, 9, b[25]),
g = d(g, h, f, m, k, 14, b[26]),
m = d(m, g, h, f, v, 20, b[27]),
f = d(f, m, g, h, D, 5, b[28]),
h = d(h, f,
m, g, j, 9, b[29]),
g = d(g, h, f, m, w, 14, b[30]),
m = d(m, g, h, f, u, 20, b[31]),
f = l(f, m, g, h, r, 4, b[32]),
h = l(h, f, m, g, v, 11, b[33]),
g = l(g, h, f, m, C, 16, b[34]),
m = l(m, g, h, f, E, 23, b[35]),
f = l(f, m, g, h, e, 4, b[36]),
h = l(h, f, m, g, z, 11, b[37]),
g = l(g, h, f, m, w, 16, b[38]),
m = l(m, g, h, f, B, 23, b[39]),
f = l(f, m, g, h, D, 4, b[40]),
h = l(h, f, m, g, c, 11, b[41]),
g = l(g, h, f, m, k, 16, b[42]),
m = l(m, g, h, f, t, 23, b[43]),
f = l(f, m, g, h, A, 4, b[44]),
h = l(h, f, m, g, u, 11, b[45]),
g = l(g, h, f, m, x, 16, b[46]),
m = l(m, g, h, f, j, 23, b[47]),
f = s(f, m, g, h, c, 6, b[48]),
h = s(h, f, m, g, w, 10, b[49]),
g = s(g, h, f, m,
E, 15, b[50]),
m = s(m, g, h, f, r, 21, b[51]),
f = s(f, m, g, h, u, 6, b[52]),
h = s(h, f, m, g, k, 10, b[53]),
g = s(g, h, f, m, B, 15, b[54]),
m = s(m, g, h, f, e, 21, b[55]),
f = s(f, m, g, h, v, 6, b[56]),
h = s(h, f, m, g, x, 10, b[57]),
g = s(g, h, f, m, t, 15, b[58]),
m = s(m, g, h, f, D, 21, b[59]),
f = s(f, m, g, h, z, 6, b[60]),
h = s(h, f, m, g, C, 10, b[61]),
g = s(g, h, f, m, j, 15, b[62]),
m = s(m, g, h, f, A, 21, b[63]);
a[0] = a[0] + f | 0;
a[1] = a[1] + m | 0;
a[2] = a[2] + g | 0;
a[3] = a[3] + h | 0
},
_doFinalize: function() {
var b = this._data,
n = b.words,
a = 8 * this._nDataBytes,
c = 8 * b.sigBytes;
n[c >>> 5] |= 128 << 24 - c % 32;
var e = u.floor(a /
4294967296);
n[(c + 64 >>> 9 << 4) + 15] = (e << 8 | e >>> 24) & 16711935 | (e << 24 | e >>> 8) & 4278255360;
n[(c + 64 >>> 9 << 4) + 14] = (a << 8 | a >>> 24) & 16711935 | (a << 24 | a >>> 8) & 4278255360;
b.sigBytes = 4 * (n.length + 1);
this._process();
b = this._hash;
n = b.words;
for(a = 0; 4 > a; a++) c = n[a], n[a] = (c << 8 | c >>> 24) & 16711935 | (c << 24 | c >>> 8) & 4278255360;
return b
},
clone: function() {
var b = v.clone.call(this);
b._hash = this._hash.clone();
return b
}
});
t.MD5 = v._createHelper(r);
t.HmacMD5 = v._createHmacHelper(r)
})(Math);
(function() {
var u = CryptoJS,
p = u.lib,
d = p.Base,
l = p.WordArray,
p = u.algo,
s = p.EvpKDF = d.extend({
cfg: d.extend({
keySize: 4,
hasher: p.MD5,
iterations: 1
}),
init: function(d) {
this.cfg = this.cfg.extend(d)
},
compute: function(d, r) {
for(var p = this.cfg, s = p.hasher.create(), b = l.create(), u = b.words, q = p.keySize, p = p.iterations; u.length < q;) {
n && s.update(n);
var n = s.update(d).finalize(r);
s.reset();
for(var a = 1; a < p; a++) n = s.finalize(n), s.reset();
b.concat(n)
}
b.sigBytes = 4 * q;
return b
}
});
u.EvpKDF = function(d, l, p) {
return s.create(p).compute(d,
l)
}
})();
CryptoJS.lib.Cipher || function(u) {
var p = CryptoJS,
d = p.lib,
l = d.Base,
s = d.WordArray,
t = d.BufferedBlockAlgorithm,
r = p.enc.Base64,
w = p.algo.EvpKDF,
v = d.Cipher = t.extend({
cfg: l.extend(),
createEncryptor: function(e, a) {
return this.create(this._ENC_XFORM_MODE, e, a)
},
createDecryptor: function(e, a) {
return this.create(this._DEC_XFORM_MODE, e, a)
},
init: function(e, a, b) {
this.cfg = this.cfg.extend(b);
this._xformMode = e;
this._key = a;
this.reset()
},
reset: function() {
t.reset.call(this);
this._doReset()
},
process: function(e) {
this._append(e);
return this._process()
},
finalize: function(e) {
e && this._append(e);
return this._doFinalize()
},
keySize: 4,
ivSize: 4,
_ENC_XFORM_MODE: 1,
_DEC_XFORM_MODE: 2,
_createHelper: function(e) {
return {
encrypt: function(b, k, d) {
return("string" == typeof k ? c : a).encrypt(e, b, k, d)
},
decrypt: function(b, k, d) {
return("string" == typeof k ? c : a).decrypt(e, b, k, d)
}
}
}
});
d.StreamCipher = v.extend({
_doFinalize: function() {
return this._process(!0)
},
blockSize: 1
});
var b = p.mode = {},
x = function(e, a, b) {
var c = this._iv;
c ? this._iv = u : c = this._prevBlock;
for(var d = 0; d < b; d++) e[a + d] ^=
c[d]
},
q = (d.BlockCipherMode = l.extend({
createEncryptor: function(e, a) {
return this.Encryptor.create(e, a)
},
createDecryptor: function(e, a) {
return this.Decryptor.create(e, a)
},
init: function(e, a) {
this._cipher = e;
this._iv = a
}
})).extend();
q.Encryptor = q.extend({
processBlock: function(e, a) {
var b = this._cipher,
c = b.blockSize;
x.call(this, e, a, c);
b.encryptBlock(e, a);
this._prevBlock = e.slice(a, a + c)
}
});
q.Decryptor = q.extend({
processBlock: function(e, a) {
var b = this._cipher,
c = b.blockSize,
d = e.slice(a, a + c);
b.decryptBlock(e, a);
x.call(this,
e, a, c);
this._prevBlock = d
}
});
b = b.CBC = q;
q = (p.pad = {}).Pkcs7 = {
pad: function(a, b) {
for(var c = 4 * b, c = c - a.sigBytes % c, d = c << 24 | c << 16 | c << 8 | c, l = [], n = 0; n < c; n += 4) l.push(d);
c = s.create(l, c);
a.concat(c)
},
unpad: function(a) {
a.sigBytes -= a.words[a.sigBytes - 1 >>> 2] & 255
}
};
d.BlockCipher = v.extend({
cfg: v.cfg.extend({
mode: b,
padding: q
}),
reset: function() {
v.reset.call(this);
var a = this.cfg,
b = a.iv,
a = a.mode;
if(this._xformMode == this._ENC_XFORM_MODE) var c = a.createEncryptor;
else c = a.createDecryptor, this._minBufferSize = 1;
this._mode = c.call(a,
this, b && b.words)
},
_doProcessBlock: function(a, b) {
this._mode.processBlock(a, b)
},
_doFinalize: function() {
var a = this.cfg.padding;
if(this._xformMode == this._ENC_XFORM_MODE) {
a.pad(this._data, this.blockSize);
var b = this._process(!0)
} else b = this._process(!0), a.unpad(b);
return b
},
blockSize: 4
});
var n = d.CipherParams = l.extend({
init: function(a) {
this.mixIn(a)
},
toString: function(a) {
return(a || this.formatter).stringify(this)
}
}),
b = (p.format = {}).OpenSSL = {
stringify: function(a) {
var b = a.ciphertext;
a = a.salt;
return(a ? s.create([1398893684,
1701076831
]).concat(a).concat(b) : b).toString(r)
},
parse: function(a) {
a = r.parse(a);
var b = a.words;
if(1398893684 == b[0] && 1701076831 == b[1]) {
var c = s.create(b.slice(2, 4));
b.splice(0, 4);
a.sigBytes -= 16
}
return n.create({
ciphertext: a,
salt: c
})
}
},
a = d.SerializableCipher = l.extend({
cfg: l.extend({
format: b
}),
encrypt: function(a, b, c, d) {
d = this.cfg.extend(d);
var l = a.createEncryptor(c, d);
b = l.finalize(b);
l = l.cfg;
return n.create({
ciphertext: b,
key: c,
iv: l.iv,
algorithm: a,
mode: l.mode,
padding: l.padding,
blockSize: a.blockSize,
formatter: d.format
})
},
decrypt: function(a, b, c, d) {
d = this.cfg.extend(d);
b = this._parse(b, d.format);
return a.createDecryptor(c, d).finalize(b.ciphertext)
},
_parse: function(a, b) {
return "string" == typeof a ? b.parse(a, this) : a
}
}),
p = (p.kdf = {}).OpenSSL = {
execute: function(a, b, c, d) {
d || (d = s.random(8));
a = w.create({
keySize: b + c
}).compute(a, d);
c = s.create(a.words.slice(b), 4 * c);
a.sigBytes = 4 * b;
return n.create({
key: a,
iv: c,
salt: d
})
}
},
c = d.PasswordBasedCipher = a.extend({
cfg: a.cfg.extend({
kdf: p
}),
encrypt: function(b, c, d, l) {
l = this.cfg.extend(l);
d = l.kdf.execute(d,
b.keySize, b.ivSize);
l.iv = d.iv;
b = a.encrypt.call(this, b, c, d.key, l);
b.mixIn(d);
return b
},
decrypt: function(b, c, d, l) {
l = this.cfg.extend(l);
c = this._parse(c, l.format);
d = l.kdf.execute(d, b.keySize, b.ivSize, c.salt);
l.iv = d.iv;
return a.decrypt.call(this, b, c, d.key, l)
}
})
}();
(function() {
for(var u = CryptoJS, p = u.lib.BlockCipher, d = u.algo, l = [], s = [], t = [], r = [], w = [], v = [], b = [], x = [], q = [], n = [], a = [], c = 0; 256 > c; c++) a[c] = 128 > c ? c << 1 : c << 1 ^ 283;
for(var e = 0, j = 0, c = 0; 256 > c; c++) {
var k = j ^ j << 1 ^ j << 2 ^ j << 3 ^ j << 4,
k = k >>> 8 ^ k & 255 ^ 99;
l[e] = k;
s[k] = e;
var z = a[e],
F = a[z],
G = a[F],
y = 257 * a[k] ^ 16843008 * k;
t[e] = y << 24 | y >>> 8;
r[e] = y << 16 | y >>> 16;
w[e] = y << 8 | y >>> 24;
v[e] = y;
y = 16843009 * G ^ 65537 * F ^ 257 * z ^ 16843008 * e;
b[k] = y << 24 | y >>> 8;
x[k] = y << 16 | y >>> 16;
q[k] = y << 8 | y >>> 24;
n[k] = y;
e ? (e = z ^ a[a[a[G ^ z]]], j ^= a[a[j]]) : e = j = 1
}
var H = [0, 1, 2, 4, 8,
16, 32, 64, 128, 27, 54
],
d = d.AES = p.extend({
_doReset: function() {
for(var a = this._key, c = a.words, d = a.sigBytes / 4, a = 4 * ((this._nRounds = d + 6) + 1), e = this._keySchedule = [], j = 0; j < a; j++)
if(j < d) e[j] = c[j];
else {
var k = e[j - 1];
j % d ? 6 < d && 4 == j % d && (k = l[k >>> 24] << 24 | l[k >>> 16 & 255] << 16 | l[k >>> 8 & 255] << 8 | l[k & 255]) : (k = k << 8 | k >>> 24, k = l[k >>> 24] << 24 | l[k >>> 16 & 255] << 16 | l[k >>> 8 & 255] << 8 | l[k & 255], k ^= H[j / d | 0] << 24);
e[j] = e[j - d] ^ k
}
c = this._invKeySchedule = [];
for(d = 0; d < a; d++) j = a - d, k = d % 4 ? e[j] : e[j - 4], c[d] = 4 > d || 4 >= j ? k : b[l[k >>> 24]] ^ x[l[k >>> 16 & 255]] ^ q[l[k >>>
8 & 255]] ^ n[l[k & 255]]
},
encryptBlock: function(a, b) {
this._doCryptBlock(a, b, this._keySchedule, t, r, w, v, l)
},
decryptBlock: function(a, c) {
var d = a[c + 1];
a[c + 1] = a[c + 3];
a[c + 3] = d;
this._doCryptBlock(a, c, this._invKeySchedule, b, x, q, n, s);
d = a[c + 1];
a[c + 1] = a[c + 3];
a[c + 3] = d
},
_doCryptBlock: function(a, b, c, d, e, j, l, f) {
for(var m = this._nRounds, g = a[b] ^ c[0], h = a[b + 1] ^ c[1], k = a[b + 2] ^ c[2], n = a[b + 3] ^ c[3], p = 4, r = 1; r < m; r++) var q = d[g >>> 24] ^ e[h >>> 16 & 255] ^ j[k >>> 8 & 255] ^ l[n & 255] ^ c[p++],
s = d[h >>> 24] ^ e[k >>> 16 & 255] ^ j[n >>> 8 & 255] ^ l[g & 255] ^ c[p++],
t =
d[k >>> 24] ^ e[n >>> 16 & 255] ^ j[g >>> 8 & 255] ^ l[h & 255] ^ c[p++],
n = d[n >>> 24] ^ e[g >>> 16 & 255] ^ j[h >>> 8 & 255] ^ l[k & 255] ^ c[p++],
g = q,
h = s,
k = t;
q = (f[g >>> 24] << 24 | f[h >>> 16 & 255] << 16 | f[k >>> 8 & 255] << 8 | f[n & 255]) ^ c[p++];
s = (f[h >>> 24] << 24 | f[k >>> 16 & 255] << 16 | f[n >>> 8 & 255] << 8 | f[g & 255]) ^ c[p++];
t = (f[k >>> 24] << 24 | f[n >>> 16 & 255] << 16 | f[g >>> 8 & 255] << 8 | f[h & 255]) ^ c[p++];
n = (f[n >>> 24] << 24 | f[g >>> 16 & 255] << 16 | f[h >>> 8 & 255] << 8 | f[k & 255]) ^ c[p++];
a[b] = q;
a[b + 1] = s;
a[b + 2] = t;
a[b + 3] = n
},
keySize: 8
});
u.AES = p._createHelper(d)
})();
! function(t, n) {
"object" == typeof exports ? module.exports = exports = n() : "function" == typeof define && define.amd ? define([], n) : t.CryptoJS = n()
}(this, function() {
var t = t || function(t, n) {
var i = Object.create || function() {
function t() {}
return function(n) {
var i;
return t.prototype = n, i = new t, t.prototype = null, i
}
}(),
e = {},
r = e.lib = {},
o = r.Base = function() {
return {
extend: function(t) {
var n = i(this);
return t && n.mixIn(t), n.hasOwnProperty("init") && this.init !== n.init || (n.init = function() {
n.$super.init.apply(this, arguments)
}), n.init.prototype = n, n.$super = this, n
},
create: function() {
var t = this.extend();
return t.init.apply(t, arguments), t
},
init: function() {},
mixIn: function(t) {
for(var n in t) t.hasOwnProperty(n) && (this[n] = t[n]);
t.hasOwnProperty("toString") && (this.toString = t.toString)
},
clone: function() {
return this.init.prototype.extend(this)
}
}
}(),
s = r.WordArray = o.extend({
init: function(t, i) {
t = this.words = t || [], i != n ? this.sigBytes = i : this.sigBytes = 4 * t.length
},
toString: function(t) {
return(t || c).stringify(this)
},
concat: function(t) {
var n = this.words,
i = t.words,
e = this.sigBytes,
r = t.sigBytes;
if(this.clamp(), e % 4)
for(var o = 0; o < r; o++) {
var s = i[o >>> 2] >>> 24 - o % 4 * 8 & 255;
n[e + o >>> 2] |= s << 24 - (e + o) % 4 * 8
} else
for(var o = 0; o < r; o += 4) n[e + o >>> 2] = i[o >>> 2];
return this.sigBytes += r, this
},
clamp: function() {
var n = this.words,
i = this.sigBytes;
n[i >>> 2] &= 4294967295 << 32 - i % 4 * 8, n.length = t.ceil(i / 4)
},
clone: function() {
var t = o.clone.call(this);
return t.words = this.words.slice(0), t
},
random: function(n) {
for(var i, e = [], r = function(n) {
var n = n,
i = 987654321,
e = 4294967295;
return function() {
i = 36969 * (65535 & i) + (i >> 16) & e, n = 18e3 * (65535 & n) + (n >> 16) & e;
var r = (i << 16) + n & e;
return r /= 4294967296, r += .5, r * (t.random() > .5 ? 1 : -1)
}
}, o = 0; o < n; o += 4) {
var a = r(4294967296 * (i || t.random()));
i = 987654071 * a(), e.push(4294967296 * a() | 0)
}
return new s.init(e, n)
}
}),
a = e.enc = {},
c = a.Hex = {
stringify: function(t) {
for(var n = t.words, i = t.sigBytes, e = [], r = 0; r < i; r++) {
var o = n[r >>> 2] >>> 24 - r % 4 * 8 & 255;
e.push((o >>> 4).toString(16)), e.push((15 & o).toString(16))
}
return e.join("")
},
parse: function(t) {
for(var n = t.length, i = [], e = 0; e < n; e += 2) i[e >>> 3] |= parseInt(t.substr(e, 2), 16) << 24 - e % 8 * 4;
return new s.init(i, n / 2)
}
},
u = a.Latin1 = {
stringify: function(t) {
for(var n = t.words, i = t.sigBytes, e = [], r = 0; r < i; r++) {
var o = n[r >>> 2] >>> 24 - r % 4 * 8 & 255;
e.push(String.fromCharCode(o))
}
return e.join("")
},
parse: function(t) {
for(var n = t.length, i = [], e = 0; e < n; e++) i[e >>> 2] |= (255 & t.charCodeAt(e)) << 24 - e % 4 * 8;
return new s.init(i, n)
}
},
f = a.Utf8 = {
stringify: function(t) {
try {
return decodeURIComponent(escape(u.stringify(t)))
} catch(t) {
throw new Error("Malformed UTF-8 data")
}
},
parse: function(t) {
return u.parse(unescape(encodeURIComponent(t)))
}
},
h = r.BufferedBlockAlgorithm = o.extend({
reset: function() {
this._data = new s.init, this._nDataBytes = 0
},
_append: function(t) {
"string" == typeof t && (t = f.parse(t)), this._data.concat(t), this._nDataBytes += t.sigBytes
},
_process: function(n) {
var i = this._data,
e = i.words,
r = i.sigBytes,
o = this.blockSize,
a = 4 * o,
c = r / a;
c = n ? t.ceil(c) : t.max((0 | c) - this._minBufferSize, 0);
var u = c * o,
f = t.min(4 * u, r);
if(u) {
for(var h = 0; h < u; h += o) this._doProcessBlock(e, h);
var p = e.splice(0, u);
i.sigBytes -= f
}
return new s.init(p, f)
},
clone: function() {
var t = o.clone.call(this);
return t._data = this._data.clone(), t
},
_minBufferSize: 0
}),
p = (r.Hasher = h.extend({
cfg: o.extend(),
init: function(t) {
this.cfg = this.cfg.extend(t), this.reset()
},
reset: function() {
h.reset.call(this), this._doReset()
},
update: function(t) {
return this._append(t), this._process(), this
},
finalize: function(t) {
t && this._append(t);
var n = this._doFinalize();
return n
},
blockSize: 16,
_createHelper: function(t) {
return function(n, i) {
return new t.init(i).finalize(n)
}
},
_createHmacHelper: function(t) {
return function(n, i) {
return new p.HMAC.init(t, i).finalize(n)
}
}
}), e.algo = {});
return e
}(Math);
return t
});
//# sourceMappingURL=core.min.js.map
! function(e, t, i) {
"object" == typeof exports ? module.exports = exports = t(require("./core.min"), require("./sha1.min"), require("./hmac.min")) : "function" == typeof define && define.amd ? define(["./core.min", "./sha1.min", "./hmac.min"], t) : t(e.CryptoJS)
}(this, function(e) {
return function() {
var t = e,
i = t.lib,
r = i.Base,
n = i.WordArray,
o = t.algo,
a = o.MD5,
c = o.EvpKDF = r.extend({
cfg: r.extend({
keySize: 4,
hasher: a,
iterations: 1
}),
init: function(e) {
this.cfg = this.cfg.extend(e)
},
compute: function(e, t) {
for(var i = this.cfg, r = i.hasher.create(), o = n.create(), a = o.words, c = i.keySize, f = i.iterations; a.length < c;) {
s && r.update(s);
var s = r.update(e).finalize(t);
r.reset();
for(var u = 1; u < f; u++) s = r.finalize(s), r.reset();
o.concat(s)
}
return o.sigBytes = 4 * c, o
}
});
t.EvpKDF = function(e, t, i) {
return c.create(i).compute(e, t)
}
}(), e.EvpKDF
});
//# sourceMappingURL=evpkdf.min.js.map
! function(r, e) {
"object" == typeof exports ? module.exports = exports = e(require("./core.min")) : "function" == typeof define && define.amd ? define(["./core.min"], e) : e(r.CryptoJS)
}(this, function(r) {
return function() {
function e(r, e, t) {
for(var n = [], i = 0, o = 0; o < e; o++)
if(o % 4) {
var f = t[r.charCodeAt(o - 1)] << o % 4 * 2,
c = t[r.charCodeAt(o)] >>> 6 - o % 4 * 2;
n[i >>> 2] |= (f | c) << 24 - i % 4 * 8, i++
}
return a.create(n, i)
}
var t = r,
n = t.lib,
a = n.WordArray,
i = t.enc;
i.Base64 = {
stringify: function(r) {
var e = r.words,
t = r.sigBytes,
n = this._map;
r.clamp();
for(var a = [], i = 0; i < t; i += 3)
for(var o = e[i >>> 2] >>> 24 - i % 4 * 8 & 255, f = e[i + 1 >>> 2] >>> 24 - (i + 1) % 4 * 8 & 255, c = e[i + 2 >>> 2] >>> 24 - (i + 2) % 4 * 8 & 255, s = o << 16 | f << 8 | c, h = 0; h < 4 && i + .75 * h < t; h++) a.push(n.charAt(s >>> 6 * (3 - h) & 63));
var p = n.charAt(64);
if(p)
for(; a.length % 4;) a.push(p);
return a.join("")
},
parse: function(r) {
var t = r.length,
n = this._map,
a = this._reverseMap;
if(!a) {
a = this._reverseMap = [];
for(var i = 0; i < n.length; i++) a[n.charCodeAt(i)] = i
}
var o = n.charAt(64);
if(o) {
var f = r.indexOf(o);
f !== -1 && (t = f)
}
return e(r, t, a)
},
_map: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
}
}(), r.enc.Base64
});
//# sourceMappingURL=enc-base64.min.js.map
! function(e, t, r) {
"object" == typeof exports ? module.exports = exports = t(require("./core.min"), require("./evpkdf.min")) : "function" == typeof define && define.amd ? define(["./core.min", "./evpkdf.min"], t) : t(e.CryptoJS)
}(this, function(e) {
e.lib.Cipher || function(t) {
var r = e,
i = r.lib,
n = i.Base,
c = i.WordArray,
o = i.BufferedBlockAlgorithm,
s = r.enc,
a = (s.Utf8, s.Base64),
f = r.algo,
p = f.EvpKDF,
d = i.Cipher = o.extend({
cfg: n.extend(),
createEncryptor: function(e, t) {
return this.create(this._ENC_XFORM_MODE, e, t)
},
createDecryptor: function(e, t) {
return this.create(this._DEC_XFORM_MODE, e, t)
},
init: function(e, t, r) {
this.cfg = this.cfg.extend(r), this._xformMode = e, this._key = t, this.reset()
},
reset: function() {
o.reset.call(this), this._doReset()
},
process: function(e) {
return this._append(e), this._process()
},
finalize: function(e) {
e && this._append(e);
var t = this._doFinalize();
return t
},
keySize: 4,
ivSize: 4,
_ENC_XFORM_MODE: 1,
_DEC_XFORM_MODE: 2,
_createHelper: function() {
function e(e) {
return "string" == typeof e ? B : x
}
return function(t) {
return {
encrypt: function(r, i, n) {
return e(i).encrypt(t, r, i, n)
},
decrypt: function(r, i, n) {
return e(i).decrypt(t, r, i, n)
}
}
}
}()
}),
h = (i.StreamCipher = d.extend({
_doFinalize: function() {
var e = this._process(!0);
return e
},
blockSize: 1
}), r.mode = {}),
u = i.BlockCipherMode = n.extend({
createEncryptor: function(e, t) {
return this.Encryptor.create(e, t)
},
createDecryptor: function(e, t) {
return this.Decryptor.create(e, t)
},
init: function(e, t) {
this._cipher = e, this._iv = t
}
}),
l = h.CBC = function() {
function e(e, r, i) {
var n = this._iv;
if(n) {
var c = n;
this._iv = t
} else var c = this._prevBlock;
for(var o = 0; o < i; o++) e[r + o] ^= c[o]
}
var r = u.extend();
return r.Encryptor = r.extend({
processBlock: function(t, r) {
var i = this._cipher,
n = i.blockSize;
e.call(this, t, r, n), i.encryptBlock(t, r), this._prevBlock = t.slice(r, r + n)
}
}), r.Decryptor = r.extend({
processBlock: function(t, r) {
var i = this._cipher,
n = i.blockSize,
c = t.slice(r, r + n);
i.decryptBlock(t, r), e.call(this, t, r, n), this._prevBlock = c
}
}), r
}(),
_ = r.pad = {},
v = _.Pkcs7 = {
pad: function(e, t) {
for(var r = 4 * t, i = r - e.sigBytes % r, n = i << 24 | i << 16 | i << 8 | i, o = [], s = 0; s < i; s += 4) o.push(n);
var a = c.create(o, i);
e.concat(a)
},
unpad: function(e) {
var t = 255 & e.words[e.sigBytes - 1 >>> 2];
e.sigBytes -= t
}
},
y = (i.BlockCipher = d.extend({
cfg: d.cfg.extend({
mode: l,
padding: v
}),
reset: function() {
d.reset.call(this);
var e = this.cfg,
t = e.iv,
r = e.mode;
if(this._xformMode == this._ENC_XFORM_MODE) var i = r.createEncryptor;
else {
var i = r.createDecryptor;
this._minBufferSize = 1
}
this._mode && this._mode.__creator == i ? this._mode.init(this, t && t.words) : (this._mode = i.call(r, this, t && t.words), this._mode.__creator = i)
},
_doProcessBlock: function(e, t) {
this._mode.processBlock(e, t)
},
_doFinalize: function() {
var e = this.cfg.padding;
if(this._xformMode == this._ENC_XFORM_MODE) {
e.pad(this._data, this.blockSize);
var t = this._process(!0)
} else {
var t = this._process(!0);
e.unpad(t)
}
return t
},
blockSize: 4
}), i.CipherParams = n.extend({
init: function(e) {
this.mixIn(e)
},
toString: function(e) {
return(e || this.formatter).stringify(this)
}
})),
m = r.format = {},
k = m.OpenSSL = {
stringify: function(e) {
var t = e.ciphertext,
r = e.salt;
if(r) var i = c.create([1398893684, 1701076831]).concat(r).concat(t);
else var i = t;
return i.toString(a)
},
parse: function(e) {
var t = a.parse(e),
r = t.words;
if(1398893684 == r[0] && 1701076831 == r[1]) {
var i = c.create(r.slice(2, 4));
r.splice(0, 4), t.sigBytes -= 16
}
return y.create({
ciphertext: t,
salt: i
})
}
},
x = i.SerializableCipher = n.extend({
cfg: n.extend({
format: k
}),
encrypt: function(e, t, r, i) {
i = this.cfg.extend(i);
var n = e.createEncryptor(r, i),
c = n.finalize(t),
o = n.cfg;
return y.create({
ciphertext: c,
key: r,
iv: o.iv,
algorithm: e,
mode: o.mode,
padding: o.padding,
blockSize: e.blockSize,
formatter: i.format
})
},
decrypt: function(e, t, r, i) {
i = this.cfg.extend(i), t = this._parse(t, i.format);
var n = e.createDecryptor(r, i).finalize(t.ciphertext);
return n
},
_parse: function(e, t) {
return "string" == typeof e ? t.parse(e, this) : e
}
}),
g = r.kdf = {},
S = g.OpenSSL = {
execute: function(e, t, r, i) {
i || (i = c.random(8));
var n = p.create({
keySize: t + r
}).compute(e, i),
o = c.create(n.words.slice(t), 4 * r);
return n.sigBytes = 4 * t, y.create({
key: n,
iv: o,
salt: i
})
}
},
B = i.PasswordBasedCipher = x.extend({
cfg: x.cfg.extend({
kdf: S
}),
encrypt: function(e, t, r, i) {
i = this.cfg.extend(i);
var n = i.kdf.execute(r, e.keySize, e.ivSize);
i.iv = n.iv;
var c = x.encrypt.call(this, e, t, n.key, i);
return c.mixIn(n), c
},
decrypt: function(e, t, r, i) {
i = this.cfg.extend(i), t = this._parse(t, i.format);
var n = i.kdf.execute(r, e.keySize, e.ivSize, t.salt);
i.iv = n.iv;
var c = x.decrypt.call(this, e, t, n.key, i);
return c
}
})
}()
});
//# sourceMappingURL=cipher-core.min.js.map
! function(e, i) {
"object" == typeof exports ? module.exports = exports = i(require("./core.min")) : "function" == typeof define && define.amd ? define(["./core.min"], i) : i(e.CryptoJS)
}(this, function(e) {
! function() {
var i = e,
t = i.lib,
n = t.Base,
s = i.enc,
r = s.Utf8,
o = i.algo;
o.HMAC = n.extend({
init: function(e, i) {
e = this._hasher = new e.init, "string" == typeof i && (i = r.parse(i));
var t = e.blockSize,
n = 4 * t;
i.sigBytes > n && (i = e.finalize(i)), i.clamp();
for(var s = this._oKey = i.clone(), o = this._iKey = i.clone(), a = s.words, f = o.words, c = 0; c < t; c++) a[c] ^= 1549556828, f[c] ^= 909522486;
s.sigBytes = o.sigBytes = n, this.reset()
},
reset: function() {
var e = this._hasher;
e.reset(), e.update(this._iKey)
},
update: function(e) {
return this._hasher.update(e), this
},
finalize: function(e) {
var i = this._hasher,
t = i.finalize(e);
i.reset();
var n = i.finalize(this._oKey.clone().concat(t));
return n
}
})
}()
});
//# sourceMappingURL=hmac.min.js.map
! function(e, o, r) {
"object" == typeof exports ? module.exports = exports = o(require("./core.min"), require("./cipher-core.min")) : "function" == typeof define && define.amd ? define(["./core.min", "./cipher-core.min"], o) : o(e.CryptoJS)
}(this, function(e) {
return e.mode.ECB = function() {
var o = e.lib.BlockCipherMode.extend();
return o.Encryptor = o.extend({
processBlock: function(e, o) {
this._cipher.encryptBlock(e, o)
}
}), o.Decryptor = o.extend({
processBlock: function(e, o) {
this._cipher.decryptBlock(e, o)
}
}), o
}(), e.mode.ECB
});
//# sourceMappingURL=mode-ecb.min.js.map
! function(e, r, i) {
"object" == typeof exports ? module.exports = exports = r(require("./core.min"), require("./cipher-core.min")) : "function" == typeof define && define.amd ? define(["./core.min", "./cipher-core.min"], r) : r(e.CryptoJS)
}(this, function(e) {
return e.pad.Pkcs7
});
//# sourceMappingURL=pad-pkcs7.min.js.map
! function(e, r, i) {
"object" == typeof exports ? module.exports = exports = r(require("./core.min"), require("./enc-base64.min"), require("./md5.min"), require("./evpkdf.min"), require("./cipher-core.min")) : "function" == typeof define && define.amd ? define(["./core.min", "./enc-base64.min", "./md5.min", "./evpkdf.min", "./cipher-core.min"], r) : r(e.CryptoJS)
}(this, function(e) {
return function() {
var r = e,
i = r.lib,
n = i.BlockCipher,
o = r.algo,
t = [],
c = [],
s = [],
f = [],
a = [],
d = [],
u = [],
v = [],
h = [],
y = [];
! function() {
for(var e = [], r = 0; r < 256; r++) r < 128 ? e[r] = r << 1 : e[r] = r << 1 ^ 283;
for(var i = 0, n = 0, r = 0; r < 256; r++) {
var o = n ^ n << 1 ^ n << 2 ^ n << 3 ^ n << 4;
o = o >>> 8 ^ 255 & o ^ 99, t[i] = o, c[o] = i;
var p = e[i],
l = e[p],
_ = e[l],
k = 257 * e[o] ^ 16843008 * o;
s[i] = k << 24 | k >>> 8, f[i] = k << 16 | k >>> 16, a[i] = k << 8 | k >>> 24, d[i] = k;
var k = 16843009 * _ ^ 65537 * l ^ 257 * p ^ 16843008 * i;
u[o] = k << 24 | k >>> 8, v[o] = k << 16 | k >>> 16, h[o] = k << 8 | k >>> 24, y[o] = k, i ? (i = p ^ e[e[e[_ ^ p]]], n ^= e[e[n]]) : i = n = 1
}
}();
var p = [0, 1, 2, 4, 8, 16, 32, 64, 128, 27, 54],
l = o.AES = n.extend({
_doReset: function() {
if(!this._nRounds || this._keyPriorReset !== this._key) {
for(var e = this._keyPriorReset = this._key, r = e.words, i = e.sigBytes / 4, n = this._nRounds = i + 6, o = 4 * (n + 1), c = this._keySchedule = [], s = 0; s < o; s++)
if(s < i) c[s] = r[s];
else {
var f = c[s - 1];
s % i ? i > 6 && s % i == 4 && (f = t[f >>> 24] << 24 | t[f >>> 16 & 255] << 16 | t[f >>> 8 & 255] << 8 | t[255 & f]) : (f = f << 8 | f >>> 24, f = t[f >>> 24] << 24 | t[f >>> 16 & 255] << 16 | t[f >>> 8 & 255] << 8 | t[255 & f], f ^= p[s / i | 0] << 24), c[s] = c[s - i] ^ f
}
for(var a = this._invKeySchedule = [], d = 0; d < o; d++) {
var s = o - d;
if(d % 4) var f = c[s];
else var f = c[s - 4];
d < 4 || s <= 4 ? a[d] = f : a[d] = u[t[f >>> 24]] ^ v[t[f >>> 16 & 255]] ^ h[t[f >>> 8 & 255]] ^ y[t[255 & f]]
}
}
},
encryptBlock: function(e, r) {
this._doCryptBlock(e, r, this._keySchedule, s, f, a, d, t)
},
decryptBlock: function(e, r) {
var i = e[r + 1];
e[r + 1] = e[r + 3], e[r + 3] = i, this._doCryptBlock(e, r, this._invKeySchedule, u, v, h, y, c);
var i = e[r + 1];
e[r + 1] = e[r + 3], e[r + 3] = i
},
_doCryptBlock: function(e, r, i, n, o, t, c, s) {
for(var f = this._nRounds, a = e[r] ^ i[0], d = e[r + 1] ^ i[1], u = e[r + 2] ^ i[2], v = e[r + 3] ^ i[3], h = 4, y = 1; y < f; y++) {
var p = n[a >>> 24] ^ o[d >>> 16 & 255] ^ t[u >>> 8 & 255] ^ c[255 & v] ^ i[h++],
l = n[d >>> 24] ^ o[u >>> 16 & 255] ^ t[v >>> 8 & 255] ^ c[255 & a] ^ i[h++],
_ = n[u >>> 24] ^ o[v >>> 16 & 255] ^ t[a >>> 8 & 255] ^ c[255 & d] ^ i[h++],
k = n[v >>> 24] ^ o[a >>> 16 & 255] ^ t[d >>> 8 & 255] ^ c[255 & u] ^ i[h++];
a = p, d = l, u = _, v = k
}
var p = (s[a >>> 24] << 24 | s[d >>> 16 & 255] << 16 | s[u >>> 8 & 255] << 8 | s[255 & v]) ^ i[h++],
l = (s[d >>> 24] << 24 | s[u >>> 16 & 255] << 16 | s[v >>> 8 & 255] << 8 | s[255 & a]) ^ i[h++],
_ = (s[u >>> 24] << 24 | s[v >>> 16 & 255] << 16 | s[a >>> 8 & 255] << 8 | s[255 & d]) ^ i[h++],
k = (s[v >>> 24] << 24 | s[a >>> 16 & 255] << 16 | s[d >>> 8 & 255] << 8 | s[255 & u]) ^ i[h++];
e[r] = p, e[r + 1] = l, e[r + 2] = _, e[r + 3] = k
},
keySize: 8
});
r.AES = n._createHelper(l)
}(), e.AES
});
//# sourceMappingURL=aes.min.js.map
! function(e, n) {
"object" == typeof exports ? module.exports = exports = n(require("./core.min")) : "function" == typeof define && define.amd ? define(["./core.min"], n) : n(e.CryptoJS)
}(this, function(e) {
return e.enc.Utf8
});
//# sourceMappingURL=enc-utf8.min.js.map
\ No newline at end of file
let urlCreatesign = urldomaincreatesign
let urlGateway = urldomaingateway
const appmark = "sdzwapp"
const appword = "aKd20dbGdFvmuwrt"
let userType = "1" //用户类型 1个人 2法人
window.onload = function () {
getUserInfo()
}
/**
* 通过jssdk方法获取APP本地用户票据
*/
function getUserInfo() {
lightAppJssdk.user.getTicket({
success: function (data) {
//成功回调
console.log(JSON.stringify(data))
if (data == "未登录") {
onLoginApp() //APP用户未登录,调用登录页面
} else {
var jsonData = JSON.parse(data)
if (jsonData.retcode == "000000") {
var dataValueObj = JSON.parse(jsonData.data)
var ticket = dataValueObj.ticket //解析出用户票据信息
userType = dataValueObj.usertype //解析保存用户类型(个人法人)
getUserToken(ticket)
}
}
},
fail: function (data) {
//错误返回
console.log(JSON.stringify(data))
}
})
}
/**
* 使用jssdk调用登录页面
*/
function onLoginApp() {
lightAppJssdk.user.loginapp({
success: function (data) {
if (data == "未登录") {
//取消登录或登录失败,关闭页面
oncloseWindow()
} else {
var dataObj = JSON.parse(data)
if (dataObj.retcode == "000000") {
//登录成功,返回用户的票据和用户类型
var dataValueObj = JSON.parse(dataObj.data)
getUserToken(dataValueObj.ticket) //解析出用户票据信息
userType = jsonData.usertype //解析保存用户类型(个人法人)
} else {
//关闭页面
oncloseWindow()
}
}
},
fail: function (data) {
//关闭页面
oncloseWindow()
}
})
}
/**
* 通过用户票据获取用户的令牌数据,票据使用一次后失效,token时效性较长
*/
function getUserToken(ticket) {
var params = '{"ticket":"' + ticket + '"}'
const interfaceContent = {
app_id: appmark,
servicename: "ticketValidate",
params: params
}
vaildInterfacefn("jisnzjk", "ticketvalidate", JSON.stringify(interfaceContent), "1", "https://" + urlCreatesign, "https://" + urlGateway).then((value) => {
const data = JSON.parse(value)
if (data.retcode == "000000") {
const userToken = JSON.parse(data.data).token
if (userType == "1") {
//个人类型获取用户信息
getUserInfoByToken(userToken)
} else {
//法人类型获取用户信息
findCorUserByToken(userToken)
}
} else {
lightAppJssdk.notification.alert({
title: "提示", //可传空
message: data.msg,
buttonName: "确认",
success: function (data) {
oncloseWindow()
}
})
}
})
}
/**
* 根据令牌获取个人完整信息
*/
function getUserInfoByToken(userToken) {
const params = '{"token":"' + userToken + '"}'
const interfaceContent = {
app_id: appmark,
servicename: "findOutsideUserByToken",
params: params
}
try {
vaildInterfacefn("jisnzjk", "findoutsideuserbytoken", JSON.stringify(interfaceContent), "2", "https://" + urlCreatesign, "https://" + urlGateway).then((value) => {
const data = JSON.parse(value)
if (data.retcode == "000000") {
const userInfo = data.data
const userObj = JSON.parse(userInfo)
document.getElementById("name").innerText = userObj.name
document.getElementById("cardid").innerText = userObj.papersnumber
document.getElementById("mobile").innerText = userObj.mobile
} else {
}
})
} catch (error) {}
}
/**
* 根据令牌获取完整法人信息
*/
function findCorUserByToken(userToken) {
try {
const params = '{"token":"' + userToken + '"}'
const interfaceContent = {
app_id: appmark,
servicename: "findCorUserByToken",
params: params
}
vaildInterfacefn("jisnzjk", "findcoruserytoken", JSON.stringify(interfaceContent), "2", "https://" + urlCreatesign, "https://" + urlGateway).then((value) => {
const data = JSON.parse(value)
if (data.retcode == "000000") {
const userInfo = JSON.stringify(data.data)
document.getElementById("userinfo").innerText = userInfo
} else {
}
})
} catch (err) {}
}
/**
* 关闭容器
*/
function oncloseWindow() {
lightAppJssdk.navigation.close({
success: function (data) {},
fail: function (data) {}
})
}
/**
* AES解密
*/
function Decrypt(word, key) {
var key = CryptoJS.enc.Utf8.parse(key) //转为128bit
var srcs = CryptoJS.enc.Hex.parse(word) //转为16进制
var str = CryptoJS.enc.Base64.stringify(srcs) //变为Base64编码的字符串
var decrypt = CryptoJS.AES.decrypt(str, key, {
mode: CryptoJS.mode.ECB,
spadding: CryptoJS.pad.Pkcs7
})
return decrypt.toString(CryptoJS.enc.Utf8)
}
/*
*jssdk jsapi所在服务器域名,无需追加'http://'或'https://'
*/
let jssdkconfigUrl = 'isdapp.shandong.gov.cn' // 爱山东测试环境
let jssdkbaseUrl = jssdkconfigUrl + '/jpaas-jags-server/interface/'
var jssdkconfig = {
urlConfig: {
/*
* 服务配置项
*/
urldomain: jssdkconfigUrl + '/jmopenpub/jmopen_files/js',
baseUrl: jssdkbaseUrl,
urldomaincreatesign: jssdkbaseUrl + 'createsign',
urldomaingateway: jssdkbaseUrl + 'gateway',
/*
* 埋点配置项
*/
app_id: 'jmopennzjk', //appid参数
interface_id: 'getAppStatisticsSecret', // 上报统计数据参数
interface_id_ua: 'checkUaAvailability' // ua判断参数
}
}
var urldomain = jssdkconfig.urlConfig.urldomain
var urldomaincreatesign = jssdkconfig.urlConfig.urldomaincreatesign
var urldomaingateway = jssdkconfig.urlConfig.urldomaingateway
var flySrc = urldomain + '/jssdk/fly.js'
var sUserAgent = navigator.userAgent.toLowerCase()
var bIsGftApp = sUserAgent.indexOf('hanweb_gft') > -1 || sUserAgent.indexOf('ganfutong_ios') > -1
function containerType() {
var bIsIpad = sUserAgent.match(/ipad/i) == "ipad"
var bIsApp = sUserAgent.indexOf('hanweb') > -1
var bIsdingding = sUserAgent.indexOf('dingtalk') > -1
var bIsWechat = sUserAgent.indexOf('micromessenger') > -1
var bIsWechatMini = sUserAgent.indexOf('miniprogram') > -1
var bIsAlipay = sUserAgent.indexOf('alipayclient') > -1
if (bIsApp) {
return "hanweb"
} else if (bIsGftApp) {
return "hanweb"
} else if (bIsWechat) {
if (bIsWechatMini) {
return "wechatMini"
}
return "wechat"
} else if (bIsAlipay) {
return "Alipay"
} else if (bIsdingding) {
return "dingtalk"
} else {
return "web"
}
}
var container = containerType()
var tmpTag = 'https:' == document.location.protocol ? true : false
// var tmpTag = true
// 公用js文件写入
// ua判断 及 应用埋点 js写入
if (tmpTag) {
document.write('<script type="text/javascript" src="https://' + urldomain + '/jssdk/md5.js"></script>')
document.write('<script type="text/javascript" src="https://' + flySrc + '"></script>')
document.write('<script type="text/javascript" src="https://' + urldomain +
'/jssdk/AnalyticsJs/sendAnalytics.js"></script>')
} else {
document.write('<script type="text/javascript" src="http://' + urldomain + '/jssdk/md5.js"></script>')
document.write('<script type="text/javascript" src="http://' + flySrc + '"></script>')
document.write('<script type="text/javascript" src="http://' + urldomain +
'/jssdk/AnalyticsJs/sendAnalytics.js"></script>')
}
if (bIsGftApp) {
// localStorage.setItem("gft_user", "");
document.write(
'<script type="text/javascript" src="https://ganfutong.jiangxi.gov.cn/jmopen/webapp/html5/gftAPI/hanwebAPI-2.0.0.min.js"></script>'
)
} else {
if (tmpTag == true) {
document.write('<script type="text/javascript" src="https://' + urldomain + '/jssdk/aes.js"></script>')
} else {
document.write('<script type="text/javascript" src="http://' + urldomain + '/jssdk/aes.js"></script>')
}
}
if (container == 'hanweb') {
if (tmpTag == true) {
if (typeof $ == 'undefined') {
document.write('<script type="text/javascript" src="https://' + urldomain +
'/jssdk/jquery-1.8.3.min.js"></script>')
}
document.write('<script type="text/javascript" src="https://' + urldomain + '/jssdk/sha1.js"></script>')
document.write('<script type="text/javascript" src="https://' + urldomain + '/jssdk/js/indexnew.js"></script>')
document.write('<script type="text/javascript" src="https://' + urldomain +
'/jssdk/jmportal_SDK.js"></script>')
} else {
if (typeof $ == 'undefined') {
document.write('<script type="text/javascript" src="http://' + urldomain +
'/jssdk/jquery-1.8.3.min.js"></script>')
}
document.write('<script type="text/javascript" src="http://' + urldomain + '/jssdk/sha1.js"></script>')
document.write('<script type="text/javascript" src="http://' + urldomain + '/jssdk/js/indexnew.js"></script>')
document.write('<script type="text/javascript" src="http://' + urldomain + '/jssdk/jmportal_SDK.js"></script>')
}
} else if (container == 'wechatMini') {
if (tmpTag == true) {
if (typeof $ == 'undefined') {
document.write('<script type="text/javascript" src="https://' + urldomain +
'/jssdk/jquery-1.8.3.min.js"></script>')
}
document.write('<script src="https://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>')
// document.write('<script src="https://cdn.bootcss.com/qs/6.5.1/qs.min.js"></script>')
document.write('<script type="text/javascript" src="https://' + urldomain + '/jssdk/wechat_mini/qs.js"></script>')
document.write('<script type="text/javascript" src="https://' + urldomain + '/jssdk/sha1.js"></script>')
document.write('<script type="text/javascript" src="https://' + urldomain +
'/jssdk/wechat_mini/aes.js"></script>')
document.write('<script type="text/javascript" src="https://' + urldomain +
'/jssdk/wechat_mini/newsm2.js"></script>')
document.write('<script type="text/javascript" src="https://' + urldomain +
'/jssdk/wechat_mini/indexnew.js"></script>')
} else {
if (typeof $ == 'undefined') {
document.write('<script type="text/javascript" src="http://' + urldomain +
'/jssdk/jquery-1.8.3.min.js"></script>')
}
document.write('<script src="http://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>')
// document.write('<script src="https://cdn.bootcss.com/qs/6.5.1/qs.min.js"></script>')
document.write('<script type="text/javascript" src="https://' + urldomain + '/jssdk/wechat_mini/qs.js"></script>')
document.write('<script type="text/javascript" src="http://' + urldomain + '/jssdk/sha1.js"></script>')
document.write('<script type="text/javascript" src="http://' + urldomain +
'/jssdk/wechat_mini/aes.js"></script>')
document.write('<script type="text/javascript" src="http://' + urldomain +
'/jssdk/wechat_mini/newsm2.js"></script>')
document.write('<script type="text/javascript" src="http://' + urldomain +
'/jssdk/wechat_mini/indexnew.js"></script>')
}
} else if (container == 'wechat') {
if (tmpTag == true) {
if (typeof $ == 'undefined') {
document.write('<script type="text/javascript" src="https://' + urldomain +
'/jssdk/jquery-1.8.3.min.js"></script>')
}
document.write('<script src="https://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>')
// document.write(
// '<script type="text/javascript" src="https://api.map.baidu.com/api?v=2.0&ak=cL8AUF5vdmRtXC1cjgq2XjjS"></script>'
// )
document.write('<script type="text/javascript" src="https://' + urldomain + '/jssdk/sha1.js"></script>')
document.write('<script type="text/javascript" src="https://' + urldomain +
'/jssdk/alipayjs/aes.js"></script>')
document.write('<script type="text/javascript" src="https://' + urldomain +
'/jssdk/alipayjs/pad-nopadding.js"></script>')
document.write('<script type="text/javascript" src="https://' + urldomain +
'/jssdk/wechatjs/indexnew.js"></script>')
} else {
if (typeof $ == 'undefined') {
document.write('<script type="text/javascript" src="http://' + urldomain +
'/jssdk/jquery-1.8.3.min.js"></script>')
}
// document.write(
// '<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=cL8AUF5vdmRtXC1cjgq2XjjS"></script>'
// )
document.write('<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>')
document.write('<script type="text/javascript" src="http://' + urldomain + '/jssdk/sha1.js"></script>')
document.write('<script type="text/javascript" src="http://' + urldomain + '/jssdk/alipayjs/aes.js"></script>')
document.write('<script type="text/javascript" src="http://' + urldomain +
'/jssdk/alipayjs/pad-nopadding.js"></script>')
document.write('<script type="text/javascript" src="http://' + urldomain +
'/jssdk/wechatjs/indexnew.js"></script>')
document.write('<script type="text/javascript" src="http://' + urldomain + '/jssdk/alipayjs/md5.js"></script>')
}
} else if (container == 'dingtalk') {
if (tmpTag == true) {
if (typeof $ == 'undefined') {
document.write('<script type="text/javascript" src="https://' + urldomain +
'/jssdk/jquery-1.8.3.min.js"></script>')
}
document.write('<script type="text/javascript" src="https://' + urldomain + '/jssdk/sha1.js"></script>')
// document.write(
// '<script type="text/javascript" src="https://api.map.baidu.com/api?v=2.0&ak=xOWZlWcTZPK84VcK3Ixzqq9wQ6arTUry"></script>'
// )
} else {
if (typeof $ == 'undefined') {
document.write('<script type="text/javascript" src="http://' + urldomain +
'/jssdk/jquery-1.8.3.min.js"></script>')
}
document.write('<script type="text/javascript" src="http://' + urldomain + '/jssdk/sha1.js"></script>')
// document.write(
// '<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=xOWZlWcTZPK84VcK3Ixzqq9wQ6arTUry"></script>'
// )
}
} else if (container == 'Alipay') {
document.write('<script type="text/javascript" src="https://' + urldomain +
'/jssdk/jquery-1.8.3.min.js"></script>')
document.write(
'<script type="text/javascript" src="https://gw.alipayobjects.com/as/g/h5-lib/alipayjsapi/3.1.1/alipayjsapi.min.js"></script>'
)
document.writeln('<script src="https://appx/web-view.min.js"' + '>' + '<' + '/' + 'script>')
// document.write(
// '<script type="text/javascript" src="https://api.map.baidu.com/api?v=2.0&ak=xOWZlWcTZPK84VcK3Ixzqq9wQ6arTUry"></script>'
// )
document.write('<script type="text/javascript" src="https://' + urldomain + '/jssdk/alipayjs/aes.js"></script>')
document.write('<script type="text/javascript" src="https://' + urldomain + '/jssdk/sha1.js"></script>')
document.write('<script type="text/javascript" src="https://' + urldomain +
'/jssdk/alipayjs/pad-nopadding.js"></script>')
document.write('<script type="text/javascript" src="https://' + urldomain +
'/jssdk/alipayjs/indexnew.js"></script>')
} else {
if (tmpTag == true) {
if (typeof $ == 'undefined') {
document.write('<script type="text/javascript" src="https://' + urldomain +
'/jssdk/jquery-1.8.3.min.js"></script>')
}
document.write('<script type="text/javascript" src="https://' + urldomain + '/jssdk/sha1.js"></script>')
document.write('<script type="text/javascript" src="https://' + urldomain +
'/jssdk/wechatjs/brower.js"></script>')
} else {
if (typeof $ == 'undefined') {
document.write('<script type="text/javascript" src="http://' + urldomain +
'/jssdk/jquery-1.8.3.min.js"></script>')
}
document.write('<script type="text/javascript" src="http://' + urldomain + '/jssdk/sha1.js"></script>')
document.write('<script type="text/javascript" src="http://' + urldomain +
'/jssdk/wechatjs/brower.js"></script>')
}
}
/*
* 网关验签接口
* appid应用唯一标识
* interfaceid接口唯一标识
* interfacecontent接口参数,请使用json格式, 例如:{"siteid":"2","cateid":"1"}
* fromport端口来源"0":PC;"1":APP;"2":支付宝;"3":微信
* signurl签名接口地址
* gatewayurl网关接口地址
* extraData 额外参数,附件,请求头一类的参数
*/
function vaildInterface(appid, interfaceid, interfacecontent, fromport = '1', extraData = {}) {
return new Promise(async function (resolve, reject) {
'string' === typeof extraData && (extraData = {})
// 获取额外参数
let {
fileList,
header
} = extraData
//const defaultDomainUrl = 'https://web1.isdapp.shandong.gov.cn'
// 获取当前客户端版本
// let currentClientVersion = await new Promise((resolve) => {
// lightAppJssdk.device.version({
// version: '',
// success: function (data) {
// resolve(data)
// },
// fail: function (data) {
// resolve(data)
// }
// })
// })
// 获取分发的网关域名
// let domainUrl = await new Promise((resolve) => {
// if (lightAppJssdk
// && lightAppJssdk.device
// && lightAppJssdk.device.getCurrentDomainUrl
// && Number(currentClientVersion.replace(/\./g, '')) >= 500) {
// lightAppJssdk.device.getCurrentDomainUrl({
// success: function (data) {
// resolve(data + '/jpaas-jags-web-server/interface/gateway')
// },
// fail: function (data) {
// resolve(defaultDomainUrl + '/jpaas-jags-web-server/interface/gateway')
// }
// })
// } else {
// // 当前版本非30w平台客户端版本,依旧返回线上的爱山东网关地址
// resolve('https://isdapp.shandong.gov.cn/jpaas-jags-server/interface/gateway')
// }
// })
const datestr = (new Date()).valueOf()
let fdDqtq = new FormData()
fdDqtq.append('app_id', appid)
fdDqtq.append('interface_id', interfaceid)
fdDqtq.append('version', '1.0')
fdDqtq.append('biz_content', interfacecontent)
fdDqtq.append('charset', 'utf-8')
fdDqtq.append('timestamp', datestr)
fdDqtq.append('origin', fromport)
fdDqtq.append('sign', 'signResult')
// 附件
let fileListType = ''
if (typeof Array.isArray === 'function') {
fileListType = Array.isArray(fileList)
} else {
fileListType = Object.prototype.toString.call(fileList) === "[object Array]"
}
if (fileListType) {
fileList.forEach(ele => {
let {
fileName,
file
} = ele
if (fileName && file) {
fdDqtq.append(fileName, file)
}
})
}
// 请求头
if (header) {
if (typeof header !== 'string') {
try {
header = JSON.stringify(header)
} catch (error) {
} finally {
fdDqtq.append('header', header)
}
} else {
fdDqtq.append('header', header)
}
}
$.ajax({
url: 'https://isdapp.shandong.gov.cn/jpaas-jags-server/interface/gateway.do',
type: 'post',
dataType: 'json',
data: fdDqtq,
contentType: false, // 注意这里应设为false
processData: false,
cache: false,
success: function (data) {
if (data == null || data == undefined || data == '') {
reject(false)
} else {
var gateWayResult = data.data
resolve(gateWayResult)
}
},
error: function (data) {
reject(false)
}
})
})
}
//扩展带请求头方法,headers必填参数
function vaildInterfaceWithHeaders(appid, interfaceid, interfacecontent, fromport, headers, signurl, gatewayurl) {
return new Promise(function (resolve, reject) {
var datestr = (new Date()).valueOf()
var param = {
"app_id": appid,
"interface_id": interfaceid,
"version": "1.0",
"biz_content": interfacecontent,
"charset": "utf-8",
"timestamp": datestr,
"origin": fromport,
"sign": 'signResult',
"header": headers
}
$.ajax({
url: "https://" + urldomaingateway,
type: 'post',
dataType: 'json',
data: param,
success: function (data) {
if (data == null || data == undefined || data == '') {
reject(false)
} else {
var gateWayResult = data.data
resolve(gateWayResult)
}
},
error: function (data) {
reject(false)
}
})
})
}
async function vaildInterfacefn(appid, interfaceid, interfacecontent, fromport, extraData = {}) {
var returnData = await vaildInterface(appid, interfaceid, interfacecontent, fromport, extraData)
return returnData
}
async function vaildInterfaceWithHeadersfn(appid, interfaceid, interfacecontent, fromport, headers, signurl, gatewayurl) {
var returnData = await vaildInterfaceWithHeaders(appid, interfaceid, interfacecontent, fromport, headers,
signurl, gatewayurl)
return returnData
}
//调用方式验证网关接口
//vaildInterfacefn().then(value => {
// var data = value
//})
// vaildInterfaceWithHeadersfn().then(value => {
// var data = value
// })
\ No newline at end of file
/*
CryptoJS v3.1.2
code.google.com/p/crypto-js
(c) 2009-2013 by Jeff Mott. All rights reserved.
code.google.com/p/crypto-js/wiki/License
*/
var CryptoJS = CryptoJS || function(u, p) {
var d = {},
l = d.lib = {},
s = function() {},
t = l.Base = {
extend: function(a) {
s.prototype = this;
var c = new s;
a && c.mixIn(a);
c.hasOwnProperty("init") || (c.init = function() {
c.$super.init.apply(this, arguments)
});
c.init.prototype = c;
c.$super = this;
return c
},
create: function() {
var a = this.extend();
a.init.apply(a, arguments);
return a
},
init: function() {},
mixIn: function(a) {
for(var c in a) a.hasOwnProperty(c) && (this[c] = a[c]);
a.hasOwnProperty("toString") && (this.toString = a.toString)
},
clone: function() {
return this.init.prototype.extend(this)
}
},
r = l.WordArray = t.extend({
init: function(a, c) {
a = this.words = a || [];
this.sigBytes = c != p ? c : 4 * a.length
},
toString: function(a) {
return(a || v).stringify(this)
},
concat: function(a) {
var c = this.words,
e = a.words,
j = this.sigBytes;
a = a.sigBytes;
this.clamp();
if(j % 4)
for(var k = 0; k < a; k++) c[j + k >>> 2] |= (e[k >>> 2] >>> 24 - 8 * (k % 4) & 255) << 24 - 8 * ((j + k) % 4);
else if(65535 < e.length)
for(k = 0; k < a; k += 4) c[j + k >>> 2] = e[k >>> 2];
else c.push.apply(c, e);
this.sigBytes += a;
return this
},
clamp: function() {
var a = this.words,
c = this.sigBytes;
a[c >>> 2] &= 4294967295 <<
32 - 8 * (c % 4);
a.length = u.ceil(c / 4)
},
clone: function() {
var a = t.clone.call(this);
a.words = this.words.slice(0);
return a
},
random: function(a) {
for(var c = [], e = 0; e < a; e += 4) c.push(4294967296 * u.random() | 0);
return new r.init(c, a)
}
}),
w = d.enc = {},
v = w.Hex = {
stringify: function(a) {
var c = a.words;
a = a.sigBytes;
for(var e = [], j = 0; j < a; j++) {
var k = c[j >>> 2] >>> 24 - 8 * (j % 4) & 255;
e.push((k >>> 4).toString(16));
e.push((k & 15).toString(16))
}
return e.join("")
},
parse: function(a) {
for(var c = a.length, e = [], j = 0; j < c; j += 2) e[j >>> 3] |= parseInt(a.substr(j,
2), 16) << 24 - 4 * (j % 8);
return new r.init(e, c / 2)
}
},
b = w.Latin1 = {
stringify: function(a) {
var c = a.words;
a = a.sigBytes;
for(var e = [], j = 0; j < a; j++) e.push(String.fromCharCode(c[j >>> 2] >>> 24 - 8 * (j % 4) & 255));
return e.join("")
},
parse: function(a) {
for(var c = a.length, e = [], j = 0; j < c; j++) e[j >>> 2] |= (a.charCodeAt(j) & 255) << 24 - 8 * (j % 4);
return new r.init(e, c)
}
},
x = w.Utf8 = {
stringify: function(a) {
try {
return decodeURIComponent(escape(b.stringify(a)))
} catch(c) {
throw Error("Malformed UTF-8 data");
}
},
parse: function(a) {
return b.parse(unescape(encodeURIComponent(a)))
}
},
q = l.BufferedBlockAlgorithm = t.extend({
reset: function() {
this._data = new r.init;
this._nDataBytes = 0
},
_append: function(a) {
"string" == typeof a && (a = x.parse(a));
this._data.concat(a);
this._nDataBytes += a.sigBytes
},
_process: function(a) {
var c = this._data,
e = c.words,
j = c.sigBytes,
k = this.blockSize,
b = j / (4 * k),
b = a ? u.ceil(b) : u.max((b | 0) - this._minBufferSize, 0);
a = b * k;
j = u.min(4 * a, j);
if(a) {
for(var q = 0; q < a; q += k) this._doProcessBlock(e, q);
q = e.splice(0, a);
c.sigBytes -= j
}
return new r.init(q, j)
},
clone: function() {
var a = t.clone.call(this);
a._data = this._data.clone();
return a
},
_minBufferSize: 0
});
l.Hasher = q.extend({
cfg: t.extend(),
init: function(a) {
this.cfg = this.cfg.extend(a);
this.reset()
},
reset: function() {
q.reset.call(this);
this._doReset()
},
update: function(a) {
this._append(a);
this._process();
return this
},
finalize: function(a) {
a && this._append(a);
return this._doFinalize()
},
blockSize: 16,
_createHelper: function(a) {
return function(b, e) {
return(new a.init(e)).finalize(b)
}
},
_createHmacHelper: function(a) {
return function(b, e) {
return(new n.HMAC.init(a,
e)).finalize(b)
}
}
});
var n = d.algo = {};
return d
}(Math);
(function() {
var u = CryptoJS,
p = u.lib.WordArray;
u.enc.Base64 = {
stringify: function(d) {
var l = d.words,
p = d.sigBytes,
t = this._map;
d.clamp();
d = [];
for(var r = 0; r < p; r += 3)
for(var w = (l[r >>> 2] >>> 24 - 8 * (r % 4) & 255) << 16 | (l[r + 1 >>> 2] >>> 24 - 8 * ((r + 1) % 4) & 255) << 8 | l[r + 2 >>> 2] >>> 24 - 8 * ((r + 2) % 4) & 255, v = 0; 4 > v && r + 0.75 * v < p; v++) d.push(t.charAt(w >>> 6 * (3 - v) & 63));
if(l = t.charAt(64))
for(; d.length % 4;) d.push(l);
return d.join("")
},
parse: function(d) {
var l = d.length,
s = this._map,
t = s.charAt(64);
t && (t = d.indexOf(t), -1 != t && (l = t));
for(var t = [], r = 0, w = 0; w <
l; w++)
if(w % 4) {
var v = s.indexOf(d.charAt(w - 1)) << 2 * (w % 4),
b = s.indexOf(d.charAt(w)) >>> 6 - 2 * (w % 4);
t[r >>> 2] |= (v | b) << 24 - 8 * (r % 4);
r++
}
return p.create(t, r)
},
_map: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
}
})();
(function(u) {
function p(b, n, a, c, e, j, k) {
b = b + (n & a | ~n & c) + e + k;
return(b << j | b >>> 32 - j) + n
}
function d(b, n, a, c, e, j, k) {
b = b + (n & c | a & ~c) + e + k;
return(b << j | b >>> 32 - j) + n
}
function l(b, n, a, c, e, j, k) {
b = b + (n ^ a ^ c) + e + k;
return(b << j | b >>> 32 - j) + n
}
function s(b, n, a, c, e, j, k) {
b = b + (a ^ (n | ~c)) + e + k;
return(b << j | b >>> 32 - j) + n
}
for(var t = CryptoJS, r = t.lib, w = r.WordArray, v = r.Hasher, r = t.algo, b = [], x = 0; 64 > x; x++) b[x] = 4294967296 * u.abs(u.sin(x + 1)) | 0;
r = r.MD5 = v.extend({
_doReset: function() {
this._hash = new w.init([1732584193, 4023233417, 2562383102, 271733878])
},
_doProcessBlock: function(q, n) {
for(var a = 0; 16 > a; a++) {
var c = n + a,
e = q[c];
q[c] = (e << 8 | e >>> 24) & 16711935 | (e << 24 | e >>> 8) & 4278255360
}
var a = this._hash.words,
c = q[n + 0],
e = q[n + 1],
j = q[n + 2],
k = q[n + 3],
z = q[n + 4],
r = q[n + 5],
t = q[n + 6],
w = q[n + 7],
v = q[n + 8],
A = q[n + 9],
B = q[n + 10],
C = q[n + 11],
u = q[n + 12],
D = q[n + 13],
E = q[n + 14],
x = q[n + 15],
f = a[0],
m = a[1],
g = a[2],
h = a[3],
f = p(f, m, g, h, c, 7, b[0]),
h = p(h, f, m, g, e, 12, b[1]),
g = p(g, h, f, m, j, 17, b[2]),
m = p(m, g, h, f, k, 22, b[3]),
f = p(f, m, g, h, z, 7, b[4]),
h = p(h, f, m, g, r, 12, b[5]),
g = p(g, h, f, m, t, 17, b[6]),
m = p(m, g, h, f, w, 22, b[7]),
f = p(f, m, g, h, v, 7, b[8]),
h = p(h, f, m, g, A, 12, b[9]),
g = p(g, h, f, m, B, 17, b[10]),
m = p(m, g, h, f, C, 22, b[11]),
f = p(f, m, g, h, u, 7, b[12]),
h = p(h, f, m, g, D, 12, b[13]),
g = p(g, h, f, m, E, 17, b[14]),
m = p(m, g, h, f, x, 22, b[15]),
f = d(f, m, g, h, e, 5, b[16]),
h = d(h, f, m, g, t, 9, b[17]),
g = d(g, h, f, m, C, 14, b[18]),
m = d(m, g, h, f, c, 20, b[19]),
f = d(f, m, g, h, r, 5, b[20]),
h = d(h, f, m, g, B, 9, b[21]),
g = d(g, h, f, m, x, 14, b[22]),
m = d(m, g, h, f, z, 20, b[23]),
f = d(f, m, g, h, A, 5, b[24]),
h = d(h, f, m, g, E, 9, b[25]),
g = d(g, h, f, m, k, 14, b[26]),
m = d(m, g, h, f, v, 20, b[27]),
f = d(f, m, g, h, D, 5, b[28]),
h = d(h, f,
m, g, j, 9, b[29]),
g = d(g, h, f, m, w, 14, b[30]),
m = d(m, g, h, f, u, 20, b[31]),
f = l(f, m, g, h, r, 4, b[32]),
h = l(h, f, m, g, v, 11, b[33]),
g = l(g, h, f, m, C, 16, b[34]),
m = l(m, g, h, f, E, 23, b[35]),
f = l(f, m, g, h, e, 4, b[36]),
h = l(h, f, m, g, z, 11, b[37]),
g = l(g, h, f, m, w, 16, b[38]),
m = l(m, g, h, f, B, 23, b[39]),
f = l(f, m, g, h, D, 4, b[40]),
h = l(h, f, m, g, c, 11, b[41]),
g = l(g, h, f, m, k, 16, b[42]),
m = l(m, g, h, f, t, 23, b[43]),
f = l(f, m, g, h, A, 4, b[44]),
h = l(h, f, m, g, u, 11, b[45]),
g = l(g, h, f, m, x, 16, b[46]),
m = l(m, g, h, f, j, 23, b[47]),
f = s(f, m, g, h, c, 6, b[48]),
h = s(h, f, m, g, w, 10, b[49]),
g = s(g, h, f, m,
E, 15, b[50]),
m = s(m, g, h, f, r, 21, b[51]),
f = s(f, m, g, h, u, 6, b[52]),
h = s(h, f, m, g, k, 10, b[53]),
g = s(g, h, f, m, B, 15, b[54]),
m = s(m, g, h, f, e, 21, b[55]),
f = s(f, m, g, h, v, 6, b[56]),
h = s(h, f, m, g, x, 10, b[57]),
g = s(g, h, f, m, t, 15, b[58]),
m = s(m, g, h, f, D, 21, b[59]),
f = s(f, m, g, h, z, 6, b[60]),
h = s(h, f, m, g, C, 10, b[61]),
g = s(g, h, f, m, j, 15, b[62]),
m = s(m, g, h, f, A, 21, b[63]);
a[0] = a[0] + f | 0;
a[1] = a[1] + m | 0;
a[2] = a[2] + g | 0;
a[3] = a[3] + h | 0
},
_doFinalize: function() {
var b = this._data,
n = b.words,
a = 8 * this._nDataBytes,
c = 8 * b.sigBytes;
n[c >>> 5] |= 128 << 24 - c % 32;
var e = u.floor(a /
4294967296);
n[(c + 64 >>> 9 << 4) + 15] = (e << 8 | e >>> 24) & 16711935 | (e << 24 | e >>> 8) & 4278255360;
n[(c + 64 >>> 9 << 4) + 14] = (a << 8 | a >>> 24) & 16711935 | (a << 24 | a >>> 8) & 4278255360;
b.sigBytes = 4 * (n.length + 1);
this._process();
b = this._hash;
n = b.words;
for(a = 0; 4 > a; a++) c = n[a], n[a] = (c << 8 | c >>> 24) & 16711935 | (c << 24 | c >>> 8) & 4278255360;
return b
},
clone: function() {
var b = v.clone.call(this);
b._hash = this._hash.clone();
return b
}
});
t.MD5 = v._createHelper(r);
t.HmacMD5 = v._createHmacHelper(r)
})(Math);
(function() {
var u = CryptoJS,
p = u.lib,
d = p.Base,
l = p.WordArray,
p = u.algo,
s = p.EvpKDF = d.extend({
cfg: d.extend({
keySize: 4,
hasher: p.MD5,
iterations: 1
}),
init: function(d) {
this.cfg = this.cfg.extend(d)
},
compute: function(d, r) {
for(var p = this.cfg, s = p.hasher.create(), b = l.create(), u = b.words, q = p.keySize, p = p.iterations; u.length < q;) {
n && s.update(n);
var n = s.update(d).finalize(r);
s.reset();
for(var a = 1; a < p; a++) n = s.finalize(n), s.reset();
b.concat(n)
}
b.sigBytes = 4 * q;
return b
}
});
u.EvpKDF = function(d, l, p) {
return s.create(p).compute(d,
l)
}
})();
CryptoJS.lib.Cipher || function(u) {
var p = CryptoJS,
d = p.lib,
l = d.Base,
s = d.WordArray,
t = d.BufferedBlockAlgorithm,
r = p.enc.Base64,
w = p.algo.EvpKDF,
v = d.Cipher = t.extend({
cfg: l.extend(),
createEncryptor: function(e, a) {
return this.create(this._ENC_XFORM_MODE, e, a)
},
createDecryptor: function(e, a) {
return this.create(this._DEC_XFORM_MODE, e, a)
},
init: function(e, a, b) {
this.cfg = this.cfg.extend(b);
this._xformMode = e;
this._key = a;
this.reset()
},
reset: function() {
t.reset.call(this);
this._doReset()
},
process: function(e) {
this._append(e);
return this._process()
},
finalize: function(e) {
e && this._append(e);
return this._doFinalize()
},
keySize: 4,
ivSize: 4,
_ENC_XFORM_MODE: 1,
_DEC_XFORM_MODE: 2,
_createHelper: function(e) {
return {
encrypt: function(b, k, d) {
return("string" == typeof k ? c : a).encrypt(e, b, k, d)
},
decrypt: function(b, k, d) {
return("string" == typeof k ? c : a).decrypt(e, b, k, d)
}
}
}
});
d.StreamCipher = v.extend({
_doFinalize: function() {
return this._process(!0)
},
blockSize: 1
});
var b = p.mode = {},
x = function(e, a, b) {
var c = this._iv;
c ? this._iv = u : c = this._prevBlock;
for(var d = 0; d < b; d++) e[a + d] ^=
c[d]
},
q = (d.BlockCipherMode = l.extend({
createEncryptor: function(e, a) {
return this.Encryptor.create(e, a)
},
createDecryptor: function(e, a) {
return this.Decryptor.create(e, a)
},
init: function(e, a) {
this._cipher = e;
this._iv = a
}
})).extend();
q.Encryptor = q.extend({
processBlock: function(e, a) {
var b = this._cipher,
c = b.blockSize;
x.call(this, e, a, c);
b.encryptBlock(e, a);
this._prevBlock = e.slice(a, a + c)
}
});
q.Decryptor = q.extend({
processBlock: function(e, a) {
var b = this._cipher,
c = b.blockSize,
d = e.slice(a, a + c);
b.decryptBlock(e, a);
x.call(this,
e, a, c);
this._prevBlock = d
}
});
b = b.CBC = q;
q = (p.pad = {}).Pkcs7 = {
pad: function(a, b) {
for(var c = 4 * b, c = c - a.sigBytes % c, d = c << 24 | c << 16 | c << 8 | c, l = [], n = 0; n < c; n += 4) l.push(d);
c = s.create(l, c);
a.concat(c)
},
unpad: function(a) {
a.sigBytes -= a.words[a.sigBytes - 1 >>> 2] & 255
}
};
d.BlockCipher = v.extend({
cfg: v.cfg.extend({
mode: b,
padding: q
}),
reset: function() {
v.reset.call(this);
var a = this.cfg,
b = a.iv,
a = a.mode;
if(this._xformMode == this._ENC_XFORM_MODE) var c = a.createEncryptor;
else c = a.createDecryptor, this._minBufferSize = 1;
this._mode = c.call(a,
this, b && b.words)
},
_doProcessBlock: function(a, b) {
this._mode.processBlock(a, b)
},
_doFinalize: function() {
var a = this.cfg.padding;
if(this._xformMode == this._ENC_XFORM_MODE) {
a.pad(this._data, this.blockSize);
var b = this._process(!0)
} else b = this._process(!0), a.unpad(b);
return b
},
blockSize: 4
});
var n = d.CipherParams = l.extend({
init: function(a) {
this.mixIn(a)
},
toString: function(a) {
return(a || this.formatter).stringify(this)
}
}),
b = (p.format = {}).OpenSSL = {
stringify: function(a) {
var b = a.ciphertext;
a = a.salt;
return(a ? s.create([1398893684,
1701076831
]).concat(a).concat(b) : b).toString(r)
},
parse: function(a) {
a = r.parse(a);
var b = a.words;
if(1398893684 == b[0] && 1701076831 == b[1]) {
var c = s.create(b.slice(2, 4));
b.splice(0, 4);
a.sigBytes -= 16
}
return n.create({
ciphertext: a,
salt: c
})
}
},
a = d.SerializableCipher = l.extend({
cfg: l.extend({
format: b
}),
encrypt: function(a, b, c, d) {
d = this.cfg.extend(d);
var l = a.createEncryptor(c, d);
b = l.finalize(b);
l = l.cfg;
return n.create({
ciphertext: b,
key: c,
iv: l.iv,
algorithm: a,
mode: l.mode,
padding: l.padding,
blockSize: a.blockSize,
formatter: d.format
})
},
decrypt: function(a, b, c, d) {
d = this.cfg.extend(d);
b = this._parse(b, d.format);
return a.createDecryptor(c, d).finalize(b.ciphertext)
},
_parse: function(a, b) {
return "string" == typeof a ? b.parse(a, this) : a
}
}),
p = (p.kdf = {}).OpenSSL = {
execute: function(a, b, c, d) {
d || (d = s.random(8));
a = w.create({
keySize: b + c
}).compute(a, d);
c = s.create(a.words.slice(b), 4 * c);
a.sigBytes = 4 * b;
return n.create({
key: a,
iv: c,
salt: d
})
}
},
c = d.PasswordBasedCipher = a.extend({
cfg: a.cfg.extend({
kdf: p
}),
encrypt: function(b, c, d, l) {
l = this.cfg.extend(l);
d = l.kdf.execute(d,
b.keySize, b.ivSize);
l.iv = d.iv;
b = a.encrypt.call(this, b, c, d.key, l);
b.mixIn(d);
return b
},
decrypt: function(b, c, d, l) {
l = this.cfg.extend(l);
c = this._parse(c, l.format);
d = l.kdf.execute(d, b.keySize, b.ivSize, c.salt);
l.iv = d.iv;
return a.decrypt.call(this, b, c, d.key, l)
}
})
}();
(function() {
for(var u = CryptoJS, p = u.lib.BlockCipher, d = u.algo, l = [], s = [], t = [], r = [], w = [], v = [], b = [], x = [], q = [], n = [], a = [], c = 0; 256 > c; c++) a[c] = 128 > c ? c << 1 : c << 1 ^ 283;
for(var e = 0, j = 0, c = 0; 256 > c; c++) {
var k = j ^ j << 1 ^ j << 2 ^ j << 3 ^ j << 4,
k = k >>> 8 ^ k & 255 ^ 99;
l[e] = k;
s[k] = e;
var z = a[e],
F = a[z],
G = a[F],
y = 257 * a[k] ^ 16843008 * k;
t[e] = y << 24 | y >>> 8;
r[e] = y << 16 | y >>> 16;
w[e] = y << 8 | y >>> 24;
v[e] = y;
y = 16843009 * G ^ 65537 * F ^ 257 * z ^ 16843008 * e;
b[k] = y << 24 | y >>> 8;
x[k] = y << 16 | y >>> 16;
q[k] = y << 8 | y >>> 24;
n[k] = y;
e ? (e = z ^ a[a[a[G ^ z]]], j ^= a[a[j]]) : e = j = 1
}
var H = [0, 1, 2, 4, 8,
16, 32, 64, 128, 27, 54
],
d = d.AES = p.extend({
_doReset: function() {
for(var a = this._key, c = a.words, d = a.sigBytes / 4, a = 4 * ((this._nRounds = d + 6) + 1), e = this._keySchedule = [], j = 0; j < a; j++)
if(j < d) e[j] = c[j];
else {
var k = e[j - 1];
j % d ? 6 < d && 4 == j % d && (k = l[k >>> 24] << 24 | l[k >>> 16 & 255] << 16 | l[k >>> 8 & 255] << 8 | l[k & 255]) : (k = k << 8 | k >>> 24, k = l[k >>> 24] << 24 | l[k >>> 16 & 255] << 16 | l[k >>> 8 & 255] << 8 | l[k & 255], k ^= H[j / d | 0] << 24);
e[j] = e[j - d] ^ k
}
c = this._invKeySchedule = [];
for(d = 0; d < a; d++) j = a - d, k = d % 4 ? e[j] : e[j - 4], c[d] = 4 > d || 4 >= j ? k : b[l[k >>> 24]] ^ x[l[k >>> 16 & 255]] ^ q[l[k >>>
8 & 255]] ^ n[l[k & 255]]
},
encryptBlock: function(a, b) {
this._doCryptBlock(a, b, this._keySchedule, t, r, w, v, l)
},
decryptBlock: function(a, c) {
var d = a[c + 1];
a[c + 1] = a[c + 3];
a[c + 3] = d;
this._doCryptBlock(a, c, this._invKeySchedule, b, x, q, n, s);
d = a[c + 1];
a[c + 1] = a[c + 3];
a[c + 3] = d
},
_doCryptBlock: function(a, b, c, d, e, j, l, f) {
for(var m = this._nRounds, g = a[b] ^ c[0], h = a[b + 1] ^ c[1], k = a[b + 2] ^ c[2], n = a[b + 3] ^ c[3], p = 4, r = 1; r < m; r++) var q = d[g >>> 24] ^ e[h >>> 16 & 255] ^ j[k >>> 8 & 255] ^ l[n & 255] ^ c[p++],
s = d[h >>> 24] ^ e[k >>> 16 & 255] ^ j[n >>> 8 & 255] ^ l[g & 255] ^ c[p++],
t =
d[k >>> 24] ^ e[n >>> 16 & 255] ^ j[g >>> 8 & 255] ^ l[h & 255] ^ c[p++],
n = d[n >>> 24] ^ e[g >>> 16 & 255] ^ j[h >>> 8 & 255] ^ l[k & 255] ^ c[p++],
g = q,
h = s,
k = t;
q = (f[g >>> 24] << 24 | f[h >>> 16 & 255] << 16 | f[k >>> 8 & 255] << 8 | f[n & 255]) ^ c[p++];
s = (f[h >>> 24] << 24 | f[k >>> 16 & 255] << 16 | f[n >>> 8 & 255] << 8 | f[g & 255]) ^ c[p++];
t = (f[k >>> 24] << 24 | f[n >>> 16 & 255] << 16 | f[g >>> 8 & 255] << 8 | f[h & 255]) ^ c[p++];
n = (f[n >>> 24] << 24 | f[g >>> 16 & 255] << 16 | f[h >>> 8 & 255] << 8 | f[k & 255]) ^ c[p++];
a[b] = q;
a[b + 1] = s;
a[b + 2] = t;
a[b + 3] = n
},
keySize: 8
});
u.AES = p._createHelper(d)
})();
! function(t, n) {
"object" == typeof exports ? module.exports = exports = n() : "function" == typeof define && define.amd ? define([], n) : t.CryptoJS = n()
}(this, function() {
var t = t || function(t, n) {
var i = Object.create || function() {
function t() {}
return function(n) {
var i;
return t.prototype = n, i = new t, t.prototype = null, i
}
}(),
e = {},
r = e.lib = {},
o = r.Base = function() {
return {
extend: function(t) {
var n = i(this);
return t && n.mixIn(t), n.hasOwnProperty("init") && this.init !== n.init || (n.init = function() {
n.$super.init.apply(this, arguments)
}), n.init.prototype = n, n.$super = this, n
},
create: function() {
var t = this.extend();
return t.init.apply(t, arguments), t
},
init: function() {},
mixIn: function(t) {
for(var n in t) t.hasOwnProperty(n) && (this[n] = t[n]);
t.hasOwnProperty("toString") && (this.toString = t.toString)
},
clone: function() {
return this.init.prototype.extend(this)
}
}
}(),
s = r.WordArray = o.extend({
init: function(t, i) {
t = this.words = t || [], i != n ? this.sigBytes = i : this.sigBytes = 4 * t.length
},
toString: function(t) {
return(t || c).stringify(this)
},
concat: function(t) {
var n = this.words,
i = t.words,
e = this.sigBytes,
r = t.sigBytes;
if(this.clamp(), e % 4)
for(var o = 0; o < r; o++) {
var s = i[o >>> 2] >>> 24 - o % 4 * 8 & 255;
n[e + o >>> 2] |= s << 24 - (e + o) % 4 * 8
} else
for(var o = 0; o < r; o += 4) n[e + o >>> 2] = i[o >>> 2];
return this.sigBytes += r, this
},
clamp: function() {
var n = this.words,
i = this.sigBytes;
n[i >>> 2] &= 4294967295 << 32 - i % 4 * 8, n.length = t.ceil(i / 4)
},
clone: function() {
var t = o.clone.call(this);
return t.words = this.words.slice(0), t
},
random: function(n) {
for(var i, e = [], r = function(n) {
var n = n,
i = 987654321,
e = 4294967295;
return function() {
i = 36969 * (65535 & i) + (i >> 16) & e, n = 18e3 * (65535 & n) + (n >> 16) & e;
var r = (i << 16) + n & e;
return r /= 4294967296, r += .5, r * (t.random() > .5 ? 1 : -1)
}
}, o = 0; o < n; o += 4) {
var a = r(4294967296 * (i || t.random()));
i = 987654071 * a(), e.push(4294967296 * a() | 0)
}
return new s.init(e, n)
}
}),
a = e.enc = {},
c = a.Hex = {
stringify: function(t) {
for(var n = t.words, i = t.sigBytes, e = [], r = 0; r < i; r++) {
var o = n[r >>> 2] >>> 24 - r % 4 * 8 & 255;
e.push((o >>> 4).toString(16)), e.push((15 & o).toString(16))
}
return e.join("")
},
parse: function(t) {
for(var n = t.length, i = [], e = 0; e < n; e += 2) i[e >>> 3] |= parseInt(t.substr(e, 2), 16) << 24 - e % 8 * 4;
return new s.init(i, n / 2)
}
},
u = a.Latin1 = {
stringify: function(t) {
for(var n = t.words, i = t.sigBytes, e = [], r = 0; r < i; r++) {
var o = n[r >>> 2] >>> 24 - r % 4 * 8 & 255;
e.push(String.fromCharCode(o))
}
return e.join("")
},
parse: function(t) {
for(var n = t.length, i = [], e = 0; e < n; e++) i[e >>> 2] |= (255 & t.charCodeAt(e)) << 24 - e % 4 * 8;
return new s.init(i, n)
}
},
f = a.Utf8 = {
stringify: function(t) {
try {
return decodeURIComponent(escape(u.stringify(t)))
} catch(t) {
throw new Error("Malformed UTF-8 data")
}
},
parse: function(t) {
return u.parse(unescape(encodeURIComponent(t)))
}
},
h = r.BufferedBlockAlgorithm = o.extend({
reset: function() {
this._data = new s.init, this._nDataBytes = 0
},
_append: function(t) {
"string" == typeof t && (t = f.parse(t)), this._data.concat(t), this._nDataBytes += t.sigBytes
},
_process: function(n) {
var i = this._data,
e = i.words,
r = i.sigBytes,
o = this.blockSize,
a = 4 * o,
c = r / a;
c = n ? t.ceil(c) : t.max((0 | c) - this._minBufferSize, 0);
var u = c * o,
f = t.min(4 * u, r);
if(u) {
for(var h = 0; h < u; h += o) this._doProcessBlock(e, h);
var p = e.splice(0, u);
i.sigBytes -= f
}
return new s.init(p, f)
},
clone: function() {
var t = o.clone.call(this);
return t._data = this._data.clone(), t
},
_minBufferSize: 0
}),
p = (r.Hasher = h.extend({
cfg: o.extend(),
init: function(t) {
this.cfg = this.cfg.extend(t), this.reset()
},
reset: function() {
h.reset.call(this), this._doReset()
},
update: function(t) {
return this._append(t), this._process(), this
},
finalize: function(t) {
t && this._append(t);
var n = this._doFinalize();
return n
},
blockSize: 16,
_createHelper: function(t) {
return function(n, i) {
return new t.init(i).finalize(n)
}
},
_createHmacHelper: function(t) {
return function(n, i) {
return new p.HMAC.init(t, i).finalize(n)
}
}
}), e.algo = {});
return e
}(Math);
return t
});
//# sourceMappingURL=core.min.js.map
! function(e, t, i) {
"object" == typeof exports ? module.exports = exports = t(require("./core.min"), require("./sha1.min"), require("./hmac.min")) : "function" == typeof define && define.amd ? define(["./core.min", "./sha1.min", "./hmac.min"], t) : t(e.CryptoJS)
}(this, function(e) {
return function() {
var t = e,
i = t.lib,
r = i.Base,
n = i.WordArray,
o = t.algo,
a = o.MD5,
c = o.EvpKDF = r.extend({
cfg: r.extend({
keySize: 4,
hasher: a,
iterations: 1
}),
init: function(e) {
this.cfg = this.cfg.extend(e)
},
compute: function(e, t) {
for(var i = this.cfg, r = i.hasher.create(), o = n.create(), a = o.words, c = i.keySize, f = i.iterations; a.length < c;) {
s && r.update(s);
var s = r.update(e).finalize(t);
r.reset();
for(var u = 1; u < f; u++) s = r.finalize(s), r.reset();
o.concat(s)
}
return o.sigBytes = 4 * c, o
}
});
t.EvpKDF = function(e, t, i) {
return c.create(i).compute(e, t)
}
}(), e.EvpKDF
});
//# sourceMappingURL=evpkdf.min.js.map
! function(r, e) {
"object" == typeof exports ? module.exports = exports = e(require("./core.min")) : "function" == typeof define && define.amd ? define(["./core.min"], e) : e(r.CryptoJS)
}(this, function(r) {
return function() {
function e(r, e, t) {
for(var n = [], i = 0, o = 0; o < e; o++)
if(o % 4) {
var f = t[r.charCodeAt(o - 1)] << o % 4 * 2,
c = t[r.charCodeAt(o)] >>> 6 - o % 4 * 2;
n[i >>> 2] |= (f | c) << 24 - i % 4 * 8, i++
}
return a.create(n, i)
}
var t = r,
n = t.lib,
a = n.WordArray,
i = t.enc;
i.Base64 = {
stringify: function(r) {
var e = r.words,
t = r.sigBytes,
n = this._map;
r.clamp();
for(var a = [], i = 0; i < t; i += 3)
for(var o = e[i >>> 2] >>> 24 - i % 4 * 8 & 255, f = e[i + 1 >>> 2] >>> 24 - (i + 1) % 4 * 8 & 255, c = e[i + 2 >>> 2] >>> 24 - (i + 2) % 4 * 8 & 255, s = o << 16 | f << 8 | c, h = 0; h < 4 && i + .75 * h < t; h++) a.push(n.charAt(s >>> 6 * (3 - h) & 63));
var p = n.charAt(64);
if(p)
for(; a.length % 4;) a.push(p);
return a.join("")
},
parse: function(r) {
var t = r.length,
n = this._map,
a = this._reverseMap;
if(!a) {
a = this._reverseMap = [];
for(var i = 0; i < n.length; i++) a[n.charCodeAt(i)] = i
}
var o = n.charAt(64);
if(o) {
var f = r.indexOf(o);
f !== -1 && (t = f)
}
return e(r, t, a)
},
_map: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
}
}(), r.enc.Base64
});
//# sourceMappingURL=enc-base64.min.js.map
! function(e, t, r) {
"object" == typeof exports ? module.exports = exports = t(require("./core.min"), require("./evpkdf.min")) : "function" == typeof define && define.amd ? define(["./core.min", "./evpkdf.min"], t) : t(e.CryptoJS)
}(this, function(e) {
e.lib.Cipher || function(t) {
var r = e,
i = r.lib,
n = i.Base,
c = i.WordArray,
o = i.BufferedBlockAlgorithm,
s = r.enc,
a = (s.Utf8, s.Base64),
f = r.algo,
p = f.EvpKDF,
d = i.Cipher = o.extend({
cfg: n.extend(),
createEncryptor: function(e, t) {
return this.create(this._ENC_XFORM_MODE, e, t)
},
createDecryptor: function(e, t) {
return this.create(this._DEC_XFORM_MODE, e, t)
},
init: function(e, t, r) {
this.cfg = this.cfg.extend(r), this._xformMode = e, this._key = t, this.reset()
},
reset: function() {
o.reset.call(this), this._doReset()
},
process: function(e) {
return this._append(e), this._process()
},
finalize: function(e) {
e && this._append(e);
var t = this._doFinalize();
return t
},
keySize: 4,
ivSize: 4,
_ENC_XFORM_MODE: 1,
_DEC_XFORM_MODE: 2,
_createHelper: function() {
function e(e) {
return "string" == typeof e ? B : x
}
return function(t) {
return {
encrypt: function(r, i, n) {
return e(i).encrypt(t, r, i, n)
},
decrypt: function(r, i, n) {
return e(i).decrypt(t, r, i, n)
}
}
}
}()
}),
h = (i.StreamCipher = d.extend({
_doFinalize: function() {
var e = this._process(!0);
return e
},
blockSize: 1
}), r.mode = {}),
u = i.BlockCipherMode = n.extend({
createEncryptor: function(e, t) {
return this.Encryptor.create(e, t)
},
createDecryptor: function(e, t) {
return this.Decryptor.create(e, t)
},
init: function(e, t) {
this._cipher = e, this._iv = t
}
}),
l = h.CBC = function() {
function e(e, r, i) {
var n = this._iv;
if(n) {
var c = n;
this._iv = t
} else var c = this._prevBlock;
for(var o = 0; o < i; o++) e[r + o] ^= c[o]
}
var r = u.extend();
return r.Encryptor = r.extend({
processBlock: function(t, r) {
var i = this._cipher,
n = i.blockSize;
e.call(this, t, r, n), i.encryptBlock(t, r), this._prevBlock = t.slice(r, r + n)
}
}), r.Decryptor = r.extend({
processBlock: function(t, r) {
var i = this._cipher,
n = i.blockSize,
c = t.slice(r, r + n);
i.decryptBlock(t, r), e.call(this, t, r, n), this._prevBlock = c
}
}), r
}(),
_ = r.pad = {},
v = _.Pkcs7 = {
pad: function(e, t) {
for(var r = 4 * t, i = r - e.sigBytes % r, n = i << 24 | i << 16 | i << 8 | i, o = [], s = 0; s < i; s += 4) o.push(n);
var a = c.create(o, i);
e.concat(a)
},
unpad: function(e) {
var t = 255 & e.words[e.sigBytes - 1 >>> 2];
e.sigBytes -= t
}
},
y = (i.BlockCipher = d.extend({
cfg: d.cfg.extend({
mode: l,
padding: v
}),
reset: function() {
d.reset.call(this);
var e = this.cfg,
t = e.iv,
r = e.mode;
if(this._xformMode == this._ENC_XFORM_MODE) var i = r.createEncryptor;
else {
var i = r.createDecryptor;
this._minBufferSize = 1
}
this._mode && this._mode.__creator == i ? this._mode.init(this, t && t.words) : (this._mode = i.call(r, this, t && t.words), this._mode.__creator = i)
},
_doProcessBlock: function(e, t) {
this._mode.processBlock(e, t)
},
_doFinalize: function() {
var e = this.cfg.padding;
if(this._xformMode == this._ENC_XFORM_MODE) {
e.pad(this._data, this.blockSize);
var t = this._process(!0)
} else {
var t = this._process(!0);
e.unpad(t)
}
return t
},
blockSize: 4
}), i.CipherParams = n.extend({
init: function(e) {
this.mixIn(e)
},
toString: function(e) {
return(e || this.formatter).stringify(this)
}
})),
m = r.format = {},
k = m.OpenSSL = {
stringify: function(e) {
var t = e.ciphertext,
r = e.salt;
if(r) var i = c.create([1398893684, 1701076831]).concat(r).concat(t);
else var i = t;
return i.toString(a)
},
parse: function(e) {
var t = a.parse(e),
r = t.words;
if(1398893684 == r[0] && 1701076831 == r[1]) {
var i = c.create(r.slice(2, 4));
r.splice(0, 4), t.sigBytes -= 16
}
return y.create({
ciphertext: t,
salt: i
})
}
},
x = i.SerializableCipher = n.extend({
cfg: n.extend({
format: k
}),
encrypt: function(e, t, r, i) {
i = this.cfg.extend(i);
var n = e.createEncryptor(r, i),
c = n.finalize(t),
o = n.cfg;
return y.create({
ciphertext: c,
key: r,
iv: o.iv,
algorithm: e,
mode: o.mode,
padding: o.padding,
blockSize: e.blockSize,
formatter: i.format
})
},
decrypt: function(e, t, r, i) {
i = this.cfg.extend(i), t = this._parse(t, i.format);
var n = e.createDecryptor(r, i).finalize(t.ciphertext);
return n
},
_parse: function(e, t) {
return "string" == typeof e ? t.parse(e, this) : e
}
}),
g = r.kdf = {},
S = g.OpenSSL = {
execute: function(e, t, r, i) {
i || (i = c.random(8));
var n = p.create({
keySize: t + r
}).compute(e, i),
o = c.create(n.words.slice(t), 4 * r);
return n.sigBytes = 4 * t, y.create({
key: n,
iv: o,
salt: i
})
}
},
B = i.PasswordBasedCipher = x.extend({
cfg: x.cfg.extend({
kdf: S
}),
encrypt: function(e, t, r, i) {
i = this.cfg.extend(i);
var n = i.kdf.execute(r, e.keySize, e.ivSize);
i.iv = n.iv;
var c = x.encrypt.call(this, e, t, n.key, i);
return c.mixIn(n), c
},
decrypt: function(e, t, r, i) {
i = this.cfg.extend(i), t = this._parse(t, i.format);
var n = i.kdf.execute(r, e.keySize, e.ivSize, t.salt);
i.iv = n.iv;
var c = x.decrypt.call(this, e, t, n.key, i);
return c
}
})
}()
});
//# sourceMappingURL=cipher-core.min.js.map
! function(e, i) {
"object" == typeof exports ? module.exports = exports = i(require("./core.min")) : "function" == typeof define && define.amd ? define(["./core.min"], i) : i(e.CryptoJS)
}(this, function(e) {
! function() {
var i = e,
t = i.lib,
n = t.Base,
s = i.enc,
r = s.Utf8,
o = i.algo;
o.HMAC = n.extend({
init: function(e, i) {
e = this._hasher = new e.init, "string" == typeof i && (i = r.parse(i));
var t = e.blockSize,
n = 4 * t;
i.sigBytes > n && (i = e.finalize(i)), i.clamp();
for(var s = this._oKey = i.clone(), o = this._iKey = i.clone(), a = s.words, f = o.words, c = 0; c < t; c++) a[c] ^= 1549556828, f[c] ^= 909522486;
s.sigBytes = o.sigBytes = n, this.reset()
},
reset: function() {
var e = this._hasher;
e.reset(), e.update(this._iKey)
},
update: function(e) {
return this._hasher.update(e), this
},
finalize: function(e) {
var i = this._hasher,
t = i.finalize(e);
i.reset();
var n = i.finalize(this._oKey.clone().concat(t));
return n
}
})
}()
});
//# sourceMappingURL=hmac.min.js.map
! function(e, o, r) {
"object" == typeof exports ? module.exports = exports = o(require("./core.min"), require("./cipher-core.min")) : "function" == typeof define && define.amd ? define(["./core.min", "./cipher-core.min"], o) : o(e.CryptoJS)
}(this, function(e) {
return e.mode.ECB = function() {
var o = e.lib.BlockCipherMode.extend();
return o.Encryptor = o.extend({
processBlock: function(e, o) {
this._cipher.encryptBlock(e, o)
}
}), o.Decryptor = o.extend({
processBlock: function(e, o) {
this._cipher.decryptBlock(e, o)
}
}), o
}(), e.mode.ECB
});
//# sourceMappingURL=mode-ecb.min.js.map
! function(e, r, i) {
"object" == typeof exports ? module.exports = exports = r(require("./core.min"), require("./cipher-core.min")) : "function" == typeof define && define.amd ? define(["./core.min", "./cipher-core.min"], r) : r(e.CryptoJS)
}(this, function(e) {
return e.pad.Pkcs7
});
//# sourceMappingURL=pad-pkcs7.min.js.map
! function(e, r, i) {
"object" == typeof exports ? module.exports = exports = r(require("./core.min"), require("./enc-base64.min"), require("./md5.min"), require("./evpkdf.min"), require("./cipher-core.min")) : "function" == typeof define && define.amd ? define(["./core.min", "./enc-base64.min", "./md5.min", "./evpkdf.min", "./cipher-core.min"], r) : r(e.CryptoJS)
}(this, function(e) {
return function() {
var r = e,
i = r.lib,
n = i.BlockCipher,
o = r.algo,
t = [],
c = [],
s = [],
f = [],
a = [],
d = [],
u = [],
v = [],
h = [],
y = [];
! function() {
for(var e = [], r = 0; r < 256; r++) r < 128 ? e[r] = r << 1 : e[r] = r << 1 ^ 283;
for(var i = 0, n = 0, r = 0; r < 256; r++) {
var o = n ^ n << 1 ^ n << 2 ^ n << 3 ^ n << 4;
o = o >>> 8 ^ 255 & o ^ 99, t[i] = o, c[o] = i;
var p = e[i],
l = e[p],
_ = e[l],
k = 257 * e[o] ^ 16843008 * o;
s[i] = k << 24 | k >>> 8, f[i] = k << 16 | k >>> 16, a[i] = k << 8 | k >>> 24, d[i] = k;
var k = 16843009 * _ ^ 65537 * l ^ 257 * p ^ 16843008 * i;
u[o] = k << 24 | k >>> 8, v[o] = k << 16 | k >>> 16, h[o] = k << 8 | k >>> 24, y[o] = k, i ? (i = p ^ e[e[e[_ ^ p]]], n ^= e[e[n]]) : i = n = 1
}
}();
var p = [0, 1, 2, 4, 8, 16, 32, 64, 128, 27, 54],
l = o.AES = n.extend({
_doReset: function() {
if(!this._nRounds || this._keyPriorReset !== this._key) {
for(var e = this._keyPriorReset = this._key, r = e.words, i = e.sigBytes / 4, n = this._nRounds = i + 6, o = 4 * (n + 1), c = this._keySchedule = [], s = 0; s < o; s++)
if(s < i) c[s] = r[s];
else {
var f = c[s - 1];
s % i ? i > 6 && s % i == 4 && (f = t[f >>> 24] << 24 | t[f >>> 16 & 255] << 16 | t[f >>> 8 & 255] << 8 | t[255 & f]) : (f = f << 8 | f >>> 24, f = t[f >>> 24] << 24 | t[f >>> 16 & 255] << 16 | t[f >>> 8 & 255] << 8 | t[255 & f], f ^= p[s / i | 0] << 24), c[s] = c[s - i] ^ f
}
for(var a = this._invKeySchedule = [], d = 0; d < o; d++) {
var s = o - d;
if(d % 4) var f = c[s];
else var f = c[s - 4];
d < 4 || s <= 4 ? a[d] = f : a[d] = u[t[f >>> 24]] ^ v[t[f >>> 16 & 255]] ^ h[t[f >>> 8 & 255]] ^ y[t[255 & f]]
}
}
},
encryptBlock: function(e, r) {
this._doCryptBlock(e, r, this._keySchedule, s, f, a, d, t)
},
decryptBlock: function(e, r) {
var i = e[r + 1];
e[r + 1] = e[r + 3], e[r + 3] = i, this._doCryptBlock(e, r, this._invKeySchedule, u, v, h, y, c);
var i = e[r + 1];
e[r + 1] = e[r + 3], e[r + 3] = i
},
_doCryptBlock: function(e, r, i, n, o, t, c, s) {
for(var f = this._nRounds, a = e[r] ^ i[0], d = e[r + 1] ^ i[1], u = e[r + 2] ^ i[2], v = e[r + 3] ^ i[3], h = 4, y = 1; y < f; y++) {
var p = n[a >>> 24] ^ o[d >>> 16 & 255] ^ t[u >>> 8 & 255] ^ c[255 & v] ^ i[h++],
l = n[d >>> 24] ^ o[u >>> 16 & 255] ^ t[v >>> 8 & 255] ^ c[255 & a] ^ i[h++],
_ = n[u >>> 24] ^ o[v >>> 16 & 255] ^ t[a >>> 8 & 255] ^ c[255 & d] ^ i[h++],
k = n[v >>> 24] ^ o[a >>> 16 & 255] ^ t[d >>> 8 & 255] ^ c[255 & u] ^ i[h++];
a = p, d = l, u = _, v = k
}
var p = (s[a >>> 24] << 24 | s[d >>> 16 & 255] << 16 | s[u >>> 8 & 255] << 8 | s[255 & v]) ^ i[h++],
l = (s[d >>> 24] << 24 | s[u >>> 16 & 255] << 16 | s[v >>> 8 & 255] << 8 | s[255 & a]) ^ i[h++],
_ = (s[u >>> 24] << 24 | s[v >>> 16 & 255] << 16 | s[a >>> 8 & 255] << 8 | s[255 & d]) ^ i[h++],
k = (s[v >>> 24] << 24 | s[a >>> 16 & 255] << 16 | s[d >>> 8 & 255] << 8 | s[255 & u]) ^ i[h++];
e[r] = p, e[r + 1] = l, e[r + 2] = _, e[r + 3] = k
},
keySize: 8
});
r.AES = n._createHelper(l)
}(), e.AES
});
//# sourceMappingURL=aes.min.js.map
! function(e, n) {
"object" == typeof exports ? module.exports = exports = n(require("./core.min")) : "function" == typeof define && define.amd ? define(["./core.min"], n) : n(e.CryptoJS)
}(this, function(e) {
return e.enc.Utf8
});
//# sourceMappingURL=enc-utf8.min.js.map
\ No newline at end of file
const appword = "aKd20dbGdFvmuwrt" // 固定值
window.onload = function() {
getUserInfo()
}
function getUserInfo() {
lightAppJssdk.user.getUserInfoWithEncryptedParamByAppId({
appId: "whsdsjzxsfrzdjqwsczptsr", //"gqyjglptxiefn", // 接入方在成功创建应用后自动生成
success: function(data) {
if (data == '未登录') onLoginApp()
else {
if (typeof data == 'string')
data = JSON.parse(data)
console.log('请求成功的数据', data)
// 对于该方法的返回结果,需要进行两步解密才能得到明文用户信息,
// 先对返回结果进行sm2解密,需要用到 接入方在创建应用时,选择应用的加密方式为sm2,并成功创建应用后,拿到的应用私钥来进行解密
const sm2_privateKey = '145e8920d0ec9b60eaaa73a208e711a68e8aa614b786e45d3eb7eca850ba7843'
let sm2_encrypt_result = data.data
let sm2_decrypt_result = sm2_Decrypt(sm2_encrypt_result, sm2_privateKey)
if (typeof sm2_decrypt_result == 'string')
sm2_decrypt_result = JSON.parse(sm2_decrypt_result)
// 其次,对sm2解密后的结果进行 aes解密
// aes解密需要用到 appword , 为固定值,使用示例代码中的即可
let aes_encrypt_result = sm2_decrypt_result.data
let aes_decrypt_result = aes_Decrypt(aes_encrypt_result, appword)
// 请求获取高区应急后台真是token,传参,授权获取的用户信息
http2.post({
serviceId: 'gqyjglptthHiddenDanger',
interfacePublicKey: "041a0802713d674bfc3db46293d83e2b3ebe99cd0ee9b5ae507a0aa07f41cd8bf1407d8c16fab3ceb28bfa233452417373ac0c7864e085895a27b4ebf14b2eb3b1",
interfacePrivateKey: "73ae80b0f34740ce795821bf4354f1621e4ab7d01d9f3f7fc7c05e52c527c528",
reqParams: {id: '4234234'}
}, function(res){
if(res){
console.log('接口回调数据', JSON.parse(res))
// 存储后台返回token存储本地localstorage
}
})
}
},
fail: function(data) {
}
});
}
/**
* 使用jssdk调用登录页面
*/
function onLoginApp() {
lightAppJssdk.user.loginapp({
success: function(data) {
if (data == "未登录") {
//取消登录或登录失败,关闭页面
oncloseWindow()
} else {
getUserInfo()
}
},
fail: function(data) {
//关闭页面
oncloseWindow()
}
})
}
/**
* 关闭容器
*/
function oncloseWindow() {
lightAppJssdk.navigation.close({
success: function(data) {},
fail: function(data) {}
})
}
// aes解密
function aes_Decrypt(word, key) {
var key = CryptoJS.enc.Utf8.parse(key) //转为128bit
var srcs = CryptoJS.enc.Hex.parse(word) //转为16进制
var str = CryptoJS.enc.Base64.stringify(srcs) //变为Base64编码的字符串
var decrypt = CryptoJS.AES.decrypt(str, key, {
mode: CryptoJS.mode.ECB,
spadding: CryptoJS.pad.Pkcs7
})
return decrypt.toString(CryptoJS.enc.Utf8)
}
// sm2解密,需要创建加密应用时的私钥
function sm2_Decrypt(word, key) {
return SM.decrypt(word, key)
}
\ No newline at end of file
var hexcase = 0;
var b64pad = "";
var chrsz = 8;
function hex_md5(s){ return binl2hex(core_md5(str2binl(s), s.length * chrsz));}
function b64_md5(s){ return binl2b64(core_md5(str2binl(s), s.length * chrsz));}
function hex_hmac_md5(key, data) { return binl2hex(core_hmac_md5(key, data)); }
function b64_hmac_md5(key, data) { return binl2b64(core_hmac_md5(key, data)); }
function calcMD5(s){ return binl2hex(core_md5(str2binl(s), s.length * chrsz));}
function md5_vm_test()
{
return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72";
}
function core_md5(x, len)
{
x[len >> 5] |= 0x80 << ((len) % 32);
x[(((len + 64) >>> 9) << 4) + 14] = len;
var a = 1732584193;
var b = -271733879;
var c = -1732584194;
var d = 271733878;
for(var i = 0; i < x.length; i += 16)
{
var olda = a;
var oldb = b;
var oldc = c;
var oldd = d;
a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);
d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);
c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819);
b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);
a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);
d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426);
c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);
b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983);
a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416);
d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);
c = md5_ff(c, d, a, b, x[i+10], 17, -42063);
b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162);
a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682);
d = md5_ff(d, a, b, c, x[i+13], 12, -40341101);
c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290);
b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329);
a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);
d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
c = md5_gg(c, d, a, b, x[i+11], 14, 643717713);
b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302);
a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);
d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083);
c = md5_gg(c, d, a, b, x[i+15], 14, -660478335);
b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848);
a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438);
d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690);
c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961);
b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501);
a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467);
d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);
c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473);
b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734);
a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);
d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);
c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562);
b = md5_hh(b, c, d, a, x[i+14], 23, -35309556);
a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353);
c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);
b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640);
a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174);
d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222);
c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979);
b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189);
a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);
d = md5_hh(d, a, b, c, x[i+12], 11, -421815835);
c = md5_hh(c, d, a, b, x[i+15], 16, 530742520);
b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);
a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);
d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415);
c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905);
b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055);
a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571);
d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);
c = md5_ii(c, d, a, b, x[i+10], 15, -1051523);
b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);
a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359);
d = md5_ii(d, a, b, c, x[i+15], 10, -30611744);
c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);
b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649);
a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);
d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379);
c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259);
b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);
a = safe_add(a, olda);
b = safe_add(b, oldb);
c = safe_add(c, oldc);
d = safe_add(d, oldd);
}
return Array(a, b, c, d);
}
function md5_cmn(q, a, b, x, s, t)
{
return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);
}
function md5_ff(a, b, c, d, x, s, t)
{
return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
}
function md5_gg(a, b, c, d, x, s, t)
{
return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
}
function md5_hh(a, b, c, d, x, s, t)
{
return md5_cmn(b ^ c ^ d, a, b, x, s, t);
}
function md5_ii(a, b, c, d, x, s, t)
{
return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
}
function core_hmac_md5(key, data)
{
var bkey = str2binl(key);
if(bkey.length > 16) bkey = core_md5(bkey, key.length * chrsz);
var ipad = Array(16), opad = Array(16);
for(var i = 0; i < 16; i++)
{
ipad[i] = bkey[i] ^ 0x36363636;
opad[i] = bkey[i] ^ 0x5C5C5C5C;
}
var hash = core_md5(ipad.concat(str2binl(data)), 512 + data.length * chrsz);
return core_md5(opad.concat(hash), 512 + 128);
}
function safe_add(x, y)
{
var lsw = (x & 0xFFFF) + (y & 0xFFFF);
var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
return (msw << 16) | (lsw & 0xFFFF);
}
function bit_rol(num, cnt)
{
return (num << cnt) | (num >>> (32 - cnt));
}
function str2binl(str)
{
var bin = Array();
var mask = (1 << chrsz) - 1;
for(var i = 0; i < str.length * chrsz; i += chrsz)
bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32);
return bin;
}
function binl2hex(binarray)
{
var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
var str = "";
for(var i = 0; i < binarray.length * 4; i++)
{
str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) +
hex_tab.charAt((binarray[i>>2] >> ((i%4)*8 )) & 0xF);
}
return str;
}
function binl2b64(binarray)
{
var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
var str = "";
for(var i = 0; i < binarray.length * 4; i += 3)
{
var triplet = (((binarray[i >> 2] >> 8 * ( i %4)) & 0xFF) << 16)
| (((binarray[i+1 >> 2] >> 8 * ((i+1)%4)) & 0xFF) << 8 )
| ((binarray[i+2 >> 2] >> 8 * ((i+2)%4)) & 0xFF);
for(var j = 0; j < 4; j++)
{
if(i * 8 + j * 6 > binarray.length * 32) str += b64pad;
else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F);
}
}
return str;
}
\ No newline at end of file
/*
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
* This devtool is neither made for production nor for readable output files.
* It uses "eval()" calls to create a separate source file in the browser devtools.
* If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
* or disable the default devtool with "devtool: false".
* If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
*/
var SM;
/******/ (() => { // webpackBootstrap
/******/ "use strict";
/******/ var __webpack_modules__ = ({
/***/ "./index.js":
/*!******************!*\
!*** ./index.js ***!
\******************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"decrypt\": () => (/* reexport safe */ _src_encrypt__WEBPACK_IMPORTED_MODULE_0__.decrypt),\n/* harmony export */ \"encrypt\": () => (/* reexport safe */ _src_encrypt__WEBPACK_IMPORTED_MODULE_0__.encrypt)\n/* harmony export */ });\n/* harmony import */ var _src_encrypt__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./src/encrypt */ \"./src/encrypt.js\");\n\r\n\n\n//# sourceURL=webpack://SM/./index.js?");
/***/ }),
/***/ "./src/encrypt.js":
/*!************************!*\
!*** ./src/encrypt.js ***!
\************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"decrypt\": () => (/* binding */ decrypt),\n/* harmony export */ \"encrypt\": () => (/* binding */ encrypt)\n/* harmony export */ });\n/* harmony import */ var _sm2__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./sm2 */ \"./src/sm2/index.js\");\n\r\n\r\nfunction encrypt(str, pubk) {\r\n return '04' + _sm2__WEBPACK_IMPORTED_MODULE_0__[\"default\"].doEncrypt(str, pubk, 1)\r\n}\r\nfunction decrypt(str, pri) {\r\n str = str.substring(2)\r\n return _sm2__WEBPACK_IMPORTED_MODULE_0__[\"default\"].doDecrypt(str, pri, 1)\r\n}\r\n\r\n\r\n\n\n//# sourceURL=webpack://SM/./src/encrypt.js?");
/***/ }),
/***/ "./src/sm2/asn1.js":
/*!*************************!*\
!*** ./src/sm2/asn1.js ***!
\*************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"decodeDer\": () => (/* binding */ decodeDer),\n/* harmony export */ \"encodeDer\": () => (/* binding */ encodeDer)\n/* harmony export */ });\n/* harmony import */ var _jsbn_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./jsbn.js */ \"./src/sm2/jsbn.js\");\n/* eslint-disable eqeqeq */\r\n\r\n\r\nfunction bigIntToMinTwosComplementsHex (bigIntegerValue) {\r\n let h = bigIntegerValue.toString(16)\r\n if (h.substr(0, 1) != '-') {\r\n if (h.length % 2 == 1) {\r\n h = '0' + h\r\n } else if (!h.match(/^[0-7]/)) {\r\n h = '00' + h\r\n }\r\n } else {\r\n const hPos = h.substr(1)\r\n let xorLen = hPos.length\r\n if (xorLen % 2 == 1) {\r\n xorLen += 1\r\n } else if (!h.match(/^[0-7]/)) {\r\n xorLen += 2\r\n }\r\n let hMask = ''\r\n for (let i = 0; i < xorLen; i++) {\r\n hMask += 'f'\r\n }\r\n const biMask = new _jsbn_js__WEBPACK_IMPORTED_MODULE_0__.BigInteger(hMask, 16)\r\n const biNeg = biMask.xor(bigIntegerValue).add(_jsbn_js__WEBPACK_IMPORTED_MODULE_0__.BigInteger.ONE)\r\n h = biNeg.toString(16).replace(/^-/, '')\r\n }\r\n return h\r\n}\r\n\r\n/**\r\n * base class for ASN.1 DER encoder object\r\n */\r\nclass ASN1Object {\r\n constructor () {\r\n this.isModified = true\r\n this.hTLV = null\r\n this.hT = '00'\r\n this.hL = '00'\r\n this.hV = ''\r\n }\r\n\r\n /**\r\n * get hexadecimal ASN.1 TLV length(L) bytes from TLV value(V)\r\n */\r\n getLengthHexFromValue () {\r\n const n = this.hV.length / 2\r\n let hN = n.toString(16)\r\n if (hN.length % 2 == 1) {\r\n hN = '0' + hN\r\n }\r\n if (n < 128) {\r\n return hN\r\n } else {\r\n const hNlen = hN.length / 2\r\n const head = 128 + hNlen\r\n return head.toString(16) + hN\r\n }\r\n }\r\n\r\n /**\r\n * get hexadecimal string of ASN.1 TLV bytes\r\n */\r\n getEncodedHex () {\r\n if (this.hTLV == null || this.isModified) {\r\n this.hV = this.getFreshValueHex()\r\n this.hL = this.getLengthHexFromValue()\r\n this.hTLV = this.hT + this.hL + this.hV\r\n this.isModified = false\r\n }\r\n return this.hTLV\r\n }\r\n\r\n getFreshValueHex () {\r\n return ''\r\n }\r\n};\r\n\r\n/**\r\n * class for ASN.1 DER Integer\r\n */\r\nclass DERInteger extends ASN1Object {\r\n constructor (options) {\r\n super()\r\n\r\n this.hT = '02'\r\n if (options && options.bigint) {\r\n this.hTLV = null\r\n this.isModified = true\r\n this.hV = bigIntToMinTwosComplementsHex(options.bigint)\r\n }\r\n }\r\n\r\n getFreshValueHex () {\r\n return this.hV\r\n }\r\n}\r\n\r\n/**\r\n * class for ASN.1 DER Sequence\r\n */\r\nclass DERSequence extends ASN1Object {\r\n constructor (options) {\r\n super()\r\n\r\n this.hT = '30'\r\n this.asn1Array = []\r\n if (options && options.array) {\r\n this.asn1Array = options.array\r\n }\r\n }\r\n\r\n getFreshValueHex () {\r\n let h = ''\r\n for (let i = 0; i < this.asn1Array.length; i++) {\r\n const asn1Obj = this.asn1Array[i]\r\n h += asn1Obj.getEncodedHex()\r\n }\r\n this.hV = h\r\n return this.hV\r\n }\r\n}\r\n\r\n/**\r\n * get byte length for ASN.1 L(length) bytes\r\n */\r\nfunction getByteLengthOfL (s, pos) {\r\n if (s.substring(pos + 2, pos + 3) != '8') return 1\r\n const i = parseInt(s.substring(pos + 3, pos + 4))\r\n if (i == 0) return -1 // length octet '80' indefinite length\r\n if (i > 0 && i < 10) return i + 1 // including '8?' octet;\r\n return -2 // malformed format\r\n}\r\n\r\n/**\r\n * get hexadecimal string for ASN.1 L(length) bytes\r\n */\r\nfunction getHexOfL (s, pos) {\r\n const len = getByteLengthOfL(s, pos)\r\n if (len < 1) return ''\r\n return s.substring(pos + 2, pos + 2 + len * 2)\r\n}\r\n\r\n/**\r\n * get integer value of ASN.1 length for ASN.1 data\r\n */\r\nfunction getIntOfL (s, pos) {\r\n const hLength = getHexOfL(s, pos)\r\n if (hLength == '') return -1\r\n let bi\r\n if (parseInt(hLength.substring(0, 1)) < 8) {\r\n bi = new _jsbn_js__WEBPACK_IMPORTED_MODULE_0__.BigInteger(hLength, 16)\r\n } else {\r\n bi = new _jsbn_js__WEBPACK_IMPORTED_MODULE_0__.BigInteger(hLength.substring(2), 16)\r\n }\r\n return bi.intValue()\r\n}\r\n\r\n/**\r\n * get ASN.1 value starting string position for ASN.1 object refered by index 'idx'.\r\n */\r\nfunction getStartPosOfV (s, pos) {\r\n const lLen = getByteLengthOfL(s, pos)\r\n if (lLen < 0) return lLen\r\n return pos + (lLen + 1) * 2\r\n}\r\n\r\n/**\r\n * get hexadecimal string of ASN.1 V(value)\r\n */\r\nfunction getHexOfV (s, pos) {\r\n const pos1 = getStartPosOfV(s, pos)\r\n const len = getIntOfL(s, pos)\r\n return s.substring(pos1, pos1 + len * 2)\r\n}\r\n\r\n/**\r\n * get next sibling starting index for ASN.1 object string\r\n */\r\nfunction getPosOfNextSibling (s, pos) {\r\n const pos1 = getStartPosOfV(s, pos)\r\n const len = getIntOfL(s, pos)\r\n return pos1 + len * 2\r\n}\r\n\r\n/**\r\n * get array of indexes of child ASN.1 objects\r\n */\r\nfunction getPosArrayOfChildren (h, pos) {\r\n const a = []\r\n const p0 = getStartPosOfV(h, pos)\r\n a.push(p0)\r\n\r\n const len = getIntOfL(h, pos)\r\n let p = p0\r\n let k = 0\r\n while (1) {\r\n var pNext = getPosOfNextSibling(h, p)\r\n if (pNext == null || (pNext - p0 >= (len * 2))) break\r\n if (k >= 200) break\r\n\r\n a.push(pNext)\r\n p = pNext\r\n\r\n k++\r\n }\r\n\r\n return a\r\n}\r\n\r\n/**\r\n * ASN.1 DER编码\r\n */\r\nfunction encodeDer (r, s) {\r\n const derR = new DERInteger({ bigint: r })\r\n const derS = new DERInteger({ bigint: s })\r\n const derSeq = new DERSequence({ array: [derR, derS] })\r\n\r\n return derSeq.getEncodedHex()\r\n}\r\n\r\n/**\r\n * 解析 ASN.1 DER\r\n */\r\nfunction decodeDer (input) {\r\n // 1. Items of ASN.1 Sequence Check\r\n const a = getPosArrayOfChildren(input, 0)\r\n\r\n // 2. Integer check\r\n const iTLV1 = a[0]\r\n const iTLV2 = a[1]\r\n\r\n // 3. getting value\r\n const hR = getHexOfV(input, iTLV1)\r\n const hS = getHexOfV(input, iTLV2)\r\n\r\n const r = new _jsbn_js__WEBPACK_IMPORTED_MODULE_0__.BigInteger(hR, 16)\r\n const s = new _jsbn_js__WEBPACK_IMPORTED_MODULE_0__.BigInteger(hS, 16)\r\n\r\n return { r, s }\r\n}\r\n\r\n\r\n\n\n//# sourceURL=webpack://SM/./src/sm2/asn1.js?");
/***/ }),
/***/ "./src/sm2/ec.js":
/*!***********************!*\
!*** ./src/sm2/ec.js ***!
\***********************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"ECCurveFp\": () => (/* binding */ ECCurveFp),\n/* harmony export */ \"ECPointFp\": () => (/* binding */ ECPointFp)\n/* harmony export */ });\n/* harmony import */ var _jsbn_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./jsbn.js */ \"./src/sm2/jsbn.js\");\n/* eslint-disable eqeqeq */\r\n\r\n\r\n/**\r\n * thanks for Tom Wu : http://www-cs-students.stanford.edu/~tjw/jsbn/\r\n *\r\n * Basic Javascript Elliptic Curve implementation\r\n * Ported loosely from BouncyCastle's Java EC code\r\n * Only Fp curves implemented for now\r\n */\r\n\r\nconst THREE = new _jsbn_js__WEBPACK_IMPORTED_MODULE_0__.BigInteger('3')\r\n\r\n/**\r\n * 椭圆曲线域元素\r\n */\r\nclass ECFieldElementFp {\r\n constructor (q, x) {\r\n this.x = x\r\n this.q = q\r\n }\r\n\r\n /**\r\n * 判断相等\r\n */\r\n equals (other) {\r\n if (other == this) return true\r\n return (this.q.equals(other.q) && this.x.equals(other.x))\r\n }\r\n\r\n /**\r\n * 返回具体数值\r\n */\r\n toBigInteger () {\r\n return this.x\r\n }\r\n\r\n /**\r\n * 取反\r\n */\r\n negate () {\r\n return new ECFieldElementFp(this.q, this.x.negate().mod(this.q))\r\n }\r\n\r\n /**\r\n * 相加\r\n */\r\n add (b) {\r\n return new ECFieldElementFp(this.q, this.x.add(b.toBigInteger()).mod(this.q))\r\n }\r\n\r\n /**\r\n * 相减\r\n */\r\n subtract (b) {\r\n return new ECFieldElementFp(this.q, this.x.subtract(b.toBigInteger()).mod(this.q))\r\n }\r\n\r\n /**\r\n * 相乘\r\n */\r\n multiply (b) {\r\n return new ECFieldElementFp(this.q, this.x.multiply(b.toBigInteger()).mod(this.q))\r\n }\r\n\r\n /**\r\n * 相除\r\n */\r\n divide (b) {\r\n return new ECFieldElementFp(this.q, this.x.multiply(b.toBigInteger().modInverse(this.q)).mod(this.q))\r\n }\r\n\r\n /**\r\n * 平方\r\n */\r\n square () {\r\n return new ECFieldElementFp(this.q, this.x.square().mod(this.q))\r\n }\r\n}\r\n\r\nclass ECPointFp {\r\n constructor (curve, x, y, z) {\r\n this.curve = curve\r\n this.x = x\r\n this.y = y\r\n // 标准射影坐标系:zinv == null 或 z * zinv == 1\r\n this.z = z == undefined ? _jsbn_js__WEBPACK_IMPORTED_MODULE_0__.BigInteger.ONE : z\r\n this.zinv = null\r\n // TODO: compression flag\r\n }\r\n\r\n getX () {\r\n if (this.zinv == null) this.zinv = this.z.modInverse(this.curve.q)\r\n\r\n return this.curve.fromBigInteger(this.x.toBigInteger().multiply(this.zinv).mod(this.curve.q))\r\n }\r\n\r\n getY () {\r\n if (this.zinv == null) this.zinv = this.z.modInverse(this.curve.q)\r\n\r\n return this.curve.fromBigInteger(this.y.toBigInteger().multiply(this.zinv).mod(this.curve.q))\r\n }\r\n\r\n /**\r\n * 判断相等\r\n */\r\n equals (other) {\r\n if (other == this) return true\r\n if (this.isInfinity()) return other.isInfinity()\r\n if (other.isInfinity()) return this.isInfinity()\r\n\r\n // u = y2 * z1 - y1 * z2\r\n const u = other.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(other.z)).mod(this.curve.q)\r\n if (!u.equals(_jsbn_js__WEBPACK_IMPORTED_MODULE_0__.BigInteger.ZERO)) return false\r\n\r\n // v = x2 * z1 - x1 * z2\r\n const v = other.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(other.z)).mod(this.curve.q)\r\n return v.equals(_jsbn_js__WEBPACK_IMPORTED_MODULE_0__.BigInteger.ZERO)\r\n }\r\n\r\n /**\r\n * 是否是无穷远点\r\n */\r\n isInfinity () {\r\n if ((this.x == null) && (this.y == null)) return true\r\n return this.z.equals(_jsbn_js__WEBPACK_IMPORTED_MODULE_0__.BigInteger.ZERO) && !this.y.toBigInteger().equals(_jsbn_js__WEBPACK_IMPORTED_MODULE_0__.BigInteger.ZERO)\r\n }\r\n\r\n /**\r\n * 取反,x 轴对称点\r\n */\r\n negate () {\r\n return new ECPointFp(this.curve, this.x, this.y.negate(), this.z)\r\n }\r\n\r\n /**\r\n * 相加\r\n *\r\n * 标准射影坐标系:\r\n *\r\n * λ1 = x1 * z2\r\n * λ2 = x2 * z1\r\n * λ3 = λ1 − λ2\r\n * λ4 = y1 * z2\r\n * λ5 = y2 * z1\r\n * λ6 = λ4 − λ5\r\n * λ7 = λ1 + λ2\r\n * λ8 = z1 * z2\r\n * λ9 = λ3^2\r\n * λ10 = λ3 * λ9\r\n * λ11 = λ8 * λ6^2 − λ7 * λ9\r\n * x3 = λ3 * λ11\r\n * y3 = λ6 * (λ9 * λ1 − λ11) − λ4 * λ10\r\n * z3 = λ10 * λ8\r\n */\r\n add (b) {\r\n if (this.isInfinity()) return b\r\n if (b.isInfinity()) return this\r\n\r\n const x1 = this.x.toBigInteger()\r\n const y1 = this.y.toBigInteger()\r\n const z1 = this.z\r\n const x2 = b.x.toBigInteger()\r\n const y2 = b.y.toBigInteger()\r\n const z2 = b.z\r\n const q = this.curve.q\r\n\r\n const w1 = x1.multiply(z2).mod(q)\r\n const w2 = x2.multiply(z1).mod(q)\r\n const w3 = w1.subtract(w2)\r\n const w4 = y1.multiply(z2).mod(q)\r\n const w5 = y2.multiply(z1).mod(q)\r\n const w6 = w4.subtract(w5)\r\n\r\n if (_jsbn_js__WEBPACK_IMPORTED_MODULE_0__.BigInteger.ZERO.equals(w3)) {\r\n if (_jsbn_js__WEBPACK_IMPORTED_MODULE_0__.BigInteger.ZERO.equals(w6)) {\r\n return this.twice() // this == b,计算自加\r\n }\r\n return this.curve.infinity // this == -b,则返回无穷远点\r\n }\r\n\r\n const w7 = w1.add(w2)\r\n const w8 = z1.multiply(z2).mod(q)\r\n const w9 = w3.square().mod(q)\r\n const w10 = w3.multiply(w9).mod(q)\r\n const w11 = w8.multiply(w6.square()).subtract(w7.multiply(w9)).mod(q)\r\n\r\n const x3 = w3.multiply(w11).mod(q)\r\n const y3 = w6.multiply(w9.multiply(w1).subtract(w11)).subtract(w4.multiply(w10)).mod(q)\r\n const z3 = w10.multiply(w8).mod(q)\r\n\r\n return new ECPointFp(this.curve, this.curve.fromBigInteger(x3), this.curve.fromBigInteger(y3), z3)\r\n }\r\n\r\n /**\r\n * 自加\r\n *\r\n * 标准射影坐标系:\r\n *\r\n * λ1 = 3 * x1^2 + a * z1^2\r\n * λ2 = 2 * y1 * z1\r\n * λ3 = y1^2\r\n * λ4 = λ3 * x1 * z1\r\n * λ5 = λ2^2\r\n * λ6 = λ1^2 − 8 * λ4\r\n * x3 = λ2 * λ6\r\n * y3 = λ1 * (4 * λ4 − λ6) − 2 * λ5 * λ3\r\n * z3 = λ2 * λ5\r\n */\r\n twice () {\r\n if (this.isInfinity()) return this\r\n if (!this.y.toBigInteger().signum()) return this.curve.infinity\r\n\r\n const x1 = this.x.toBigInteger()\r\n const y1 = this.y.toBigInteger()\r\n const z1 = this.z\r\n const q = this.curve.q\r\n const a = this.curve.a.toBigInteger()\r\n\r\n const w1 = x1.square().multiply(THREE).add(a.multiply(z1.square())).mod(q)\r\n const w2 = y1.shiftLeft(1).multiply(z1).mod(q)\r\n const w3 = y1.square().mod(q)\r\n const w4 = w3.multiply(x1).multiply(z1).mod(q)\r\n const w5 = w2.square().mod(q)\r\n const w6 = w1.square().subtract(w4.shiftLeft(3)).mod(q)\r\n\r\n const x3 = w2.multiply(w6).mod(q)\r\n const y3 = w1.multiply(w4.shiftLeft(2).subtract(w6)).subtract(w5.shiftLeft(1).multiply(w3)).mod(q)\r\n const z3 = w2.multiply(w5).mod(q)\r\n\r\n return new ECPointFp(this.curve, this.curve.fromBigInteger(x3), this.curve.fromBigInteger(y3), z3)\r\n }\r\n\r\n /**\r\n * 倍点计算\r\n */\r\n multiply (k) {\r\n if (this.isInfinity()) return this\r\n if (!k.signum()) return this.curve.infinity\r\n\r\n // 使用加减法\r\n const k3 = k.multiply(THREE)\r\n const neg = this.negate()\r\n let Q = this\r\n\r\n for (let i = k3.bitLength() - 2; i > 0; i--) {\r\n Q = Q.twice()\r\n\r\n const k3Bit = k3.testBit(i)\r\n const kBit = k.testBit(i)\r\n\r\n if (k3Bit != kBit) {\r\n Q = Q.add(k3Bit ? this : neg)\r\n }\r\n }\r\n\r\n return Q\r\n }\r\n}\r\n\r\n/**\r\n * 椭圆曲线 y^2 = x^3 + ax + b\r\n */\r\nclass ECCurveFp {\r\n constructor (q, a, b) {\r\n this.q = q\r\n this.a = this.fromBigInteger(a)\r\n this.b = this.fromBigInteger(b)\r\n this.infinity = new ECPointFp(this, null, null) // 无穷远点\r\n }\r\n\r\n /**\r\n * 判断两个椭圆曲线是否相等\r\n */\r\n equals (other) {\r\n if (other == this) return true\r\n return (this.q.equals(other.q) && this.a.equals(other.a) && this.b.equals(other.b))\r\n }\r\n\r\n /**\r\n * 生成椭圆曲线域元素\r\n */\r\n fromBigInteger (x) {\r\n return new ECFieldElementFp(this.q, x)\r\n }\r\n\r\n /**\r\n * 解析 16 进制串为椭圆曲线点\r\n */\r\n decodePointHex (s) {\r\n switch (parseInt(s.substr(0, 2), 16)) {\r\n // 第一个字节\r\n case 0:\r\n return this.infinity\r\n case 2:\r\n case 3:\r\n // 不支持的压缩方式\r\n return null\r\n case 4:\r\n case 6:\r\n case 7:\r\n const len = (s.length - 2) / 2\r\n const xHex = s.substr(2, len)\r\n const yHex = s.substr(len + 2, len)\r\n\r\n return new ECPointFp(this, this.fromBigInteger(new _jsbn_js__WEBPACK_IMPORTED_MODULE_0__.BigInteger(xHex, 16)), this.fromBigInteger(new _jsbn_js__WEBPACK_IMPORTED_MODULE_0__.BigInteger(yHex, 16)))\r\n default:\r\n // 不支持\r\n return null\r\n }\r\n }\r\n}\r\n\r\n\r\n\n\n//# sourceURL=webpack://SM/./src/sm2/ec.js?");
/***/ }),
/***/ "./src/sm2/index.js":
/*!**************************!*\
!*** ./src/sm2/index.js ***!
\**************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var _jsbn_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./jsbn.js */ \"./src/sm2/jsbn.js\");\n/* harmony import */ var _asn1__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./asn1 */ \"./src/sm2/asn1.js\");\n/* harmony import */ var _sm2__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./sm2 */ \"./src/sm2/sm2.js\");\n/* harmony import */ var _sm3__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./sm3 */ \"./src/sm2/sm3.js\");\n/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./utils */ \"./src/sm2/utils.js\");\n/* eslint-disable eqeqeq */\r\n\r\n\r\n\r\n\r\n\r\n\r\nconst { G, curve, n } = _utils__WEBPACK_IMPORTED_MODULE_4__[\"default\"].generateEcparam()\r\nconst C1C2C3 = 0\r\n\r\n/**\r\n * 加密\r\n */\r\nfunction doEncrypt (msg, publicKey, cipherMode = 1) {\r\n const cipher = new _sm2__WEBPACK_IMPORTED_MODULE_2__[\"default\"]()\r\n msg = _utils__WEBPACK_IMPORTED_MODULE_4__[\"default\"].hexToArray(_utils__WEBPACK_IMPORTED_MODULE_4__[\"default\"].parseUtf8StringToHex(msg))\r\n\r\n if (publicKey.length > 128) {\r\n publicKey = publicKey.substr(publicKey.length - 128)\r\n }\r\n const xHex = publicKey.substr(0, 64)\r\n const yHex = publicKey.substr(64)\r\n publicKey = cipher.createPoint(xHex, yHex)\r\n\r\n const c1 = cipher.initEncipher(publicKey)\r\n\r\n cipher.encryptBlock(msg)\r\n const c2 = _utils__WEBPACK_IMPORTED_MODULE_4__[\"default\"].arrayToHex(msg)\r\n\r\n let c3 = new Array(32)\r\n cipher.doFinal(c3)\r\n c3 = _utils__WEBPACK_IMPORTED_MODULE_4__[\"default\"].arrayToHex(c3)\r\n\r\n return cipherMode == C1C2C3 ? c1 + c2 + c3 : c1 + c3 + c2\r\n}\r\n\r\n/**\r\n * 解密\r\n */\r\nfunction doDecrypt (encryptData, privateKey, cipherMode = 1) {\r\n const cipher = new _sm2__WEBPACK_IMPORTED_MODULE_2__[\"default\"]()\r\n\r\n privateKey = new _jsbn_js__WEBPACK_IMPORTED_MODULE_0__.BigInteger(privateKey, 16)\r\n\r\n const c1X = encryptData.substr(0, 64)\r\n const c1Y = encryptData.substr(0 + c1X.length, 64)\r\n const c1Length = c1X.length + c1Y.length\r\n\r\n let c3 = encryptData.substr(c1Length, 64)\r\n let c2 = encryptData.substr(c1Length + 64)\r\n\r\n if (cipherMode == C1C2C3) {\r\n c3 = encryptData.substr(encryptData.length - 64)\r\n c2 = encryptData.substr(c1Length, encryptData.length - c1Length - 64)\r\n }\r\n\r\n const data = _utils__WEBPACK_IMPORTED_MODULE_4__[\"default\"].hexToArray(c2)\r\n\r\n const c1 = cipher.createPoint(c1X, c1Y)\r\n cipher.initDecipher(privateKey, c1)\r\n cipher.decryptBlock(data)\r\n const c3_ = new Array(32)\r\n cipher.doFinal(c3_)\r\n\r\n const isDecrypt = _utils__WEBPACK_IMPORTED_MODULE_4__[\"default\"].arrayToHex(c3_) == c3\r\n\r\n if (isDecrypt) {\r\n const decryptData = _utils__WEBPACK_IMPORTED_MODULE_4__[\"default\"].arrayToUtf8(data)\r\n return decryptData\r\n } else {\r\n return ''\r\n }\r\n}\r\n\r\n/**\r\n * 签名\r\n */\r\nfunction doSignature (msg, privateKey, { pointPool, der, hash, publicKey } = {}) {\r\n let hashHex = typeof msg === 'string' ? _utils__WEBPACK_IMPORTED_MODULE_4__[\"default\"].parseUtf8StringToHex(msg) : _utils__WEBPACK_IMPORTED_MODULE_4__[\"default\"].parseArrayBufferToHex(msg)\r\n\r\n if (hash) {\r\n // sm3杂凑\r\n publicKey = publicKey || getPublicKeyFromPrivateKey(privateKey)\r\n hashHex = doSm3Hash(hashHex, publicKey)\r\n }\r\n\r\n const dA = new _jsbn_js__WEBPACK_IMPORTED_MODULE_0__.BigInteger(privateKey, 16)\r\n const e = new _jsbn_js__WEBPACK_IMPORTED_MODULE_0__.BigInteger(hashHex, 16)\r\n\r\n // k\r\n let k = null\r\n let r = null\r\n let s = null\r\n\r\n do {\r\n do {\r\n let point\r\n if (pointPool && pointPool.length) {\r\n point = pointPool.pop()\r\n } else {\r\n point = getPoint()\r\n }\r\n k = point.k\r\n\r\n // r = (e + x1) mod n\r\n r = e.add(point.x1).mod(n)\r\n } while (r.equals(_jsbn_js__WEBPACK_IMPORTED_MODULE_0__.BigInteger.ZERO) || r.add(k).equals(n))\r\n\r\n // s = ((1 + dA)^-1 * (k - r * dA)) mod n\r\n s = dA.add(_jsbn_js__WEBPACK_IMPORTED_MODULE_0__.BigInteger.ONE).modInverse(n).multiply(k.subtract(r.multiply(dA))).mod(n)\r\n } while (s.equals(_jsbn_js__WEBPACK_IMPORTED_MODULE_0__.BigInteger.ZERO))\r\n\r\n if (der) {\r\n // asn1 der编码\r\n return (0,_asn1__WEBPACK_IMPORTED_MODULE_1__.encodeDer)(r, s)\r\n }\r\n\r\n return _utils__WEBPACK_IMPORTED_MODULE_4__[\"default\"].leftPad(r.toString(16), 64) + _utils__WEBPACK_IMPORTED_MODULE_4__[\"default\"].leftPad(s.toString(16), 64)\r\n}\r\n\r\n/**\r\n * 验签\r\n */\r\nfunction doVerifySignature (msg, signHex, publicKey, { der, hash } = {}) {\r\n let hashHex = typeof msg === 'string' ? _utils__WEBPACK_IMPORTED_MODULE_4__[\"default\"].parseUtf8StringToHex(msg) : _utils__WEBPACK_IMPORTED_MODULE_4__[\"default\"].parseArrayBufferToHex(msg)\r\n\r\n if (hash) {\r\n // sm3杂凑\r\n hashHex = doSm3Hash(hashHex, publicKey)\r\n }\r\n\r\n let r, s\r\n if (der) {\r\n const decodeDerObj = (0,_asn1__WEBPACK_IMPORTED_MODULE_1__.decodeDer)(signHex)\r\n r = decodeDerObj.r\r\n s = decodeDerObj.s\r\n } else {\r\n r = new _jsbn_js__WEBPACK_IMPORTED_MODULE_0__.BigInteger(signHex.substring(0, 64), 16)\r\n s = new _jsbn_js__WEBPACK_IMPORTED_MODULE_0__.BigInteger(signHex.substring(64), 16)\r\n }\r\n\r\n const PA = curve.decodePointHex(publicKey)\r\n const e = new _jsbn_js__WEBPACK_IMPORTED_MODULE_0__.BigInteger(hashHex, 16)\r\n\r\n // t = (r + s) mod n\r\n const t = r.add(s).mod(n)\r\n\r\n if (t.equals(_jsbn_js__WEBPACK_IMPORTED_MODULE_0__.BigInteger.ZERO)) return false\r\n\r\n // x1y1 = s * G + t * PA\r\n const x1y1 = G.multiply(s).add(PA.multiply(t))\r\n\r\n // R = (e + x1) mod n\r\n const R = e.add(x1y1.getX().toBigInteger()).mod(n)\r\n\r\n return r.equals(R)\r\n}\r\n\r\n/**\r\n * sm3杂凑算法\r\n */\r\nfunction doSm3Hash (hashHex, publicKey) {\r\n const smDigest = new _sm3__WEBPACK_IMPORTED_MODULE_3__[\"default\"]()\r\n\r\n const z = new _sm3__WEBPACK_IMPORTED_MODULE_3__[\"default\"]().getZ(G, publicKey.substr(2, 128))\r\n const zValue = _utils__WEBPACK_IMPORTED_MODULE_4__[\"default\"].hexToArray(_utils__WEBPACK_IMPORTED_MODULE_4__[\"default\"].arrayToHex(z).toString())\r\n\r\n const p = hashHex\r\n const pValue = _utils__WEBPACK_IMPORTED_MODULE_4__[\"default\"].hexToArray(p)\r\n\r\n const hashData = new Array(smDigest.getDigestSize())\r\n smDigest.blockUpdate(zValue, 0, zValue.length)\r\n smDigest.blockUpdate(pValue, 0, pValue.length)\r\n smDigest.doFinal(hashData, 0)\r\n\r\n return _utils__WEBPACK_IMPORTED_MODULE_4__[\"default\"].arrayToHex(hashData).toString()\r\n}\r\n\r\n/**\r\n * 计算公钥\r\n */\r\nfunction getPublicKeyFromPrivateKey (privateKey) {\r\n const PA = G.multiply(new _jsbn_js__WEBPACK_IMPORTED_MODULE_0__.BigInteger(privateKey, 16))\r\n const x = _utils__WEBPACK_IMPORTED_MODULE_4__[\"default\"].leftPad(PA.getX().toBigInteger().toString(16), 64)\r\n const y = _utils__WEBPACK_IMPORTED_MODULE_4__[\"default\"].leftPad(PA.getY().toBigInteger().toString(16), 64)\r\n return '04' + x + y\r\n}\r\n\r\n/**\r\n * 获取椭圆曲线点\r\n */\r\nfunction getPoint () {\r\n const keypair = _utils__WEBPACK_IMPORTED_MODULE_4__[\"default\"].generateKeyPairHex()\r\n const PA = curve.decodePointHex(keypair.publicKey)\r\n\r\n keypair.k = new _jsbn_js__WEBPACK_IMPORTED_MODULE_0__.BigInteger(keypair.privateKey, 16)\r\n keypair.x1 = PA.getX().toBigInteger()\r\n\r\n return keypair\r\n};\r\n\r\nconst generateKeyPairHex = _utils__WEBPACK_IMPORTED_MODULE_4__[\"default\"].generateKeyPairHex\r\n\r\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({\r\n generateKeyPairHex,\r\n doEncrypt,\r\n doDecrypt,\r\n doSignature,\r\n doVerifySignature,\r\n getPoint\r\n});\r\n\n\n//# sourceURL=webpack://SM/./src/sm2/index.js?");
/***/ }),
/***/ "./src/sm2/jsbn.js":
/*!*************************!*\
!*** ./src/sm2/jsbn.js ***!
\*************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"BigInteger\": () => (/* binding */ BigInteger),\n/* harmony export */ \"SecureRandom\": () => (/* binding */ SecureRandom),\n/* harmony export */ \"default\": () => (/* binding */ BigInteger)\n/* harmony export */ });\n/* eslint-disable eqeqeq */\r\n/* eslint-disable camelcase */\r\n// Copyright (c) 2005 Tom Wu\r\n// All Rights Reserved.\r\n// See \"LICENSE\" for details.\r\n\r\n// Basic JavaScript BN library - subset useful for RSA encryption.\r\n\r\n// Bits per digit\r\nvar dbits\r\n\r\n// JavaScript engine analysis\r\nvar canary = 0xdeadbeefcafe\r\nvar j_lm = ((canary & 0xffffff) == 0xefcafe)\r\n\r\n// (public) Constructor\r\nfunction BigInteger (a, b, c) {\r\n if (a != null) {\r\n if (typeof a === 'number') this.fromNumber(a, b, c)\r\n else if (b == null && typeof a !== 'string') this.fromString(a, 256)\r\n else this.fromString(a, b)\r\n }\r\n}\r\n\r\n// return new, unset BigInteger\r\nfunction nbi () { return new BigInteger(null) }\r\n\r\n// am: Compute w_j += (x*this_i), propagate carries,\r\n// c is initial carry, returns final carry.\r\n// c < 3*dvalue, x < 2*dvalue, this_i < dvalue\r\n// We need to select the fastest one that works in this environment.\r\n\r\n// am1: use a single mult and divide to get the high bits,\r\n// max digit bits should be 26 because\r\n// max internal value = 2*dvalue^2-2*dvalue (< 2^53)\r\nfunction am1 (i, x, w, j, c, n) {\r\n while (--n >= 0) {\r\n var v = x * this[i++] + w[j] + c\r\n c = Math.floor(v / 0x4000000)\r\n w[j++] = v & 0x3ffffff\r\n }\r\n return c\r\n}\r\n// am2 avoids a big mult-and-extract completely.\r\n// Max digit bits should be <= 30 because we do bitwise ops\r\n// on values up to 2*hdvalue^2-hdvalue-1 (< 2^31)\r\nfunction am2 (i, x, w, j, c, n) {\r\n var xl = x & 0x7fff; var xh = x >> 15\r\n while (--n >= 0) {\r\n var l = this[i] & 0x7fff\r\n var h = this[i++] >> 15\r\n var m = xh * l + h * xl\r\n l = xl * l + ((m & 0x7fff) << 15) + w[j] + (c & 0x3fffffff)\r\n c = (l >>> 30) + (m >>> 15) + xh * h + (c >>> 30)\r\n w[j++] = l & 0x3fffffff\r\n }\r\n return c\r\n}\r\n// Alternately, set max digit bits to 28 since some\r\n// browsers slow down when dealing with 32-bit numbers.\r\nfunction am3 (i, x, w, j, c, n) {\r\n var xl = x & 0x3fff; var xh = x >> 14\r\n while (--n >= 0) {\r\n var l = this[i] & 0x3fff\r\n var h = this[i++] >> 14\r\n var m = xh * l + h * xl\r\n l = xl * l + ((m & 0x3fff) << 14) + w[j] + c\r\n c = (l >> 28) + (m >> 14) + xh * h\r\n w[j++] = l & 0xfffffff\r\n }\r\n return c\r\n}\r\nvar inBrowser = typeof navigator !== 'undefined'\r\nif (inBrowser && j_lm && (navigator.appName == 'Microsoft Internet Explorer')) {\r\n BigInteger.prototype.am = am2\r\n dbits = 30\r\n} else if (inBrowser && j_lm && (navigator.appName != 'Netscape')) {\r\n BigInteger.prototype.am = am1\r\n dbits = 26\r\n} else { // Mozilla/Netscape seems to prefer am3\r\n BigInteger.prototype.am = am3\r\n dbits = 28\r\n}\r\n\r\nBigInteger.prototype.DB = dbits\r\nBigInteger.prototype.DM = ((1 << dbits) - 1)\r\nBigInteger.prototype.DV = (1 << dbits)\r\n\r\nvar BI_FP = 52\r\nBigInteger.prototype.FV = Math.pow(2, BI_FP)\r\nBigInteger.prototype.F1 = BI_FP - dbits\r\nBigInteger.prototype.F2 = 2 * dbits - BI_FP\r\n\r\n// Digit conversions\r\nvar BI_RM = '0123456789abcdefghijklmnopqrstuvwxyz'\r\nvar BI_RC = []\r\nvar rr, vv\r\nrr = '0'.charCodeAt(0)\r\nfor (vv = 0; vv <= 9; ++vv) BI_RC[rr++] = vv\r\nrr = 'a'.charCodeAt(0)\r\nfor (vv = 10; vv < 36; ++vv) BI_RC[rr++] = vv\r\nrr = 'A'.charCodeAt(0)\r\nfor (vv = 10; vv < 36; ++vv) BI_RC[rr++] = vv\r\n\r\nfunction int2char (n) { return BI_RM.charAt(n) }\r\nfunction intAt (s, i) {\r\n var c = BI_RC[s.charCodeAt(i)]\r\n return (c == null) ? -1 : c\r\n}\r\n\r\n// (protected) copy this to r\r\nfunction bnpCopyTo (r) {\r\n for (var i = this.t - 1; i >= 0; --i) r[i] = this[i]\r\n r.t = this.t\r\n r.s = this.s\r\n}\r\n\r\n// (protected) set from integer value x, -DV <= x < DV\r\nfunction bnpFromInt (x) {\r\n this.t = 1\r\n this.s = (x < 0) ? -1 : 0\r\n if (x > 0) this[0] = x\r\n else if (x < -1) this[0] = x + this.DV\r\n else this.t = 0\r\n}\r\n\r\n// return bigint initialized to value\r\nfunction nbv (i) { var r = nbi(); r.fromInt(i); return r }\r\n\r\n// (protected) set from string and radix\r\nfunction bnpFromString (s, b) {\r\n var k\r\n if (b == 16) k = 4\r\n else if (b == 8) k = 3\r\n else if (b == 256) k = 8 // byte array\r\n else if (b == 2) k = 1\r\n else if (b == 32) k = 5\r\n else if (b == 4) k = 2\r\n else { this.fromRadix(s, b); return }\r\n this.t = 0\r\n this.s = 0\r\n var i = s.length; var mi = false; var sh = 0\r\n while (--i >= 0) {\r\n var x = (k == 8) ? s[i] & 0xff : intAt(s, i)\r\n if (x < 0) {\r\n if (s.charAt(i) == '-') mi = true\r\n continue\r\n }\r\n mi = false\r\n if (sh == 0) { this[this.t++] = x } else if (sh + k > this.DB) {\r\n this[this.t - 1] |= (x & ((1 << (this.DB - sh)) - 1)) << sh\r\n this[this.t++] = (x >> (this.DB - sh))\r\n } else { this[this.t - 1] |= x << sh }\r\n sh += k\r\n if (sh >= this.DB) sh -= this.DB\r\n }\r\n if (k == 8 && (s[0] & 0x80) != 0) {\r\n this.s = -1\r\n if (sh > 0) this[this.t - 1] |= ((1 << (this.DB - sh)) - 1) << sh\r\n }\r\n this.clamp()\r\n if (mi) BigInteger.ZERO.subTo(this, this)\r\n}\r\n\r\n// (protected) clamp off excess high words\r\nfunction bnpClamp () {\r\n var c = this.s & this.DM\r\n while (this.t > 0 && this[this.t - 1] == c) --this.t\r\n}\r\n\r\n// (public) return string representation in given radix\r\nfunction bnToString (b) {\r\n if (this.s < 0) return '-' + this.negate().toString(b)\r\n var k\r\n if (b == 16) k = 4\r\n else if (b == 8) k = 3\r\n else if (b == 2) k = 1\r\n else if (b == 32) k = 5\r\n else if (b == 4) k = 2\r\n else return this.toRadix(b)\r\n var km = (1 << k) - 1; var d; var m = false; var r = ''; var i = this.t\r\n var p = this.DB - (i * this.DB) % k\r\n if (i-- > 0) {\r\n if (p < this.DB && (d = this[i] >> p) > 0) { m = true; r = int2char(d) }\r\n while (i >= 0) {\r\n if (p < k) {\r\n d = (this[i] & ((1 << p) - 1)) << (k - p)\r\n d |= this[--i] >> (p += this.DB - k)\r\n } else {\r\n d = (this[i] >> (p -= k)) & km\r\n if (p <= 0) { p += this.DB; --i }\r\n }\r\n if (d > 0) m = true\r\n if (m) r += int2char(d)\r\n }\r\n }\r\n return m ? r : '0'\r\n}\r\n\r\n// (public) -this\r\nfunction bnNegate () { var r = nbi(); BigInteger.ZERO.subTo(this, r); return r }\r\n\r\n// (public) |this|\r\nfunction bnAbs () { return (this.s < 0) ? this.negate() : this }\r\n\r\n// (public) return + if this > a, - if this < a, 0 if equal\r\nfunction bnCompareTo (a) {\r\n var r = this.s - a.s\r\n if (r != 0) return r\r\n var i = this.t\r\n r = i - a.t\r\n if (r != 0) return (this.s < 0) ? -r : r\r\n while (--i >= 0) if ((r = this[i] - a[i]) != 0) return r\r\n return 0\r\n}\r\n\r\n// returns bit length of the integer x\r\nfunction nbits (x) {\r\n var r = 1; var t\r\n if ((t = x >>> 16) != 0) { x = t; r += 16 }\r\n if ((t = x >> 8) != 0) { x = t; r += 8 }\r\n if ((t = x >> 4) != 0) { x = t; r += 4 }\r\n if ((t = x >> 2) != 0) { x = t; r += 2 }\r\n if ((t = x >> 1) != 0) { x = t; r += 1 }\r\n return r\r\n}\r\n\r\n// (public) return the number of bits in \"this\"\r\nfunction bnBitLength () {\r\n if (this.t <= 0) return 0\r\n return this.DB * (this.t - 1) + nbits(this[this.t - 1] ^ (this.s & this.DM))\r\n}\r\n\r\n// (protected) r = this << n*DB\r\nfunction bnpDLShiftTo (n, r) {\r\n var i\r\n for (i = this.t - 1; i >= 0; --i) r[i + n] = this[i]\r\n for (i = n - 1; i >= 0; --i) r[i] = 0\r\n r.t = this.t + n\r\n r.s = this.s\r\n}\r\n\r\n// (protected) r = this >> n*DB\r\nfunction bnpDRShiftTo (n, r) {\r\n for (var i = n; i < this.t; ++i) r[i - n] = this[i]\r\n r.t = Math.max(this.t - n, 0)\r\n r.s = this.s\r\n}\r\n\r\n// (protected) r = this << n\r\nfunction bnpLShiftTo (n, r) {\r\n var bs = n % this.DB\r\n var cbs = this.DB - bs\r\n var bm = (1 << cbs) - 1\r\n var ds = Math.floor(n / this.DB); var c = (this.s << bs) & this.DM; var i\r\n for (i = this.t - 1; i >= 0; --i) {\r\n r[i + ds + 1] = (this[i] >> cbs) | c\r\n c = (this[i] & bm) << bs\r\n }\r\n for (i = ds - 1; i >= 0; --i) r[i] = 0\r\n r[ds] = c\r\n r.t = this.t + ds + 1\r\n r.s = this.s\r\n r.clamp()\r\n}\r\n\r\n// (protected) r = this >> n\r\nfunction bnpRShiftTo (n, r) {\r\n r.s = this.s\r\n var ds = Math.floor(n / this.DB)\r\n if (ds >= this.t) { r.t = 0; return }\r\n var bs = n % this.DB\r\n var cbs = this.DB - bs\r\n var bm = (1 << bs) - 1\r\n r[0] = this[ds] >> bs\r\n for (var i = ds + 1; i < this.t; ++i) {\r\n r[i - ds - 1] |= (this[i] & bm) << cbs\r\n r[i - ds] = this[i] >> bs\r\n }\r\n if (bs > 0) r[this.t - ds - 1] |= (this.s & bm) << cbs\r\n r.t = this.t - ds\r\n r.clamp()\r\n}\r\n\r\n// (protected) r = this - a\r\nfunction bnpSubTo (a, r) {\r\n var i = 0; var c = 0; var m = Math.min(a.t, this.t)\r\n while (i < m) {\r\n c += this[i] - a[i]\r\n r[i++] = c & this.DM\r\n c >>= this.DB\r\n }\r\n if (a.t < this.t) {\r\n c -= a.s\r\n while (i < this.t) {\r\n c += this[i]\r\n r[i++] = c & this.DM\r\n c >>= this.DB\r\n }\r\n c += this.s\r\n } else {\r\n c += this.s\r\n while (i < a.t) {\r\n c -= a[i]\r\n r[i++] = c & this.DM\r\n c >>= this.DB\r\n }\r\n c -= a.s\r\n }\r\n r.s = (c < 0) ? -1 : 0\r\n if (c < -1) r[i++] = this.DV + c\r\n else if (c > 0) r[i++] = c\r\n r.t = i\r\n r.clamp()\r\n}\r\n\r\n// (protected) r = this * a, r != this,a (HAC 14.12)\r\n// \"this\" should be the larger one if appropriate.\r\nfunction bnpMultiplyTo (a, r) {\r\n var x = this.abs(); var y = a.abs()\r\n var i = x.t\r\n r.t = i + y.t\r\n while (--i >= 0) r[i] = 0\r\n for (i = 0; i < y.t; ++i) r[i + x.t] = x.am(0, y[i], r, i, 0, x.t)\r\n r.s = 0\r\n r.clamp()\r\n if (this.s != a.s) BigInteger.ZERO.subTo(r, r)\r\n}\r\n\r\n// (protected) r = this^2, r != this (HAC 14.16)\r\nfunction bnpSquareTo (r) {\r\n var x = this.abs()\r\n var i = r.t = 2 * x.t\r\n while (--i >= 0) r[i] = 0\r\n for (i = 0; i < x.t - 1; ++i) {\r\n var c = x.am(i, x[i], r, 2 * i, 0, 1)\r\n if ((r[i + x.t] += x.am(i + 1, 2 * x[i], r, 2 * i + 1, c, x.t - i - 1)) >= x.DV) {\r\n r[i + x.t] -= x.DV\r\n r[i + x.t + 1] = 1\r\n }\r\n }\r\n if (r.t > 0) r[r.t - 1] += x.am(i, x[i], r, 2 * i, 0, 1)\r\n r.s = 0\r\n r.clamp()\r\n}\r\n\r\n// (protected) divide this by m, quotient and remainder to q, r (HAC 14.20)\r\n// r != q, this != m. q or r may be null.\r\nfunction bnpDivRemTo (m, q, r) {\r\n var pm = m.abs()\r\n if (pm.t <= 0) return\r\n var pt = this.abs()\r\n if (pt.t < pm.t) {\r\n if (q != null) q.fromInt(0)\r\n if (r != null) this.copyTo(r)\r\n return\r\n }\r\n if (r == null) r = nbi()\r\n var y = nbi(); var ts = this.s; var ms = m.s\r\n var nsh = this.DB - nbits(pm[pm.t - 1]) // normalize modulus\r\n if (nsh > 0) { pm.lShiftTo(nsh, y); pt.lShiftTo(nsh, r) } else { pm.copyTo(y); pt.copyTo(r) }\r\n var ys = y.t\r\n var y0 = y[ys - 1]\r\n if (y0 == 0) return\r\n var yt = y0 * (1 << this.F1) + ((ys > 1) ? y[ys - 2] >> this.F2 : 0)\r\n var d1 = this.FV / yt; var d2 = (1 << this.F1) / yt; var e = 1 << this.F2\r\n var i = r.t; var j = i - ys; var t = (q == null) ? nbi() : q\r\n y.dlShiftTo(j, t)\r\n if (r.compareTo(t) >= 0) {\r\n r[r.t++] = 1\r\n r.subTo(t, r)\r\n }\r\n BigInteger.ONE.dlShiftTo(ys, t)\r\n t.subTo(y, y) // \"negative\" y so we can replace sub with am later\r\n while (y.t < ys) y[y.t++] = 0\r\n while (--j >= 0) {\r\n // Estimate quotient digit\r\n var qd = (r[--i] == y0) ? this.DM : Math.floor(r[i] * d1 + (r[i - 1] + e) * d2)\r\n if ((r[i] += y.am(0, qd, r, j, 0, ys)) < qd) { // Try it out\r\n y.dlShiftTo(j, t)\r\n r.subTo(t, r)\r\n while (r[i] < --qd) r.subTo(t, r)\r\n }\r\n }\r\n if (q != null) {\r\n r.drShiftTo(ys, q)\r\n if (ts != ms) BigInteger.ZERO.subTo(q, q)\r\n }\r\n r.t = ys\r\n r.clamp()\r\n if (nsh > 0) r.rShiftTo(nsh, r) // Denormalize remainder\r\n if (ts < 0) BigInteger.ZERO.subTo(r, r)\r\n}\r\n\r\n// (public) this mod a\r\nfunction bnMod (a) {\r\n var r = nbi()\r\n this.abs().divRemTo(a, null, r)\r\n if (this.s < 0 && r.compareTo(BigInteger.ZERO) > 0) a.subTo(r, r)\r\n return r\r\n}\r\n\r\n// Modular reduction using \"classic\" algorithm\r\nfunction Classic (m) { this.m = m }\r\nfunction cConvert (x) {\r\n if (x.s < 0 || x.compareTo(this.m) >= 0) return x.mod(this.m)\r\n else return x\r\n}\r\nfunction cRevert (x) { return x }\r\nfunction cReduce (x) { x.divRemTo(this.m, null, x) }\r\nfunction cMulTo (x, y, r) { x.multiplyTo(y, r); this.reduce(r) }\r\nfunction cSqrTo (x, r) { x.squareTo(r); this.reduce(r) }\r\n\r\nClassic.prototype.convert = cConvert\r\nClassic.prototype.revert = cRevert\r\nClassic.prototype.reduce = cReduce\r\nClassic.prototype.mulTo = cMulTo\r\nClassic.prototype.sqrTo = cSqrTo\r\n\r\n// (protected) return \"-1/this % 2^DB\"; useful for Mont. reduction\r\n// justification:\r\n// xy == 1 (mod m)\r\n// xy = 1+km\r\n// xy(2-xy) = (1+km)(1-km)\r\n// x[y(2-xy)] = 1-k^2m^2\r\n// x[y(2-xy)] == 1 (mod m^2)\r\n// if y is 1/x mod m, then y(2-xy) is 1/x mod m^2\r\n// should reduce x and y(2-xy) by m^2 at each step to keep size bounded.\r\n// JS multiply \"overflows\" differently from C/C++, so care is needed here.\r\nfunction bnpInvDigit () {\r\n if (this.t < 1) return 0\r\n var x = this[0]\r\n if ((x & 1) == 0) return 0\r\n var y = x & 3 // y == 1/x mod 2^2\r\n y = (y * (2 - (x & 0xf) * y)) & 0xf // y == 1/x mod 2^4\r\n y = (y * (2 - (x & 0xff) * y)) & 0xff // y == 1/x mod 2^8\r\n y = (y * (2 - (((x & 0xffff) * y) & 0xffff))) & 0xffff // y == 1/x mod 2^16\r\n // last step - calculate inverse mod DV directly;\r\n // assumes 16 < DB <= 32 and assumes ability to handle 48-bit ints\r\n y = (y * (2 - x * y % this.DV)) % this.DV // y == 1/x mod 2^dbits\r\n // we really want the negative inverse, and -DV < y < DV\r\n return (y > 0) ? this.DV - y : -y\r\n}\r\n\r\n// Montgomery reduction\r\nfunction Montgomery (m) {\r\n this.m = m\r\n this.mp = m.invDigit()\r\n this.mpl = this.mp & 0x7fff\r\n this.mph = this.mp >> 15\r\n this.um = (1 << (m.DB - 15)) - 1\r\n this.mt2 = 2 * m.t\r\n}\r\n\r\n// xR mod m\r\nfunction montConvert (x) {\r\n var r = nbi()\r\n x.abs().dlShiftTo(this.m.t, r)\r\n r.divRemTo(this.m, null, r)\r\n if (x.s < 0 && r.compareTo(BigInteger.ZERO) > 0) this.m.subTo(r, r)\r\n return r\r\n}\r\n\r\n// x/R mod m\r\nfunction montRevert (x) {\r\n var r = nbi()\r\n x.copyTo(r)\r\n this.reduce(r)\r\n return r\r\n}\r\n\r\n// x = x/R mod m (HAC 14.32)\r\nfunction montReduce (x) {\r\n while (x.t <= this.mt2) { // pad x so am has enough room later\r\n x[x.t++] = 0\r\n }\r\n for (var i = 0; i < this.m.t; ++i) {\r\n // faster way of calculating u0 = x[i]*mp mod DV\r\n var j = x[i] & 0x7fff\r\n var u0 = (j * this.mpl + (((j * this.mph + (x[i] >> 15) * this.mpl) & this.um) << 15)) & x.DM\r\n // use am to combine the multiply-shift-add into one call\r\n j = i + this.m.t\r\n x[j] += this.m.am(0, u0, x, i, 0, this.m.t)\r\n // propagate carry\r\n while (x[j] >= x.DV) { x[j] -= x.DV; x[++j]++ }\r\n }\r\n x.clamp()\r\n x.drShiftTo(this.m.t, x)\r\n if (x.compareTo(this.m) >= 0) x.subTo(this.m, x)\r\n}\r\n\r\n// r = \"x^2/R mod m\"; x != r\r\nfunction montSqrTo (x, r) { x.squareTo(r); this.reduce(r) }\r\n\r\n// r = \"xy/R mod m\"; x,y != r\r\nfunction montMulTo (x, y, r) { x.multiplyTo(y, r); this.reduce(r) }\r\n\r\nMontgomery.prototype.convert = montConvert\r\nMontgomery.prototype.revert = montRevert\r\nMontgomery.prototype.reduce = montReduce\r\nMontgomery.prototype.mulTo = montMulTo\r\nMontgomery.prototype.sqrTo = montSqrTo\r\n\r\n// (protected) true iff this is even\r\nfunction bnpIsEven () { return ((this.t > 0) ? (this[0] & 1) : this.s) == 0 }\r\n\r\n// (protected) this^e, e < 2^32, doing sqr and mul with \"r\" (HAC 14.79)\r\nfunction bnpExp (e, z) {\r\n if (e > 0xffffffff || e < 1) return BigInteger.ONE\r\n var r = nbi(); var r2 = nbi(); var g = z.convert(this); var i = nbits(e) - 1\r\n g.copyTo(r)\r\n while (--i >= 0) {\r\n z.sqrTo(r, r2)\r\n if ((e & (1 << i)) > 0) z.mulTo(r2, g, r)\r\n else { var t = r; r = r2; r2 = t }\r\n }\r\n return z.revert(r)\r\n}\r\n\r\n// (public) this^e % m, 0 <= e < 2^32\r\nfunction bnModPowInt (e, m) {\r\n var z\r\n if (e < 256 || m.isEven()) z = new Classic(m); else z = new Montgomery(m)\r\n return this.exp(e, z)\r\n}\r\n\r\n// protected\r\nBigInteger.prototype.copyTo = bnpCopyTo\r\nBigInteger.prototype.fromInt = bnpFromInt\r\nBigInteger.prototype.fromString = bnpFromString\r\nBigInteger.prototype.clamp = bnpClamp\r\nBigInteger.prototype.dlShiftTo = bnpDLShiftTo\r\nBigInteger.prototype.drShiftTo = bnpDRShiftTo\r\nBigInteger.prototype.lShiftTo = bnpLShiftTo\r\nBigInteger.prototype.rShiftTo = bnpRShiftTo\r\nBigInteger.prototype.subTo = bnpSubTo\r\nBigInteger.prototype.multiplyTo = bnpMultiplyTo\r\nBigInteger.prototype.squareTo = bnpSquareTo\r\nBigInteger.prototype.divRemTo = bnpDivRemTo\r\nBigInteger.prototype.invDigit = bnpInvDigit\r\nBigInteger.prototype.isEven = bnpIsEven\r\nBigInteger.prototype.exp = bnpExp\r\n\r\n// public\r\nBigInteger.prototype.toString = bnToString\r\nBigInteger.prototype.negate = bnNegate\r\nBigInteger.prototype.abs = bnAbs\r\nBigInteger.prototype.compareTo = bnCompareTo\r\nBigInteger.prototype.bitLength = bnBitLength\r\nBigInteger.prototype.mod = bnMod\r\nBigInteger.prototype.modPowInt = bnModPowInt\r\n\r\n// \"constants\"\r\nBigInteger.ZERO = nbv(0)\r\nBigInteger.ONE = nbv(1)\r\n\r\n// Copyright (c) 2005-2009 Tom Wu\r\n// All Rights Reserved.\r\n// See \"LICENSE\" for details.\r\n\r\n// Extended JavaScript BN functions, required for RSA private ops.\r\n\r\n// Version 1.1: new BigInteger(\"0\", 10) returns \"proper\" zero\r\n// Version 1.2: square() API, isProbablePrime fix\r\n\r\n// (public)\r\nfunction bnClone () { var r = nbi(); this.copyTo(r); return r }\r\n\r\n// (public) return value as integer\r\nfunction bnIntValue () {\r\n if (this.s < 0) {\r\n if (this.t == 1) return this[0] - this.DV\r\n else if (this.t == 0) return -1\r\n } else if (this.t == 1) return this[0]\r\n else if (this.t == 0) return 0\r\n // assumes 16 < DB < 32\r\n return ((this[1] & ((1 << (32 - this.DB)) - 1)) << this.DB) | this[0]\r\n}\r\n\r\n// (public) return value as byte\r\nfunction bnByteValue () { return (this.t == 0) ? this.s : (this[0] << 24) >> 24 }\r\n\r\n// (public) return value as short (assumes DB>=16)\r\nfunction bnShortValue () { return (this.t == 0) ? this.s : (this[0] << 16) >> 16 }\r\n\r\n// (protected) return x s.t. r^x < DV\r\nfunction bnpChunkSize (r) { return Math.floor(Math.LN2 * this.DB / Math.log(r)) }\r\n\r\n// (public) 0 if this == 0, 1 if this > 0\r\nfunction bnSigNum () {\r\n if (this.s < 0) return -1\r\n else if (this.t <= 0 || (this.t == 1 && this[0] <= 0)) return 0\r\n else return 1\r\n}\r\n\r\n// (protected) convert to radix string\r\nfunction bnpToRadix (b) {\r\n if (b == null) b = 10\r\n if (this.signum() == 0 || b < 2 || b > 36) return '0'\r\n var cs = this.chunkSize(b)\r\n var a = Math.pow(b, cs)\r\n var d = nbv(a); var y = nbi(); var z = nbi(); var r = ''\r\n this.divRemTo(d, y, z)\r\n while (y.signum() > 0) {\r\n r = (a + z.intValue()).toString(b).substr(1) + r\r\n y.divRemTo(d, y, z)\r\n }\r\n return z.intValue().toString(b) + r\r\n}\r\n\r\n// (protected) convert from radix string\r\nfunction bnpFromRadix (s, b) {\r\n this.fromInt(0)\r\n if (b == null) b = 10\r\n var cs = this.chunkSize(b)\r\n var d = Math.pow(b, cs); var mi = false; var j = 0; var w = 0\r\n for (var i = 0; i < s.length; ++i) {\r\n var x = intAt(s, i)\r\n if (x < 0) {\r\n if (s.charAt(i) == '-' && this.signum() == 0) mi = true\r\n continue\r\n }\r\n w = b * w + x\r\n if (++j >= cs) {\r\n this.dMultiply(d)\r\n this.dAddOffset(w, 0)\r\n j = 0\r\n w = 0\r\n }\r\n }\r\n if (j > 0) {\r\n this.dMultiply(Math.pow(b, j))\r\n this.dAddOffset(w, 0)\r\n }\r\n if (mi) BigInteger.ZERO.subTo(this, this)\r\n}\r\n\r\n// (protected) alternate constructor\r\nfunction bnpFromNumber (a, b, c) {\r\n if (typeof b === 'number') {\r\n // new BigInteger(int,int,RNG)\r\n if (a < 2) this.fromInt(1)\r\n else {\r\n this.fromNumber(a, c)\r\n if (!this.testBit(a - 1)) { // force MSB set\r\n this.bitwiseTo(BigInteger.ONE.shiftLeft(a - 1), op_or, this)\r\n }\r\n if (this.isEven()) this.dAddOffset(1, 0) // force odd\r\n while (!this.isProbablePrime(b)) {\r\n this.dAddOffset(2, 0)\r\n if (this.bitLength() > a) this.subTo(BigInteger.ONE.shiftLeft(a - 1), this)\r\n }\r\n }\r\n } else {\r\n // new BigInteger(int,RNG)\r\n var x = []\r\n var t = a & 7\r\n x.length = (a >> 3) + 1\r\n b.nextBytes(x)\r\n if (t > 0) x[0] &= ((1 << t) - 1); else x[0] = 0\r\n this.fromString(x, 256)\r\n }\r\n}\r\n\r\n// (public) convert to bigendian byte array\r\nfunction bnToByteArray () {\r\n var i = this.t\r\n var r = []\r\n r[0] = this.s\r\n var p = this.DB - (i * this.DB) % 8; var d; var k = 0\r\n if (i-- > 0) {\r\n if (p < this.DB && (d = this[i] >> p) != (this.s & this.DM) >> p) { r[k++] = d | (this.s << (this.DB - p)) }\r\n while (i >= 0) {\r\n if (p < 8) {\r\n d = (this[i] & ((1 << p) - 1)) << (8 - p)\r\n d |= this[--i] >> (p += this.DB - 8)\r\n } else {\r\n d = (this[i] >> (p -= 8)) & 0xff\r\n if (p <= 0) { p += this.DB; --i }\r\n }\r\n if ((d & 0x80) != 0) d |= -256\r\n if (k == 0 && (this.s & 0x80) != (d & 0x80)) ++k\r\n if (k > 0 || d != this.s) r[k++] = d\r\n }\r\n }\r\n return r\r\n}\r\n\r\nfunction bnEquals (a) { return (this.compareTo(a) == 0) }\r\nfunction bnMin (a) { return (this.compareTo(a) < 0) ? this : a }\r\nfunction bnMax (a) { return (this.compareTo(a) > 0) ? this : a }\r\n\r\n// (protected) r = this op a (bitwise)\r\nfunction bnpBitwiseTo (a, op, r) {\r\n var i; var f; var m = Math.min(a.t, this.t)\r\n for (i = 0; i < m; ++i) r[i] = op(this[i], a[i])\r\n if (a.t < this.t) {\r\n f = a.s & this.DM\r\n for (i = m; i < this.t; ++i) r[i] = op(this[i], f)\r\n r.t = this.t\r\n } else {\r\n f = this.s & this.DM\r\n for (i = m; i < a.t; ++i) r[i] = op(f, a[i])\r\n r.t = a.t\r\n }\r\n r.s = op(this.s, a.s)\r\n r.clamp()\r\n}\r\n\r\n// (public) this & a\r\nfunction op_and (x, y) { return x & y }\r\nfunction bnAnd (a) { var r = nbi(); this.bitwiseTo(a, op_and, r); return r }\r\n\r\n// (public) this | a\r\nfunction op_or (x, y) { return x | y }\r\nfunction bnOr (a) { var r = nbi(); this.bitwiseTo(a, op_or, r); return r }\r\n\r\n// (public) this ^ a\r\nfunction op_xor (x, y) { return x ^ y }\r\nfunction bnXor (a) { var r = nbi(); this.bitwiseTo(a, op_xor, r); return r }\r\n\r\n// (public) this & ~a\r\nfunction op_andnot (x, y) { return x & ~y }\r\nfunction bnAndNot (a) { var r = nbi(); this.bitwiseTo(a, op_andnot, r); return r }\r\n\r\n// (public) ~this\r\nfunction bnNot () {\r\n var r = nbi()\r\n for (var i = 0; i < this.t; ++i) r[i] = this.DM & ~this[i]\r\n r.t = this.t\r\n r.s = ~this.s\r\n return r\r\n}\r\n\r\n// (public) this << n\r\nfunction bnShiftLeft (n) {\r\n var r = nbi()\r\n if (n < 0) this.rShiftTo(-n, r); else this.lShiftTo(n, r)\r\n return r\r\n}\r\n\r\n// (public) this >> n\r\nfunction bnShiftRight (n) {\r\n var r = nbi()\r\n if (n < 0) this.lShiftTo(-n, r); else this.rShiftTo(n, r)\r\n return r\r\n}\r\n\r\n// return index of lowest 1-bit in x, x < 2^31\r\nfunction lbit (x) {\r\n if (x == 0) return -1\r\n var r = 0\r\n if ((x & 0xffff) == 0) { x >>= 16; r += 16 }\r\n if ((x & 0xff) == 0) { x >>= 8; r += 8 }\r\n if ((x & 0xf) == 0) { x >>= 4; r += 4 }\r\n if ((x & 3) == 0) { x >>= 2; r += 2 }\r\n if ((x & 1) == 0) ++r\r\n return r\r\n}\r\n\r\n// (public) returns index of lowest 1-bit (or -1 if none)\r\nfunction bnGetLowestSetBit () {\r\n for (var i = 0; i < this.t; ++i) { if (this[i] != 0) return i * this.DB + lbit(this[i]) }\r\n if (this.s < 0) return this.t * this.DB\r\n return -1\r\n}\r\n\r\n// return number of 1 bits in x\r\nfunction cbit (x) {\r\n var r = 0\r\n while (x != 0) { x &= x - 1; ++r }\r\n return r\r\n}\r\n\r\n// (public) return number of set bits\r\nfunction bnBitCount () {\r\n var r = 0; var x = this.s & this.DM\r\n for (var i = 0; i < this.t; ++i) r += cbit(this[i] ^ x)\r\n return r\r\n}\r\n\r\n// (public) true iff nth bit is set\r\nfunction bnTestBit (n) {\r\n var j = Math.floor(n / this.DB)\r\n if (j >= this.t) return (this.s != 0)\r\n return ((this[j] & (1 << (n % this.DB))) != 0)\r\n}\r\n\r\n// (protected) this op (1<<n)\r\nfunction bnpChangeBit (n, op) {\r\n var r = BigInteger.ONE.shiftLeft(n)\r\n this.bitwiseTo(r, op, r)\r\n return r\r\n}\r\n\r\n// (public) this | (1<<n)\r\nfunction bnSetBit (n) { return this.changeBit(n, op_or) }\r\n\r\n// (public) this & ~(1<<n)\r\nfunction bnClearBit (n) { return this.changeBit(n, op_andnot) }\r\n\r\n// (public) this ^ (1<<n)\r\nfunction bnFlipBit (n) { return this.changeBit(n, op_xor) }\r\n\r\n// (protected) r = this + a\r\nfunction bnpAddTo (a, r) {\r\n var i = 0; var c = 0; var m = Math.min(a.t, this.t)\r\n while (i < m) {\r\n c += this[i] + a[i]\r\n r[i++] = c & this.DM\r\n c >>= this.DB\r\n }\r\n if (a.t < this.t) {\r\n c += a.s\r\n while (i < this.t) {\r\n c += this[i]\r\n r[i++] = c & this.DM\r\n c >>= this.DB\r\n }\r\n c += this.s\r\n } else {\r\n c += this.s\r\n while (i < a.t) {\r\n c += a[i]\r\n r[i++] = c & this.DM\r\n c >>= this.DB\r\n }\r\n c += a.s\r\n }\r\n r.s = (c < 0) ? -1 : 0\r\n if (c > 0) r[i++] = c\r\n else if (c < -1) r[i++] = this.DV + c\r\n r.t = i\r\n r.clamp()\r\n}\r\n\r\n// (public) this + a\r\nfunction bnAdd (a) { var r = nbi(); this.addTo(a, r); return r }\r\n\r\n// (public) this - a\r\nfunction bnSubtract (a) { var r = nbi(); this.subTo(a, r); return r }\r\n\r\n// (public) this * a\r\nfunction bnMultiply (a) { var r = nbi(); this.multiplyTo(a, r); return r }\r\n\r\n// (public) this^2\r\nfunction bnSquare () { var r = nbi(); this.squareTo(r); return r }\r\n\r\n// (public) this / a\r\nfunction bnDivide (a) { var r = nbi(); this.divRemTo(a, r, null); return r }\r\n\r\n// (public) this % a\r\nfunction bnRemainder (a) { var r = nbi(); this.divRemTo(a, null, r); return r }\r\n\r\n// (public) [this/a,this%a]\r\nfunction bnDivideAndRemainder (a) {\r\n var q = nbi(); var r = nbi()\r\n this.divRemTo(a, q, r)\r\n return [q, r]\r\n}\r\n\r\n// (protected) this *= n, this >= 0, 1 < n < DV\r\nfunction bnpDMultiply (n) {\r\n this[this.t] = this.am(0, n - 1, this, 0, 0, this.t)\r\n ++this.t\r\n this.clamp()\r\n}\r\n\r\n// (protected) this += n << w words, this >= 0\r\nfunction bnpDAddOffset (n, w) {\r\n if (n == 0) return\r\n while (this.t <= w) this[this.t++] = 0\r\n this[w] += n\r\n while (this[w] >= this.DV) {\r\n this[w] -= this.DV\r\n if (++w >= this.t) this[this.t++] = 0\r\n ++this[w]\r\n }\r\n}\r\n\r\n// A \"null\" reducer\r\nfunction NullExp () {}\r\nfunction nNop (x) { return x }\r\nfunction nMulTo (x, y, r) { x.multiplyTo(y, r) }\r\nfunction nSqrTo (x, r) { x.squareTo(r) }\r\n\r\nNullExp.prototype.convert = nNop\r\nNullExp.prototype.revert = nNop\r\nNullExp.prototype.mulTo = nMulTo\r\nNullExp.prototype.sqrTo = nSqrTo\r\n\r\n// (public) this^e\r\nfunction bnPow (e) { return this.exp(e, new NullExp()) }\r\n\r\n// (protected) r = lower n words of \"this * a\", a.t <= n\r\n// \"this\" should be the larger one if appropriate.\r\nfunction bnpMultiplyLowerTo (a, n, r) {\r\n var i = Math.min(this.t + a.t, n)\r\n r.s = 0 // assumes a,this >= 0\r\n r.t = i\r\n while (i > 0) r[--i] = 0\r\n var j\r\n for (j = r.t - this.t; i < j; ++i) r[i + this.t] = this.am(0, a[i], r, i, 0, this.t)\r\n for (j = Math.min(a.t, n); i < j; ++i) this.am(0, a[i], r, i, 0, n - i)\r\n r.clamp()\r\n}\r\n\r\n// (protected) r = \"this * a\" without lower n words, n > 0\r\n// \"this\" should be the larger one if appropriate.\r\nfunction bnpMultiplyUpperTo (a, n, r) {\r\n --n\r\n var i = r.t = this.t + a.t - n\r\n r.s = 0 // assumes a,this >= 0\r\n while (--i >= 0) r[i] = 0\r\n for (i = Math.max(n - this.t, 0); i < a.t; ++i) { r[this.t + i - n] = this.am(n - i, a[i], r, 0, 0, this.t + i - n) }\r\n r.clamp()\r\n r.drShiftTo(1, r)\r\n}\r\n\r\n// Barrett modular reduction\r\nfunction Barrett (m) {\r\n // setup Barrett\r\n this.r2 = nbi()\r\n this.q3 = nbi()\r\n BigInteger.ONE.dlShiftTo(2 * m.t, this.r2)\r\n this.mu = this.r2.divide(m)\r\n this.m = m\r\n}\r\n\r\nfunction barrettConvert (x) {\r\n if (x.s < 0 || x.t > 2 * this.m.t) return x.mod(this.m)\r\n else if (x.compareTo(this.m) < 0) return x\r\n else { var r = nbi(); x.copyTo(r); this.reduce(r); return r }\r\n}\r\n\r\nfunction barrettRevert (x) { return x }\r\n\r\n// x = x mod m (HAC 14.42)\r\nfunction barrettReduce (x) {\r\n x.drShiftTo(this.m.t - 1, this.r2)\r\n if (x.t > this.m.t + 1) { x.t = this.m.t + 1; x.clamp() }\r\n this.mu.multiplyUpperTo(this.r2, this.m.t + 1, this.q3)\r\n this.m.multiplyLowerTo(this.q3, this.m.t + 1, this.r2)\r\n while (x.compareTo(this.r2) < 0) x.dAddOffset(1, this.m.t + 1)\r\n x.subTo(this.r2, x)\r\n while (x.compareTo(this.m) >= 0) x.subTo(this.m, x)\r\n}\r\n\r\n// r = x^2 mod m; x != r\r\nfunction barrettSqrTo (x, r) { x.squareTo(r); this.reduce(r) }\r\n\r\n// r = x*y mod m; x,y != r\r\nfunction barrettMulTo (x, y, r) { x.multiplyTo(y, r); this.reduce(r) }\r\n\r\nBarrett.prototype.convert = barrettConvert\r\nBarrett.prototype.revert = barrettRevert\r\nBarrett.prototype.reduce = barrettReduce\r\nBarrett.prototype.mulTo = barrettMulTo\r\nBarrett.prototype.sqrTo = barrettSqrTo\r\n\r\n// (public) this^e % m (HAC 14.85)\r\nfunction bnModPow (e, m) {\r\n var i = e.bitLength(); var k; var r = nbv(1); var z\r\n if (i <= 0) return r\r\n else if (i < 18) k = 1\r\n else if (i < 48) k = 3\r\n else if (i < 144) k = 4\r\n else if (i < 768) k = 5\r\n else k = 6\r\n if (i < 8) { z = new Classic(m) } else if (m.isEven()) { z = new Barrett(m) } else { z = new Montgomery(m) }\r\n\r\n // precomputation\r\n var g = []\r\n var n = 3; var k1 = k - 1; var km = (1 << k) - 1\r\n g[1] = z.convert(this)\r\n if (k > 1) {\r\n var g2 = nbi()\r\n z.sqrTo(g[1], g2)\r\n while (n <= km) {\r\n g[n] = nbi()\r\n z.mulTo(g2, g[n - 2], g[n])\r\n n += 2\r\n }\r\n }\r\n\r\n var j = e.t - 1; var w; var is1 = true; var r2 = nbi(); var t\r\n i = nbits(e[j]) - 1\r\n while (j >= 0) {\r\n if (i >= k1) w = (e[j] >> (i - k1)) & km\r\n else {\r\n w = (e[j] & ((1 << (i + 1)) - 1)) << (k1 - i)\r\n if (j > 0) w |= e[j - 1] >> (this.DB + i - k1)\r\n }\r\n\r\n n = k\r\n while ((w & 1) == 0) { w >>= 1; --n }\r\n if ((i -= n) < 0) { i += this.DB; --j }\r\n if (is1) { // ret == 1, don't bother squaring or multiplying it\r\n g[w].copyTo(r)\r\n is1 = false\r\n } else {\r\n while (n > 1) { z.sqrTo(r, r2); z.sqrTo(r2, r); n -= 2 }\r\n if (n > 0) z.sqrTo(r, r2); else { t = r; r = r2; r2 = t }\r\n z.mulTo(r2, g[w], r)\r\n }\r\n\r\n while (j >= 0 && (e[j] & (1 << i)) == 0) {\r\n z.sqrTo(r, r2); t = r; r = r2; r2 = t\r\n if (--i < 0) { i = this.DB - 1; --j }\r\n }\r\n }\r\n return z.revert(r)\r\n}\r\n\r\n// (public) gcd(this,a) (HAC 14.54)\r\nfunction bnGCD (a) {\r\n var x = (this.s < 0) ? this.negate() : this.clone()\r\n var y = (a.s < 0) ? a.negate() : a.clone()\r\n if (x.compareTo(y) < 0) { var t = x; x = y; y = t }\r\n var i = x.getLowestSetBit(); var g = y.getLowestSetBit()\r\n if (g < 0) return x\r\n if (i < g) g = i\r\n if (g > 0) {\r\n x.rShiftTo(g, x)\r\n y.rShiftTo(g, y)\r\n }\r\n while (x.signum() > 0) {\r\n if ((i = x.getLowestSetBit()) > 0) x.rShiftTo(i, x)\r\n if ((i = y.getLowestSetBit()) > 0) y.rShiftTo(i, y)\r\n if (x.compareTo(y) >= 0) {\r\n x.subTo(y, x)\r\n x.rShiftTo(1, x)\r\n } else {\r\n y.subTo(x, y)\r\n y.rShiftTo(1, y)\r\n }\r\n }\r\n if (g > 0) y.lShiftTo(g, y)\r\n return y\r\n}\r\n\r\n// (protected) this % n, n < 2^26\r\nfunction bnpModInt (n) {\r\n if (n <= 0) return 0\r\n var d = this.DV % n; var r = (this.s < 0) ? n - 1 : 0\r\n if (this.t > 0) {\r\n if (d == 0) r = this[0] % n\r\n else for (var i = this.t - 1; i >= 0; --i) r = (d * r + this[i]) % n\r\n }\r\n return r\r\n}\r\n\r\n// (public) 1/this % m (HAC 14.61)\r\nfunction bnModInverse (m) {\r\n var ac = m.isEven()\r\n if ((this.isEven() && ac) || m.signum() == 0) return BigInteger.ZERO\r\n var u = m.clone(); var v = this.clone()\r\n var a = nbv(1); var b = nbv(0); var c = nbv(0); var d = nbv(1)\r\n while (u.signum() != 0) {\r\n while (u.isEven()) {\r\n u.rShiftTo(1, u)\r\n if (ac) {\r\n if (!a.isEven() || !b.isEven()) { a.addTo(this, a); b.subTo(m, b) }\r\n a.rShiftTo(1, a)\r\n } else if (!b.isEven()) b.subTo(m, b)\r\n b.rShiftTo(1, b)\r\n }\r\n while (v.isEven()) {\r\n v.rShiftTo(1, v)\r\n if (ac) {\r\n if (!c.isEven() || !d.isEven()) { c.addTo(this, c); d.subTo(m, d) }\r\n c.rShiftTo(1, c)\r\n } else if (!d.isEven()) d.subTo(m, d)\r\n d.rShiftTo(1, d)\r\n }\r\n if (u.compareTo(v) >= 0) {\r\n u.subTo(v, u)\r\n if (ac) a.subTo(c, a)\r\n b.subTo(d, b)\r\n } else {\r\n v.subTo(u, v)\r\n if (ac) c.subTo(a, c)\r\n d.subTo(b, d)\r\n }\r\n }\r\n if (v.compareTo(BigInteger.ONE) != 0) return BigInteger.ZERO\r\n if (d.compareTo(m) >= 0) return d.subtract(m)\r\n if (d.signum() < 0) d.addTo(m, d); else return d\r\n if (d.signum() < 0) return d.add(m); else return d\r\n}\r\n\r\nvar lowprimes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997]\r\nvar lplim = (1 << 26) / lowprimes[lowprimes.length - 1]\r\n\r\n// (public) test primality with certainty >= 1-.5^t\r\nfunction bnIsProbablePrime (t) {\r\n var i; var x = this.abs()\r\n if (x.t == 1 && x[0] <= lowprimes[lowprimes.length - 1]) {\r\n for (i = 0; i < lowprimes.length; ++i) { if (x[0] == lowprimes[i]) return true }\r\n return false\r\n }\r\n if (x.isEven()) return false\r\n i = 1\r\n while (i < lowprimes.length) {\r\n var m = lowprimes[i]; var j = i + 1\r\n while (j < lowprimes.length && m < lplim) m *= lowprimes[j++]\r\n m = x.modInt(m)\r\n while (i < j) if (m % lowprimes[i++] == 0) return false\r\n }\r\n return x.millerRabin(t)\r\n}\r\n\r\n// (protected) true if probably prime (HAC 4.24, Miller-Rabin)\r\nfunction bnpMillerRabin (t) {\r\n var n1 = this.subtract(BigInteger.ONE)\r\n var k = n1.getLowestSetBit()\r\n if (k <= 0) return false\r\n var r = n1.shiftRight(k)\r\n t = (t + 1) >> 1\r\n if (t > lowprimes.length) t = lowprimes.length\r\n var a = nbi()\r\n for (var i = 0; i < t; ++i) {\r\n // Pick bases at random, instead of starting at 2\r\n a.fromInt(lowprimes[Math.floor(Math.random() * lowprimes.length)])\r\n var y = a.modPow(r, this)\r\n if (y.compareTo(BigInteger.ONE) != 0 && y.compareTo(n1) != 0) {\r\n var j = 1\r\n while (j++ < k && y.compareTo(n1) != 0) {\r\n y = y.modPowInt(2, this)\r\n if (y.compareTo(BigInteger.ONE) == 0) return false\r\n }\r\n if (y.compareTo(n1) != 0) return false\r\n }\r\n }\r\n return true\r\n}\r\n\r\n// protected\r\nBigInteger.prototype.chunkSize = bnpChunkSize\r\nBigInteger.prototype.toRadix = bnpToRadix\r\nBigInteger.prototype.fromRadix = bnpFromRadix\r\nBigInteger.prototype.fromNumber = bnpFromNumber\r\nBigInteger.prototype.bitwiseTo = bnpBitwiseTo\r\nBigInteger.prototype.changeBit = bnpChangeBit\r\nBigInteger.prototype.addTo = bnpAddTo\r\nBigInteger.prototype.dMultiply = bnpDMultiply\r\nBigInteger.prototype.dAddOffset = bnpDAddOffset\r\nBigInteger.prototype.multiplyLowerTo = bnpMultiplyLowerTo\r\nBigInteger.prototype.multiplyUpperTo = bnpMultiplyUpperTo\r\nBigInteger.prototype.modInt = bnpModInt\r\nBigInteger.prototype.millerRabin = bnpMillerRabin\r\n\r\n// public\r\nBigInteger.prototype.clone = bnClone\r\nBigInteger.prototype.intValue = bnIntValue\r\nBigInteger.prototype.byteValue = bnByteValue\r\nBigInteger.prototype.shortValue = bnShortValue\r\nBigInteger.prototype.signum = bnSigNum\r\nBigInteger.prototype.toByteArray = bnToByteArray\r\nBigInteger.prototype.equals = bnEquals\r\nBigInteger.prototype.min = bnMin\r\nBigInteger.prototype.max = bnMax\r\nBigInteger.prototype.and = bnAnd\r\nBigInteger.prototype.or = bnOr\r\nBigInteger.prototype.xor = bnXor\r\nBigInteger.prototype.andNot = bnAndNot\r\nBigInteger.prototype.not = bnNot\r\nBigInteger.prototype.shiftLeft = bnShiftLeft\r\nBigInteger.prototype.shiftRight = bnShiftRight\r\nBigInteger.prototype.getLowestSetBit = bnGetLowestSetBit\r\nBigInteger.prototype.bitCount = bnBitCount\r\nBigInteger.prototype.testBit = bnTestBit\r\nBigInteger.prototype.setBit = bnSetBit\r\nBigInteger.prototype.clearBit = bnClearBit\r\nBigInteger.prototype.flipBit = bnFlipBit\r\nBigInteger.prototype.add = bnAdd\r\nBigInteger.prototype.subtract = bnSubtract\r\nBigInteger.prototype.multiply = bnMultiply\r\nBigInteger.prototype.divide = bnDivide\r\nBigInteger.prototype.remainder = bnRemainder\r\nBigInteger.prototype.divideAndRemainder = bnDivideAndRemainder\r\nBigInteger.prototype.modPow = bnModPow\r\nBigInteger.prototype.modInverse = bnModInverse\r\nBigInteger.prototype.pow = bnPow\r\nBigInteger.prototype.gcd = bnGCD\r\nBigInteger.prototype.isProbablePrime = bnIsProbablePrime\r\n\r\n// JSBN-specific extension\r\nBigInteger.prototype.square = bnSquare\r\n\r\n// Expose the Barrett function\r\nBigInteger.prototype.Barrett = Barrett\r\n\r\n// BigInteger interfaces not implemented in jsbn:\r\n\r\n// BigInteger(int signum, byte[] magnitude)\r\n// double doubleValue()\r\n// float floatValue()\r\n// int hashCode()\r\n// long longValue()\r\n// static BigInteger valueOf(long val)\r\n\r\n// Random number generator - requires a PRNG backend, e.g. prng4.js\r\n\r\n// For best results, put code like\r\n// <body onClick='rng_seed_time();' onKeyPress='rng_seed_time();'>\r\n// in your main HTML document.\r\n\r\nvar rng_state\r\nvar rng_pool\r\nvar rng_pptr\r\n\r\n// Mix in a 32-bit integer into the pool\r\nfunction rng_seed_int (x) {\r\n rng_pool[rng_pptr++] ^= x & 255\r\n rng_pool[rng_pptr++] ^= (x >> 8) & 255\r\n rng_pool[rng_pptr++] ^= (x >> 16) & 255\r\n rng_pool[rng_pptr++] ^= (x >> 24) & 255\r\n if (rng_pptr >= rng_psize) rng_pptr -= rng_psize\r\n}\r\n\r\n// Mix in the current time (w/milliseconds) into the pool\r\nfunction rng_seed_time () {\r\n rng_seed_int(new Date().getTime())\r\n}\r\n\r\nvar rng_psize = 256\r\n\r\n// Initialize the pool with junk if needed.\r\nif (rng_pool == null) {\r\n rng_pool = []\r\n rng_pptr = 0\r\n var t\r\n if (typeof window !== 'undefined' && window.crypto) {\r\n if (window.crypto.getRandomValues) {\r\n // Use webcrypto if available\r\n var ua = new Uint8Array(32)\r\n window.crypto.getRandomValues(ua)\r\n for (t = 0; t < 32; ++t) { rng_pool[rng_pptr++] = ua[t] }\r\n } else if (navigator.appName == 'Netscape' && navigator.appVersion < '5') {\r\n // Extract entropy (256 bits) from NS4 RNG if available\r\n var z = window.crypto.random(32)\r\n for (t = 0; t < z.length; ++t) { rng_pool[rng_pptr++] = z.charCodeAt(t) & 255 }\r\n }\r\n }\r\n while (rng_pptr < rng_psize) { // extract some randomness from Math.random()\r\n t = Math.floor(65536 * Math.random())\r\n rng_pool[rng_pptr++] = t >>> 8\r\n rng_pool[rng_pptr++] = t & 255\r\n }\r\n rng_pptr = 0\r\n rng_seed_time()\r\n // rng_seed_int(window.screenX);\r\n // rng_seed_int(window.screenY);\r\n}\r\n\r\nfunction rng_get_byte () {\r\n if (rng_state == null) {\r\n rng_seed_time()\r\n rng_state = prng_newstate()\r\n rng_state.init(rng_pool)\r\n for (rng_pptr = 0; rng_pptr < rng_pool.length; ++rng_pptr) { rng_pool[rng_pptr] = 0 }\r\n rng_pptr = 0\r\n // rng_pool = null;\r\n }\r\n return rng_state.next()\r\n}\r\n\r\nfunction rng_get_bytes (ba) {\r\n var i\r\n for (i = 0; i < ba.length; ++i) ba[i] = rng_get_byte()\r\n}\r\n\r\nfunction SecureRandom () {}\r\n\r\nSecureRandom.prototype.nextBytes = rng_get_bytes\r\n\r\n// prng4.js - uses Arcfour as a PRNG\r\n\r\nfunction Arcfour () {\r\n this.i = 0\r\n this.j = 0\r\n this.S = []\r\n}\r\n\r\n// Initialize arcfour context from key, an array of ints, each from [0..255]\r\nfunction ARC4init (key) {\r\n var i, j, t\r\n for (i = 0; i < 256; ++i) { this.S[i] = i }\r\n j = 0\r\n for (i = 0; i < 256; ++i) {\r\n j = (j + this.S[i] + key[i % key.length]) & 255\r\n t = this.S[i]\r\n this.S[i] = this.S[j]\r\n this.S[j] = t\r\n }\r\n this.i = 0\r\n this.j = 0\r\n}\r\n\r\nfunction ARC4next () {\r\n var t\r\n this.i = (this.i + 1) & 255\r\n this.j = (this.j + this.S[this.i]) & 255\r\n t = this.S[this.i]\r\n this.S[this.i] = this.S[this.j]\r\n this.S[this.j] = t\r\n return this.S[(t + this.S[this.i]) & 255]\r\n}\r\n\r\nArcfour.prototype.init = ARC4init\r\nArcfour.prototype.next = ARC4next\r\n\r\n// Plug in your RNG constructor here\r\nfunction prng_newstate () {\r\n return new Arcfour()\r\n}\r\n\r\n// Pool size must be a multiple of 4 and greater than 32.\r\n// An array of bytes the size of the pool will be passed to init()\r\n\r\n\r\n\n\n//# sourceURL=webpack://SM/./src/sm2/jsbn.js?");
/***/ }),
/***/ "./src/sm2/sm2.js":
/*!************************!*\
!*** ./src/sm2/sm2.js ***!
\************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var _jsbn_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./jsbn.js */ \"./src/sm2/jsbn.js\");\n/* harmony import */ var _sm3__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./sm3 */ \"./src/sm2/sm3.js\");\n/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./utils */ \"./src/sm2/utils.js\");\n/* eslint-disable eqeqeq */\r\n\r\n\r\n\r\n\r\nclass SM2Cipher {\r\n constructor () {\r\n this.ct = 1\r\n this.p2 = null\r\n this.sm3keybase = null\r\n this.sm3c3 = null\r\n this.key = new Array(32)\r\n this.keyOff = 0\r\n }\r\n\r\n reset () {\r\n this.sm3keybase = new _sm3__WEBPACK_IMPORTED_MODULE_1__[\"default\"]()\r\n this.sm3c3 = new _sm3__WEBPACK_IMPORTED_MODULE_1__[\"default\"]()\r\n const xWords = _utils__WEBPACK_IMPORTED_MODULE_2__[\"default\"].hexToArray(this.p2.getX().toBigInteger().toRadix(16))\r\n const yWords = _utils__WEBPACK_IMPORTED_MODULE_2__[\"default\"].hexToArray(this.p2.getY().toBigInteger().toRadix(16))\r\n this.sm3keybase.blockUpdate(xWords, 0, xWords.length)\r\n this.sm3c3.blockUpdate(xWords, 0, xWords.length)\r\n this.sm3keybase.blockUpdate(yWords, 0, yWords.length)\r\n this.ct = 1\r\n this.nextKey()\r\n }\r\n\r\n nextKey () {\r\n const sm3keycur = new _sm3__WEBPACK_IMPORTED_MODULE_1__[\"default\"](this.sm3keybase)\r\n sm3keycur.update((this.ct >> 24 & 0x00ff))\r\n sm3keycur.update((this.ct >> 16 & 0x00ff))\r\n sm3keycur.update((this.ct >> 8 & 0x00ff))\r\n sm3keycur.update((this.ct & 0x00ff))\r\n sm3keycur.doFinal(this.key, 0)\r\n this.keyOff = 0\r\n this.ct++\r\n }\r\n\r\n initEncipher (userKey) {\r\n const keypair = _utils__WEBPACK_IMPORTED_MODULE_2__[\"default\"].generateKeyPairHex()\r\n const k = new _jsbn_js__WEBPACK_IMPORTED_MODULE_0__.BigInteger(keypair.privateKey, 16)\r\n let publicKey = keypair.publicKey\r\n\r\n this.p2 = userKey.multiply(k) // [k](Pb)\r\n this.reset()\r\n\r\n if (publicKey.length > 128) {\r\n publicKey = publicKey.substr(publicKey.length - 128)\r\n }\r\n\r\n return publicKey\r\n }\r\n\r\n encryptBlock (data) {\r\n this.sm3c3.blockUpdate(data, 0, data.length)\r\n for (let i = 0; i < data.length; i++) {\r\n if (this.keyOff == this.key.length) {\r\n this.nextKey()\r\n }\r\n data[i] ^= this.key[this.keyOff++] & 0xff\r\n }\r\n }\r\n\r\n initDecipher (userD, c1) {\r\n this.p2 = c1.multiply(userD)\r\n this.reset()\r\n }\r\n\r\n decryptBlock (data) {\r\n for (let i = 0; i < data.length; i++) {\r\n if (this.keyOff == this.key.length) {\r\n this.nextKey()\r\n }\r\n data[i] ^= this.key[this.keyOff++] & 0xff\r\n }\r\n this.sm3c3.blockUpdate(data, 0, data.length)\r\n }\r\n\r\n doFinal (c3) {\r\n const yWords = _utils__WEBPACK_IMPORTED_MODULE_2__[\"default\"].hexToArray(this.p2.getY().toBigInteger().toRadix(16))\r\n this.sm3c3.blockUpdate(yWords, 0, yWords.length)\r\n this.sm3c3.doFinal(c3, 0)\r\n this.reset()\r\n }\r\n\r\n createPoint (x, y) {\r\n const publicKey = '04' + x + y\r\n const point = _utils__WEBPACK_IMPORTED_MODULE_2__[\"default\"].getGlobalCurve().decodePointHex(publicKey)\r\n return point\r\n }\r\n}\r\n\r\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (SM2Cipher);\r\n\n\n//# sourceURL=webpack://SM/./src/sm2/sm2.js?");
/***/ }),
/***/ "./src/sm2/sm3.js":
/*!************************!*\
!*** ./src/sm2/sm3.js ***!
\************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var _jsbn_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./jsbn.js */ \"./src/sm2/jsbn.js\");\n/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils */ \"./src/sm2/utils.js\");\n/* eslint-disable eqeqeq */\r\n/* eslint-disable camelcase */\r\n\r\n\r\n\r\nconst copyArray = function (sourceArray, sourceIndex, destinationArray, destinationIndex, length) {\r\n for (let i = 0; i < length; i++) destinationArray[destinationIndex + i] = sourceArray[sourceIndex + i]\r\n}\r\n\r\nconst Int32 = {\r\n minValue: -parseInt('10000000000000000000000000000000', 2),\r\n maxValue: parseInt('1111111111111111111111111111111', 2),\r\n parse: function (n) {\r\n if (n < this.minValue) {\r\n const bigInteger = -n\r\n const bigIntegerRadix = bigInteger.toString(2)\r\n const subBigIntegerRadix = bigIntegerRadix.substr(bigIntegerRadix.length - 31, 31)\r\n let reBigIntegerRadix = ''\r\n for (let i = 0; i < subBigIntegerRadix.length; i++) {\r\n const subBigIntegerRadixItem = subBigIntegerRadix.substr(i, 1)\r\n reBigIntegerRadix += subBigIntegerRadixItem == '0' ? '1' : '0'\r\n }\r\n const result = parseInt(reBigIntegerRadix, 2)\r\n return (result + 1)\r\n } else if (n > this.maxValue) {\r\n const bigInteger = Number(n)\r\n const bigIntegerRadix = bigInteger.toString(2)\r\n const subBigIntegerRadix = bigIntegerRadix.substr(bigIntegerRadix.length - 31, 31)\r\n let reBigIntegerRadix = ''\r\n for (let i = 0; i < subBigIntegerRadix.length; i++) {\r\n const subBigIntegerRadixItem = subBigIntegerRadix.substr(i, 1)\r\n reBigIntegerRadix += subBigIntegerRadixItem == '0' ? '1' : '0'\r\n }\r\n const result = parseInt(reBigIntegerRadix, 2)\r\n return -(result + 1)\r\n } else {\r\n return n\r\n }\r\n },\r\n parseByte: function (n) {\r\n if (n < 0) {\r\n const bigInteger = -n\r\n const bigIntegerRadix = bigInteger.toString(2)\r\n const subBigIntegerRadix = bigIntegerRadix.substr(bigIntegerRadix.length - 8, 8)\r\n let reBigIntegerRadix = ''\r\n for (let i = 0; i < subBigIntegerRadix.length; i++) {\r\n const subBigIntegerRadixItem = subBigIntegerRadix.substr(i, 1)\r\n reBigIntegerRadix += subBigIntegerRadixItem == '0' ? '1' : '0'\r\n }\r\n const result = parseInt(reBigIntegerRadix, 2)\r\n return (result + 1)\r\n } else if (n > 255) {\r\n const bigInteger = Number(n)\r\n const bigIntegerRadix = bigInteger.toString(2)\r\n return parseInt(bigIntegerRadix.substr(bigIntegerRadix.length - 8, 8), 2)\r\n } else {\r\n return n\r\n }\r\n }\r\n}\r\n\r\nclass SM3Digest {\r\n constructor () {\r\n this.xBuf = []\r\n this.xBufOff = 0\r\n this.byteCount = 0\r\n this.DIGEST_LENGTH = 32\r\n this.v0 = [0x7380166f, 0x4914b2b9, 0x172442d7, 0xda8a0600, 0xa96f30bc, 0x163138aa, 0xe38dee4d, 0xb0fb0e4e]\r\n this.v0 = [0x7380166f, 0x4914b2b9, 0x172442d7, -628488704, -1452330820, 0x163138aa, -477237683, -1325724082]\r\n this.v = new Array(8)\r\n this.v_ = new Array(8)\r\n this.X0 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\r\n this.X = new Array(68)\r\n this.xOff = 0\r\n this.T_00_15 = 0x79cc4519\r\n this.T_16_63 = 0x7a879d8a\r\n if (arguments.length > 0) {\r\n this.initDigest(arguments[0])\r\n } else {\r\n this.init()\r\n }\r\n }\r\n\r\n init () {\r\n this.xBuf = new Array(4)\r\n this.reset()\r\n }\r\n\r\n initDigest (t) {\r\n this.xBuf = [].concat(t.xBuf)\r\n this.xBufOff = t.xBufOff\r\n this.byteCount = t.byteCount\r\n copyArray(t.X, 0, this.X, 0, t.X.length)\r\n this.xOff = t.xOff\r\n copyArray(t.v, 0, this.v, 0, t.v.length)\r\n }\r\n\r\n getDigestSize () {\r\n return this.DIGEST_LENGTH\r\n }\r\n\r\n reset () {\r\n this.byteCount = 0\r\n this.xBufOff = 0\r\n for (const elem in this.xBuf) this.xBuf[elem] = null\r\n copyArray(this.v0, 0, this.v, 0, this.v0.length)\r\n this.xOff = 0\r\n copyArray(this.X0, 0, this.X, 0, this.X0.length)\r\n }\r\n\r\n processBlock () {\r\n let i\r\n const ww = this.X\r\n const ww_ = new Array(64)\r\n for (i = 16; i < 68; i++) {\r\n ww[i] = this.p1(ww[i - 16] ^ ww[i - 9] ^ (this.rotate(ww[i - 3], 15))) ^ (this.rotate(ww[i - 13], 7)) ^ ww[i - 6]\r\n }\r\n for (i = 0; i < 64; i++) {\r\n ww_[i] = ww[i] ^ ww[i + 4]\r\n }\r\n const vv = this.v\r\n const vv_ = this.v_\r\n copyArray(vv, 0, vv_, 0, this.v0.length)\r\n let SS1, SS2, TT1, TT2, aaa\r\n for (i = 0; i < 16; i++) {\r\n aaa = this.rotate(vv_[0], 12)\r\n SS1 = Int32.parse(Int32.parse(aaa + vv_[4]) + this.rotate(this.T_00_15, i))\r\n SS1 = this.rotate(SS1, 7)\r\n SS2 = SS1 ^ aaa\r\n TT1 = Int32.parse(Int32.parse(this.ff_00_15(vv_[0], vv_[1], vv_[2]) + vv_[3]) + SS2) + ww_[i]\r\n TT2 = Int32.parse(Int32.parse(this.gg_00_15(vv_[4], vv_[5], vv_[6]) + vv_[7]) + SS1) + ww[i]\r\n vv_[3] = vv_[2]\r\n vv_[2] = this.rotate(vv_[1], 9)\r\n vv_[1] = vv_[0]\r\n vv_[0] = TT1\r\n vv_[7] = vv_[6]\r\n vv_[6] = this.rotate(vv_[5], 19)\r\n vv_[5] = vv_[4]\r\n vv_[4] = this.p0(TT2)\r\n }\r\n for (i = 16; i < 64; i++) {\r\n aaa = this.rotate(vv_[0], 12)\r\n SS1 = Int32.parse(Int32.parse(aaa + vv_[4]) + this.rotate(this.T_16_63, i))\r\n SS1 = this.rotate(SS1, 7)\r\n SS2 = SS1 ^ aaa\r\n TT1 = Int32.parse(Int32.parse(this.ff_16_63(vv_[0], vv_[1], vv_[2]) + vv_[3]) + SS2) + ww_[i]\r\n TT2 = Int32.parse(Int32.parse(this.gg_16_63(vv_[4], vv_[5], vv_[6]) + vv_[7]) + SS1) + ww[i]\r\n vv_[3] = vv_[2]\r\n vv_[2] = this.rotate(vv_[1], 9)\r\n vv_[1] = vv_[0]\r\n vv_[0] = TT1\r\n vv_[7] = vv_[6]\r\n vv_[6] = this.rotate(vv_[5], 19)\r\n vv_[5] = vv_[4]\r\n vv_[4] = this.p0(TT2)\r\n }\r\n for (i = 0; i < 8; i++) {\r\n vv[i] ^= Int32.parse(vv_[i])\r\n }\r\n this.xOff = 0\r\n copyArray(this.X0, 0, this.X, 0, this.X0.length)\r\n }\r\n\r\n processWord (in_Renamed, inOff) {\r\n let n = in_Renamed[inOff] << 24\r\n n |= (in_Renamed[++inOff] & 0xff) << 16\r\n n |= (in_Renamed[++inOff] & 0xff) << 8\r\n n |= (in_Renamed[++inOff] & 0xff)\r\n this.X[this.xOff] = n\r\n if (++this.xOff == 16) {\r\n this.processBlock()\r\n }\r\n }\r\n\r\n processLength (bitLength) {\r\n if (this.xOff > 14) {\r\n this.processBlock()\r\n }\r\n this.X[14] = (this.urShiftLong(bitLength, 32))\r\n this.X[15] = (bitLength & (0xffffffff))\r\n }\r\n\r\n intToBigEndian (n, bs, off) {\r\n bs[off] = Int32.parseByte(this.urShift(n, 24))\r\n bs[++off] = Int32.parseByte(this.urShift(n, 16))\r\n bs[++off] = Int32.parseByte(this.urShift(n, 8))\r\n bs[++off] = Int32.parseByte(n)\r\n }\r\n\r\n doFinal (out_Renamed, outOff) {\r\n this.finish()\r\n for (let i = 0; i < 8; i++) {\r\n this.intToBigEndian(this.v[i], out_Renamed, outOff + i * 4)\r\n }\r\n this.reset()\r\n return this.DIGEST_LENGTH\r\n }\r\n\r\n update (input) {\r\n this.xBuf[this.xBufOff++] = input\r\n if (this.xBufOff == this.xBuf.length) {\r\n this.processWord(this.xBuf, 0)\r\n this.xBufOff = 0\r\n }\r\n this.byteCount++\r\n }\r\n\r\n blockUpdate (input, inOff, length) {\r\n while ((this.xBufOff !== 0) && (length > 0)) {\r\n this.update(input[inOff])\r\n inOff++\r\n length--\r\n }\r\n while (length > this.xBuf.length) {\r\n this.processWord(input, inOff)\r\n inOff += this.xBuf.length\r\n length -= this.xBuf.length\r\n this.byteCount += this.xBuf.length\r\n }\r\n while (length > 0) {\r\n this.update(input[inOff])\r\n inOff++\r\n length--\r\n }\r\n }\r\n\r\n finish () {\r\n const bitLength = (this.byteCount << 3)\r\n this.update((128))\r\n while (this.xBufOff !== 0) this.update((0))\r\n this.processLength(bitLength)\r\n this.processBlock()\r\n }\r\n\r\n rotate (x, n) {\r\n return (x << n) | (this.urShift(x, (32 - n)))\r\n }\r\n\r\n p0 (X) {\r\n return ((X) ^ this.rotate((X), 9) ^ this.rotate((X), 17))\r\n }\r\n\r\n p1 (X) {\r\n return ((X) ^ this.rotate((X), 15) ^ this.rotate((X), 23))\r\n }\r\n\r\n ff_00_15 (X, Y, Z) {\r\n return (X ^ Y ^ Z)\r\n }\r\n\r\n ff_16_63 (X, Y, Z) {\r\n return ((X & Y) | (X & Z) | (Y & Z))\r\n }\r\n\r\n gg_00_15 (X, Y, Z) {\r\n return (X ^ Y ^ Z)\r\n }\r\n\r\n gg_16_63 (X, Y, Z) {\r\n return ((X & Y) | (~X & Z))\r\n }\r\n\r\n urShift (number, bits) {\r\n if (number > Int32.maxValue || number < Int32.minValue) {\r\n number = Int32.parse(number)\r\n }\r\n if (number >= 0) {\r\n return number >> bits\r\n } else {\r\n return (number >> bits) + (2 << ~bits)\r\n }\r\n }\r\n\r\n urShiftLong (number, bits) {\r\n let returnV\r\n const big = new _jsbn_js__WEBPACK_IMPORTED_MODULE_0__.BigInteger()\r\n big.fromInt(number)\r\n if (big.signum() >= 0) {\r\n returnV = big.shiftRight(bits).intValue()\r\n } else {\r\n const bigAdd = new _jsbn_js__WEBPACK_IMPORTED_MODULE_0__.BigInteger()\r\n bigAdd.fromInt(2)\r\n const shiftLeftBits = ~bits\r\n let shiftLeftNumber = ''\r\n if (shiftLeftBits < 0) {\r\n const shiftRightBits = 64 + shiftLeftBits\r\n for (let i = 0; i < shiftRightBits; i++) {\r\n shiftLeftNumber += '0'\r\n }\r\n const shiftLeftNumberBigAdd = new _jsbn_js__WEBPACK_IMPORTED_MODULE_0__.BigInteger()\r\n shiftLeftNumberBigAdd.fromInt(number >> bits)\r\n const shiftLeftNumberBig = new _jsbn_js__WEBPACK_IMPORTED_MODULE_0__.BigInteger('10' + shiftLeftNumber, 2)\r\n shiftLeftNumber = shiftLeftNumberBig.toRadix(10)\r\n const r = shiftLeftNumberBig.add(shiftLeftNumberBigAdd)\r\n returnV = r.toRadix(10)\r\n } else {\r\n shiftLeftNumber = bigAdd.shiftLeft((~bits)).intValue()\r\n returnV = (number >> bits) + shiftLeftNumber\r\n }\r\n }\r\n return returnV\r\n }\r\n\r\n getZ (g, publicKey) {\r\n const userId = _utils__WEBPACK_IMPORTED_MODULE_1__[\"default\"].parseUtf8StringToHex('1234567812345678')\r\n const len = userId.length * 4\r\n this.update((len >> 8 & 0x00ff))\r\n this.update((len & 0x00ff))\r\n const userIdWords = _utils__WEBPACK_IMPORTED_MODULE_1__[\"default\"].hexToArray(userId)\r\n this.blockUpdate(userIdWords, 0, userIdWords.length)\r\n const aWords = _utils__WEBPACK_IMPORTED_MODULE_1__[\"default\"].hexToArray(g.curve.a.toBigInteger().toRadix(16))\r\n const bWords = _utils__WEBPACK_IMPORTED_MODULE_1__[\"default\"].hexToArray(g.curve.b.toBigInteger().toRadix(16))\r\n const gxWords = _utils__WEBPACK_IMPORTED_MODULE_1__[\"default\"].hexToArray(g.getX().toBigInteger().toRadix(16))\r\n const gyWords = _utils__WEBPACK_IMPORTED_MODULE_1__[\"default\"].hexToArray(g.getY().toBigInteger().toRadix(16))\r\n const pxWords = _utils__WEBPACK_IMPORTED_MODULE_1__[\"default\"].hexToArray(publicKey.substr(0, 64))\r\n const pyWords = _utils__WEBPACK_IMPORTED_MODULE_1__[\"default\"].hexToArray(publicKey.substr(64, 64))\r\n this.blockUpdate(aWords, 0, aWords.length)\r\n this.blockUpdate(bWords, 0, bWords.length)\r\n this.blockUpdate(gxWords, 0, gxWords.length)\r\n this.blockUpdate(gyWords, 0, gyWords.length)\r\n this.blockUpdate(pxWords, 0, pxWords.length)\r\n this.blockUpdate(pyWords, 0, pyWords.length)\r\n const md = new Array(this.getDigestSize())\r\n this.doFinal(md, 0)\r\n return md\r\n }\r\n}\r\n\r\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (SM3Digest);\r\n\n\n//# sourceURL=webpack://SM/./src/sm2/sm3.js?");
/***/ }),
/***/ "./src/sm2/utils.js":
/*!**************************!*\
!*** ./src/sm2/utils.js ***!
\**************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var _ec__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ec */ \"./src/sm2/ec.js\");\n/* harmony import */ var _jsbn_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./jsbn.js */ \"./src/sm2/jsbn.js\");\n/* eslint-disable eqeqeq */\r\n\r\n\r\n\r\nconst rng = new _jsbn_js__WEBPACK_IMPORTED_MODULE_1__.SecureRandom()\r\nconst { curve, G, n } = generateEcparam()\r\n\r\n/**\r\n * 获取公共椭圆曲线\r\n */\r\nfunction getGlobalCurve () {\r\n return curve\r\n}\r\n\r\n/**\r\n * 生成ecparam\r\n */\r\nfunction generateEcparam () {\r\n // 椭圆曲线\r\n const p = new _jsbn_js__WEBPACK_IMPORTED_MODULE_1__.BigInteger('FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFF', 16)\r\n const a = new _jsbn_js__WEBPACK_IMPORTED_MODULE_1__.BigInteger('FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFC', 16)\r\n const b = new _jsbn_js__WEBPACK_IMPORTED_MODULE_1__.BigInteger('28E9FA9E9D9F5E344D5A9E4BCF6509A7F39789F515AB8F92DDBCBD414D940E93', 16)\r\n const curve = new _ec__WEBPACK_IMPORTED_MODULE_0__.ECCurveFp(p, a, b)\r\n\r\n // 基点\r\n const gxHex = '32C4AE2C1F1981195F9904466A39C9948FE30BBFF2660BE1715A4589334C74C7'\r\n const gyHex = 'BC3736A2F4F6779C59BDCEE36B692153D0A9877CC62A474002DF32E52139F0A0'\r\n const G = curve.decodePointHex('04' + gxHex + gyHex)\r\n\r\n const n = new _jsbn_js__WEBPACK_IMPORTED_MODULE_1__.BigInteger('FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFF7203DF6B21C6052B53BBF40939D54123', 16)\r\n\r\n return { curve, G, n }\r\n}\r\n\r\n/**\r\n * 生成密钥对\r\n */\r\nfunction generateKeyPairHex () {\r\n const d = new _jsbn_js__WEBPACK_IMPORTED_MODULE_1__.BigInteger(n.bitLength(), rng).mod(n.subtract(_jsbn_js__WEBPACK_IMPORTED_MODULE_1__.BigInteger.ONE)).add(_jsbn_js__WEBPACK_IMPORTED_MODULE_1__.BigInteger.ONE) // 随机数\r\n const privateKey = leftPad(d.toString(16), 64)\r\n\r\n const P = G.multiply(d) // P = dG,p 为公钥,d 为私钥\r\n const Px = leftPad(P.getX().toBigInteger().toString(16), 64)\r\n const Py = leftPad(P.getY().toBigInteger().toString(16), 64)\r\n const publicKey = '04' + Px + Py\r\n\r\n return { privateKey, publicKey }\r\n}\r\n\r\n/**\r\n * 解析utf8字符串到16进制\r\n */\r\nfunction parseUtf8StringToHex (input) {\r\n input = unescape(encodeURIComponent(input))\r\n\r\n const length = input.length\r\n\r\n // 转换到字数组\r\n const words = []\r\n for (let i = 0; i < length; i++) {\r\n words[i >>> 2] |= (input.charCodeAt(i) & 0xff) << (24 - (i % 4) * 8)\r\n }\r\n\r\n // 转换到16进制\r\n const hexChars = []\r\n for (let i = 0; i < length; i++) {\r\n const bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff\r\n hexChars.push((bite >>> 4).toString(16))\r\n hexChars.push((bite & 0x0f).toString(16))\r\n }\r\n\r\n return hexChars.join('')\r\n}\r\n\r\n/**\r\n * 解析arrayBuffer到16进制字符串\r\n */\r\nfunction parseArrayBufferToHex (input) {\r\n return Array.prototype.map.call(new Uint8Array(input), x => ('00' + x.toString(16)).slice(-2)).join('')\r\n}\r\n\r\n/**\r\n * 补全16进制字符串\r\n */\r\nfunction leftPad (input, num) {\r\n if (input.length >= num) return input\r\n\r\n return (new Array(num - input.length + 1)).join('0') + input\r\n}\r\n\r\n/**\r\n * 转成16进制串\r\n */\r\nfunction arrayToHex (arr) {\r\n const words = []\r\n let j = 0\r\n for (let i = 0; i < arr.length * 2; i += 2) {\r\n words[i >>> 3] |= parseInt(arr[j], 10) << (24 - (i % 8) * 4)\r\n j++\r\n }\r\n\r\n // 转换到16进制\r\n const hexChars = []\r\n for (let i = 0; i < arr.length; i++) {\r\n const bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff\r\n hexChars.push((bite >>> 4).toString(16))\r\n hexChars.push((bite & 0x0f).toString(16))\r\n }\r\n\r\n return hexChars.join('')\r\n}\r\n\r\n/**\r\n * 转成utf8串\r\n */\r\nfunction arrayToUtf8 (arr) {\r\n const words = []\r\n let j = 0\r\n for (let i = 0; i < arr.length * 2; i += 2) {\r\n words[i >>> 3] |= parseInt(arr[j], 10) << (24 - (i % 8) * 4)\r\n j++\r\n }\r\n\r\n try {\r\n const latin1Chars = []\r\n\r\n for (let i = 0; i < arr.length; i++) {\r\n const bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff\r\n latin1Chars.push(String.fromCharCode(bite))\r\n }\r\n\r\n return decodeURIComponent(escape(latin1Chars.join('')))\r\n } catch (e) {\r\n throw new Error('Malformed UTF-8 data')\r\n }\r\n}\r\n\r\n/**\r\n * 转成ascii码数组\r\n */\r\nfunction hexToArray (hexStr) {\r\n const words = []\r\n let hexStrLength = hexStr.length\r\n\r\n if (hexStrLength % 2 != 0) {\r\n hexStr = leftPad(hexStr, hexStrLength + 1)\r\n }\r\n\r\n hexStrLength = hexStr.length\r\n\r\n for (let i = 0; i < hexStrLength; i += 2) {\r\n words.push(parseInt(hexStr.substr(i, 2), 16))\r\n }\r\n return words\r\n}\r\n\r\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({\r\n getGlobalCurve,\r\n generateEcparam,\r\n generateKeyPairHex,\r\n parseUtf8StringToHex,\r\n parseArrayBufferToHex,\r\n leftPad,\r\n arrayToHex,\r\n arrayToUtf8,\r\n hexToArray\r\n});\r\n\n\n//# sourceURL=webpack://SM/./src/sm2/utils.js?");
/***/ })
/******/ });
/************************************************************************/
/******/ // The module cache
/******/ var __webpack_module_cache__ = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ var cachedModule = __webpack_module_cache__[moduleId];
/******/ if (cachedModule !== undefined) {
/******/ return cachedModule.exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = __webpack_module_cache__[moduleId] = {
/******/ // no module.id needed
/******/ // no module.loaded needed
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/************************************************************************/
/******/ /* webpack/runtime/define property getters */
/******/ (() => {
/******/ // define getter functions for harmony exports
/******/ __webpack_require__.d = (exports, definition) => {
/******/ for(var key in definition) {
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
/******/ }
/******/ }
/******/ };
/******/ })();
/******/
/******/ /* webpack/runtime/hasOwnProperty shorthand */
/******/ (() => {
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
/******/ })();
/******/
/******/ /* webpack/runtime/make namespace object */
/******/ (() => {
/******/ // define __esModule on exports
/******/ __webpack_require__.r = (exports) => {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/ })();
/******/
/************************************************************************/
/******/
/******/ // startup
/******/ // Load entry module and return exports
/******/ // This entry module can't be inlined because the eval devtool is used.
/******/ var __webpack_exports__ = __webpack_require__("./index.js");
/******/ SM = __webpack_exports__;
/******/
/******/ })()
;
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
/*! jQuery v3.3.1 | (c) JS Foundation and other contributors | jquery.org/license */
!function(e,t){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(e,t){"use strict";var n=[],r=e.document,i=Object.getPrototypeOf,o=n.slice,a=n.concat,s=n.push,u=n.indexOf,l={},c=l.toString,f=l.hasOwnProperty,p=f.toString,d=p.call(Object),h={},g=function e(t){return"function"==typeof t&&"number"!=typeof t.nodeType},y=function e(t){return null!=t&&t===t.window},v={type:!0,src:!0,noModule:!0};function m(e,t,n){var i,o=(t=t||r).createElement("script");if(o.text=e,n)for(i in v)n[i]&&(o[i]=n[i]);t.head.appendChild(o).parentNode.removeChild(o)}function x(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?l[c.call(e)]||"object":typeof e}var b="3.3.1",w=function(e,t){return new w.fn.init(e,t)},T=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;w.fn=w.prototype={jquery:"3.3.1",constructor:w,length:0,toArray:function(){return o.call(this)},get:function(e){return null==e?o.call(this):e<0?this[e+this.length]:this[e]},pushStack:function(e){var t=w.merge(this.constructor(),e);return t.prevObject=this,t},each:function(e){return w.each(this,e)},map:function(e){return this.pushStack(w.map(this,function(t,n){return e.call(t,n,t)}))},slice:function(){return this.pushStack(o.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(e){var t=this.length,n=+e+(e<0?t:0);return this.pushStack(n>=0&&n<t?[this[n]]:[])},end:function(){return this.prevObject||this.constructor()},push:s,sort:n.sort,splice:n.splice},w.extend=w.fn.extend=function(){var e,t,n,r,i,o,a=arguments[0]||{},s=1,u=arguments.length,l=!1;for("boolean"==typeof a&&(l=a,a=arguments[s]||{},s++),"object"==typeof a||g(a)||(a={}),s===u&&(a=this,s--);s<u;s++)if(null!=(e=arguments[s]))for(t in e)n=a[t],a!==(r=e[t])&&(l&&r&&(w.isPlainObject(r)||(i=Array.isArray(r)))?(i?(i=!1,o=n&&Array.isArray(n)?n:[]):o=n&&w.isPlainObject(n)?n:{},a[t]=w.extend(l,o,r)):void 0!==r&&(a[t]=r));return a},w.extend({expando:"jQuery"+("3.3.1"+Math.random()).replace(/\D/g,""),isReady:!0,error:function(e){throw new Error(e)},noop:function(){},isPlainObject:function(e){var t,n;return!(!e||"[object Object]"!==c.call(e))&&(!(t=i(e))||"function"==typeof(n=f.call(t,"constructor")&&t.constructor)&&p.call(n)===d)},isEmptyObject:function(e){var t;for(t in e)return!1;return!0},globalEval:function(e){m(e)},each:function(e,t){var n,r=0;if(C(e)){for(n=e.length;r<n;r++)if(!1===t.call(e[r],r,e[r]))break}else for(r in e)if(!1===t.call(e[r],r,e[r]))break;return e},trim:function(e){return null==e?"":(e+"").replace(T,"")},makeArray:function(e,t){var n=t||[];return null!=e&&(C(Object(e))?w.merge(n,"string"==typeof e?[e]:e):s.call(n,e)),n},inArray:function(e,t,n){return null==t?-1:u.call(t,e,n)},merge:function(e,t){for(var n=+t.length,r=0,i=e.length;r<n;r++)e[i++]=t[r];return e.length=i,e},grep:function(e,t,n){for(var r,i=[],o=0,a=e.length,s=!n;o<a;o++)(r=!t(e[o],o))!==s&&i.push(e[o]);return i},map:function(e,t,n){var r,i,o=0,s=[];if(C(e))for(r=e.length;o<r;o++)null!=(i=t(e[o],o,n))&&s.push(i);else for(o in e)null!=(i=t(e[o],o,n))&&s.push(i);return a.apply([],s)},guid:1,support:h}),"function"==typeof Symbol&&(w.fn[Symbol.iterator]=n[Symbol.iterator]),w.each("Boolean Number String Function Array Date RegExp Object Error Symbol".split(" "),function(e,t){l["[object "+t+"]"]=t.toLowerCase()});function C(e){var t=!!e&&"length"in e&&e.length,n=x(e);return!g(e)&&!y(e)&&("array"===n||0===t||"number"==typeof t&&t>0&&t-1 in e)}var E=function(e){var t,n,r,i,o,a,s,u,l,c,f,p,d,h,g,y,v,m,x,b="sizzle"+1*new Date,w=e.document,T=0,C=0,E=ae(),k=ae(),S=ae(),D=function(e,t){return e===t&&(f=!0),0},N={}.hasOwnProperty,A=[],j=A.pop,q=A.push,L=A.push,H=A.slice,O=function(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1},P="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",M="[\\x20\\t\\r\\n\\f]",R="(?:\\\\.|[\\w-]|[^\0-\\xa0])+",I="\\["+M+"*("+R+")(?:"+M+"*([*^$|!~]?=)"+M+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+R+"))|)"+M+"*\\]",W=":("+R+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+I+")*)|.*)\\)|)",$=new RegExp(M+"+","g"),B=new RegExp("^"+M+"+|((?:^|[^\\\\])(?:\\\\.)*)"+M+"+$","g"),F=new RegExp("^"+M+"*,"+M+"*"),_=new RegExp("^"+M+"*([>+~]|"+M+")"+M+"*"),z=new RegExp("="+M+"*([^\\]'\"]*?)"+M+"*\\]","g"),X=new RegExp(W),U=new RegExp("^"+R+"$"),V={ID:new RegExp("^#("+R+")"),CLASS:new RegExp("^\\.("+R+")"),TAG:new RegExp("^("+R+"|[*])"),ATTR:new RegExp("^"+I),PSEUDO:new RegExp("^"+W),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+M+"*(even|odd|(([+-]|)(\\d*)n|)"+M+"*(?:([+-]|)"+M+"*(\\d+)|))"+M+"*\\)|)","i"),bool:new RegExp("^(?:"+P+")$","i"),needsContext:new RegExp("^"+M+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+M+"*((?:-\\d)?\\d*)"+M+"*\\)|)(?=[^-]|$)","i")},G=/^(?:input|select|textarea|button)$/i,Y=/^h\d$/i,Q=/^[^{]+\{\s*\[native \w/,J=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,K=/[+~]/,Z=new RegExp("\\\\([\\da-f]{1,6}"+M+"?|("+M+")|.)","ig"),ee=function(e,t,n){var r="0x"+t-65536;return r!==r||n?t:r<0?String.fromCharCode(r+65536):String.fromCharCode(r>>10|55296,1023&r|56320)},te=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,ne=function(e,t){return t?"\0"===e?"\ufffd":e.slice(0,-1)+"\\"+e.charCodeAt(e.length-1).toString(16)+" ":"\\"+e},re=function(){p()},ie=me(function(e){return!0===e.disabled&&("form"in e||"label"in e)},{dir:"parentNode",next:"legend"});try{L.apply(A=H.call(w.childNodes),w.childNodes),A[w.childNodes.length].nodeType}catch(e){L={apply:A.length?function(e,t){q.apply(e,H.call(t))}:function(e,t){var n=e.length,r=0;while(e[n++]=t[r++]);e.length=n-1}}}function oe(e,t,r,i){var o,s,l,c,f,h,v,m=t&&t.ownerDocument,T=t?t.nodeType:9;if(r=r||[],"string"!=typeof e||!e||1!==T&&9!==T&&11!==T)return r;if(!i&&((t?t.ownerDocument||t:w)!==d&&p(t),t=t||d,g)){if(11!==T&&(f=J.exec(e)))if(o=f[1]){if(9===T){if(!(l=t.getElementById(o)))return r;if(l.id===o)return r.push(l),r}else if(m&&(l=m.getElementById(o))&&x(t,l)&&l.id===o)return r.push(l),r}else{if(f[2])return L.apply(r,t.getElementsByTagName(e)),r;if((o=f[3])&&n.getElementsByClassName&&t.getElementsByClassName)return L.apply(r,t.getElementsByClassName(o)),r}if(n.qsa&&!S[e+" "]&&(!y||!y.test(e))){if(1!==T)m=t,v=e;else if("object"!==t.nodeName.toLowerCase()){(c=t.getAttribute("id"))?c=c.replace(te,ne):t.setAttribute("id",c=b),s=(h=a(e)).length;while(s--)h[s]="#"+c+" "+ve(h[s]);v=h.join(","),m=K.test(e)&&ge(t.parentNode)||t}if(v)try{return L.apply(r,m.querySelectorAll(v)),r}catch(e){}finally{c===b&&t.removeAttribute("id")}}}return u(e.replace(B,"$1"),t,r,i)}function ae(){var e=[];function t(n,i){return e.push(n+" ")>r.cacheLength&&delete t[e.shift()],t[n+" "]=i}return t}function se(e){return e[b]=!0,e}function ue(e){var t=d.createElement("fieldset");try{return!!e(t)}catch(e){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function le(e,t){var n=e.split("|"),i=n.length;while(i--)r.attrHandle[n[i]]=t}function ce(e,t){var n=t&&e,r=n&&1===e.nodeType&&1===t.nodeType&&e.sourceIndex-t.sourceIndex;if(r)return r;if(n)while(n=n.nextSibling)if(n===t)return-1;return e?1:-1}function fe(e){return function(t){return"input"===t.nodeName.toLowerCase()&&t.type===e}}function pe(e){return function(t){var n=t.nodeName.toLowerCase();return("input"===n||"button"===n)&&t.type===e}}function de(e){return function(t){return"form"in t?t.parentNode&&!1===t.disabled?"label"in t?"label"in t.parentNode?t.parentNode.disabled===e:t.disabled===e:t.isDisabled===e||t.isDisabled!==!e&&ie(t)===e:t.disabled===e:"label"in t&&t.disabled===e}}function he(e){return se(function(t){return t=+t,se(function(n,r){var i,o=e([],n.length,t),a=o.length;while(a--)n[i=o[a]]&&(n[i]=!(r[i]=n[i]))})})}function ge(e){return e&&"undefined"!=typeof e.getElementsByTagName&&e}n=oe.support={},o=oe.isXML=function(e){var t=e&&(e.ownerDocument||e).documentElement;return!!t&&"HTML"!==t.nodeName},p=oe.setDocument=function(e){var t,i,a=e?e.ownerDocument||e:w;return a!==d&&9===a.nodeType&&a.documentElement?(d=a,h=d.documentElement,g=!o(d),w!==d&&(i=d.defaultView)&&i.top!==i&&(i.addEventListener?i.addEventListener("unload",re,!1):i.attachEvent&&i.attachEvent("onunload",re)),n.attributes=ue(function(e){return e.className="i",!e.getAttribute("className")}),n.getElementsByTagName=ue(function(e){return e.appendChild(d.createComment("")),!e.getElementsByTagName("*").length}),n.getElementsByClassName=Q.test(d.getElementsByClassName),n.getById=ue(function(e){return h.appendChild(e).id=b,!d.getElementsByName||!d.getElementsByName(b).length}),n.getById?(r.filter.ID=function(e){var t=e.replace(Z,ee);return function(e){return e.getAttribute("id")===t}},r.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&g){var n=t.getElementById(e);return n?[n]:[]}}):(r.filter.ID=function(e){var t=e.replace(Z,ee);return function(e){var n="undefined"!=typeof e.getAttributeNode&&e.getAttributeNode("id");return n&&n.value===t}},r.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&g){var n,r,i,o=t.getElementById(e);if(o){if((n=o.getAttributeNode("id"))&&n.value===e)return[o];i=t.getElementsByName(e),r=0;while(o=i[r++])if((n=o.getAttributeNode("id"))&&n.value===e)return[o]}return[]}}),r.find.TAG=n.getElementsByTagName?function(e,t){return"undefined"!=typeof t.getElementsByTagName?t.getElementsByTagName(e):n.qsa?t.querySelectorAll(e):void 0}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){while(n=o[i++])1===n.nodeType&&r.push(n);return r}return o},r.find.CLASS=n.getElementsByClassName&&function(e,t){if("undefined"!=typeof t.getElementsByClassName&&g)return t.getElementsByClassName(e)},v=[],y=[],(n.qsa=Q.test(d.querySelectorAll))&&(ue(function(e){h.appendChild(e).innerHTML="<a id='"+b+"'></a><select id='"+b+"-\r\\' msallowcapture=''><option selected=''></option></select>",e.querySelectorAll("[msallowcapture^='']").length&&y.push("[*^$]="+M+"*(?:''|\"\")"),e.querySelectorAll("[selected]").length||y.push("\\["+M+"*(?:value|"+P+")"),e.querySelectorAll("[id~="+b+"-]").length||y.push("~="),e.querySelectorAll(":checked").length||y.push(":checked"),e.querySelectorAll("a#"+b+"+*").length||y.push(".#.+[+~]")}),ue(function(e){e.innerHTML="<a href='' disabled='disabled'></a><select disabled='disabled'><option/></select>";var t=d.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("name","D"),e.querySelectorAll("[name=d]").length&&y.push("name"+M+"*[*^$|!~]?="),2!==e.querySelectorAll(":enabled").length&&y.push(":enabled",":disabled"),h.appendChild(e).disabled=!0,2!==e.querySelectorAll(":disabled").length&&y.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),y.push(",.*:")})),(n.matchesSelector=Q.test(m=h.matches||h.webkitMatchesSelector||h.mozMatchesSelector||h.oMatchesSelector||h.msMatchesSelector))&&ue(function(e){n.disconnectedMatch=m.call(e,"*"),m.call(e,"[s!='']:x"),v.push("!=",W)}),y=y.length&&new RegExp(y.join("|")),v=v.length&&new RegExp(v.join("|")),t=Q.test(h.compareDocumentPosition),x=t||Q.test(h.contains)?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)while(t=t.parentNode)if(t===e)return!0;return!1},D=t?function(e,t){if(e===t)return f=!0,0;var r=!e.compareDocumentPosition-!t.compareDocumentPosition;return r||(1&(r=(e.ownerDocument||e)===(t.ownerDocument||t)?e.compareDocumentPosition(t):1)||!n.sortDetached&&t.compareDocumentPosition(e)===r?e===d||e.ownerDocument===w&&x(w,e)?-1:t===d||t.ownerDocument===w&&x(w,t)?1:c?O(c,e)-O(c,t):0:4&r?-1:1)}:function(e,t){if(e===t)return f=!0,0;var n,r=0,i=e.parentNode,o=t.parentNode,a=[e],s=[t];if(!i||!o)return e===d?-1:t===d?1:i?-1:o?1:c?O(c,e)-O(c,t):0;if(i===o)return ce(e,t);n=e;while(n=n.parentNode)a.unshift(n);n=t;while(n=n.parentNode)s.unshift(n);while(a[r]===s[r])r++;return r?ce(a[r],s[r]):a[r]===w?-1:s[r]===w?1:0},d):d},oe.matches=function(e,t){return oe(e,null,null,t)},oe.matchesSelector=function(e,t){if((e.ownerDocument||e)!==d&&p(e),t=t.replace(z,"='$1']"),n.matchesSelector&&g&&!S[t+" "]&&(!v||!v.test(t))&&(!y||!y.test(t)))try{var r=m.call(e,t);if(r||n.disconnectedMatch||e.document&&11!==e.document.nodeType)return r}catch(e){}return oe(t,d,null,[e]).length>0},oe.contains=function(e,t){return(e.ownerDocument||e)!==d&&p(e),x(e,t)},oe.attr=function(e,t){(e.ownerDocument||e)!==d&&p(e);var i=r.attrHandle[t.toLowerCase()],o=i&&N.call(r.attrHandle,t.toLowerCase())?i(e,t,!g):void 0;return void 0!==o?o:n.attributes||!g?e.getAttribute(t):(o=e.getAttributeNode(t))&&o.specified?o.value:null},oe.escape=function(e){return(e+"").replace(te,ne)},oe.error=function(e){throw new Error("Syntax error, unrecognized expression: "+e)},oe.uniqueSort=function(e){var t,r=[],i=0,o=0;if(f=!n.detectDuplicates,c=!n.sortStable&&e.slice(0),e.sort(D),f){while(t=e[o++])t===e[o]&&(i=r.push(o));while(i--)e.splice(r[i],1)}return c=null,e},i=oe.getText=function(e){var t,n="",r=0,o=e.nodeType;if(o){if(1===o||9===o||11===o){if("string"==typeof e.textContent)return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)n+=i(e)}else if(3===o||4===o)return e.nodeValue}else while(t=e[r++])n+=i(t);return n},(r=oe.selectors={cacheLength:50,createPseudo:se,match:V,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(Z,ee),e[3]=(e[3]||e[4]||e[5]||"").replace(Z,ee),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||oe.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&oe.error(e[0]),e},PSEUDO:function(e){var t,n=!e[6]&&e[2];return V.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":n&&X.test(n)&&(t=a(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(Z,ee).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=E[e+" "];return t||(t=new RegExp("(^|"+M+")"+e+"("+M+"|$)"))&&E(e,function(e){return t.test("string"==typeof e.className&&e.className||"undefined"!=typeof e.getAttribute&&e.getAttribute("class")||"")})},ATTR:function(e,t,n){return function(r){var i=oe.attr(r,e);return null==i?"!="===t:!t||(i+="","="===t?i===n:"!="===t?i!==n:"^="===t?n&&0===i.indexOf(n):"*="===t?n&&i.indexOf(n)>-1:"$="===t?n&&i.slice(-n.length)===n:"~="===t?(" "+i.replace($," ")+" ").indexOf(n)>-1:"|="===t&&(i===n||i.slice(0,n.length+1)===n+"-"))}},CHILD:function(e,t,n,r,i){var o="nth"!==e.slice(0,3),a="last"!==e.slice(-4),s="of-type"===t;return 1===r&&0===i?function(e){return!!e.parentNode}:function(t,n,u){var l,c,f,p,d,h,g=o!==a?"nextSibling":"previousSibling",y=t.parentNode,v=s&&t.nodeName.toLowerCase(),m=!u&&!s,x=!1;if(y){if(o){while(g){p=t;while(p=p[g])if(s?p.nodeName.toLowerCase()===v:1===p.nodeType)return!1;h=g="only"===e&&!h&&"nextSibling"}return!0}if(h=[a?y.firstChild:y.lastChild],a&&m){x=(d=(l=(c=(f=(p=y)[b]||(p[b]={}))[p.uniqueID]||(f[p.uniqueID]={}))[e]||[])[0]===T&&l[1])&&l[2],p=d&&y.childNodes[d];while(p=++d&&p&&p[g]||(x=d=0)||h.pop())if(1===p.nodeType&&++x&&p===t){c[e]=[T,d,x];break}}else if(m&&(x=d=(l=(c=(f=(p=t)[b]||(p[b]={}))[p.uniqueID]||(f[p.uniqueID]={}))[e]||[])[0]===T&&l[1]),!1===x)while(p=++d&&p&&p[g]||(x=d=0)||h.pop())if((s?p.nodeName.toLowerCase()===v:1===p.nodeType)&&++x&&(m&&((c=(f=p[b]||(p[b]={}))[p.uniqueID]||(f[p.uniqueID]={}))[e]=[T,x]),p===t))break;return(x-=i)===r||x%r==0&&x/r>=0}}},PSEUDO:function(e,t){var n,i=r.pseudos[e]||r.setFilters[e.toLowerCase()]||oe.error("unsupported pseudo: "+e);return i[b]?i(t):i.length>1?(n=[e,e,"",t],r.setFilters.hasOwnProperty(e.toLowerCase())?se(function(e,n){var r,o=i(e,t),a=o.length;while(a--)e[r=O(e,o[a])]=!(n[r]=o[a])}):function(e){return i(e,0,n)}):i}},pseudos:{not:se(function(e){var t=[],n=[],r=s(e.replace(B,"$1"));return r[b]?se(function(e,t,n,i){var o,a=r(e,null,i,[]),s=e.length;while(s--)(o=a[s])&&(e[s]=!(t[s]=o))}):function(e,i,o){return t[0]=e,r(t,null,o,n),t[0]=null,!n.pop()}}),has:se(function(e){return function(t){return oe(e,t).length>0}}),contains:se(function(e){return e=e.replace(Z,ee),function(t){return(t.textContent||t.innerText||i(t)).indexOf(e)>-1}}),lang:se(function(e){return U.test(e||"")||oe.error("unsupported lang: "+e),e=e.replace(Z,ee).toLowerCase(),function(t){var n;do{if(n=g?t.lang:t.getAttribute("xml:lang")||t.getAttribute("lang"))return(n=n.toLowerCase())===e||0===n.indexOf(e+"-")}while((t=t.parentNode)&&1===t.nodeType);return!1}}),target:function(t){var n=e.location&&e.location.hash;return n&&n.slice(1)===t.id},root:function(e){return e===h},focus:function(e){return e===d.activeElement&&(!d.hasFocus||d.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},enabled:de(!1),disabled:de(!0),checked:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&!!e.checked||"option"===t&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,!0===e.selected},empty:function(e){for(e=e.firstChild;e;e=e.nextSibling)if(e.nodeType<6)return!1;return!0},parent:function(e){return!r.pseudos.empty(e)},header:function(e){return Y.test(e.nodeName)},input:function(e){return G.test(e.nodeName)},button:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&"button"===e.type||"button"===t},text:function(e){var t;return"input"===e.nodeName.toLowerCase()&&"text"===e.type&&(null==(t=e.getAttribute("type"))||"text"===t.toLowerCase())},first:he(function(){return[0]}),last:he(function(e,t){return[t-1]}),eq:he(function(e,t,n){return[n<0?n+t:n]}),even:he(function(e,t){for(var n=0;n<t;n+=2)e.push(n);return e}),odd:he(function(e,t){for(var n=1;n<t;n+=2)e.push(n);return e}),lt:he(function(e,t,n){for(var r=n<0?n+t:n;--r>=0;)e.push(r);return e}),gt:he(function(e,t,n){for(var r=n<0?n+t:n;++r<t;)e.push(r);return e})}}).pseudos.nth=r.pseudos.eq;for(t in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})r.pseudos[t]=fe(t);for(t in{submit:!0,reset:!0})r.pseudos[t]=pe(t);function ye(){}ye.prototype=r.filters=r.pseudos,r.setFilters=new ye,a=oe.tokenize=function(e,t){var n,i,o,a,s,u,l,c=k[e+" "];if(c)return t?0:c.slice(0);s=e,u=[],l=r.preFilter;while(s){n&&!(i=F.exec(s))||(i&&(s=s.slice(i[0].length)||s),u.push(o=[])),n=!1,(i=_.exec(s))&&(n=i.shift(),o.push({value:n,type:i[0].replace(B," ")}),s=s.slice(n.length));for(a in r.filter)!(i=V[a].exec(s))||l[a]&&!(i=l[a](i))||(n=i.shift(),o.push({value:n,type:a,matches:i}),s=s.slice(n.length));if(!n)break}return t?s.length:s?oe.error(e):k(e,u).slice(0)};function ve(e){for(var t=0,n=e.length,r="";t<n;t++)r+=e[t].value;return r}function me(e,t,n){var r=t.dir,i=t.next,o=i||r,a=n&&"parentNode"===o,s=C++;return t.first?function(t,n,i){while(t=t[r])if(1===t.nodeType||a)return e(t,n,i);return!1}:function(t,n,u){var l,c,f,p=[T,s];if(u){while(t=t[r])if((1===t.nodeType||a)&&e(t,n,u))return!0}else while(t=t[r])if(1===t.nodeType||a)if(f=t[b]||(t[b]={}),c=f[t.uniqueID]||(f[t.uniqueID]={}),i&&i===t.nodeName.toLowerCase())t=t[r]||t;else{if((l=c[o])&&l[0]===T&&l[1]===s)return p[2]=l[2];if(c[o]=p,p[2]=e(t,n,u))return!0}return!1}}function xe(e){return e.length>1?function(t,n,r){var i=e.length;while(i--)if(!e[i](t,n,r))return!1;return!0}:e[0]}function be(e,t,n){for(var r=0,i=t.length;r<i;r++)oe(e,t[r],n);return n}function we(e,t,n,r,i){for(var o,a=[],s=0,u=e.length,l=null!=t;s<u;s++)(o=e[s])&&(n&&!n(o,r,i)||(a.push(o),l&&t.push(s)));return a}function Te(e,t,n,r,i,o){return r&&!r[b]&&(r=Te(r)),i&&!i[b]&&(i=Te(i,o)),se(function(o,a,s,u){var l,c,f,p=[],d=[],h=a.length,g=o||be(t||"*",s.nodeType?[s]:s,[]),y=!e||!o&&t?g:we(g,p,e,s,u),v=n?i||(o?e:h||r)?[]:a:y;if(n&&n(y,v,s,u),r){l=we(v,d),r(l,[],s,u),c=l.length;while(c--)(f=l[c])&&(v[d[c]]=!(y[d[c]]=f))}if(o){if(i||e){if(i){l=[],c=v.length;while(c--)(f=v[c])&&l.push(y[c]=f);i(null,v=[],l,u)}c=v.length;while(c--)(f=v[c])&&(l=i?O(o,f):p[c])>-1&&(o[l]=!(a[l]=f))}}else v=we(v===a?v.splice(h,v.length):v),i?i(null,a,v,u):L.apply(a,v)})}function Ce(e){for(var t,n,i,o=e.length,a=r.relative[e[0].type],s=a||r.relative[" "],u=a?1:0,c=me(function(e){return e===t},s,!0),f=me(function(e){return O(t,e)>-1},s,!0),p=[function(e,n,r){var i=!a&&(r||n!==l)||((t=n).nodeType?c(e,n,r):f(e,n,r));return t=null,i}];u<o;u++)if(n=r.relative[e[u].type])p=[me(xe(p),n)];else{if((n=r.filter[e[u].type].apply(null,e[u].matches))[b]){for(i=++u;i<o;i++)if(r.relative[e[i].type])break;return Te(u>1&&xe(p),u>1&&ve(e.slice(0,u-1).concat({value:" "===e[u-2].type?"*":""})).replace(B,"$1"),n,u<i&&Ce(e.slice(u,i)),i<o&&Ce(e=e.slice(i)),i<o&&ve(e))}p.push(n)}return xe(p)}function Ee(e,t){var n=t.length>0,i=e.length>0,o=function(o,a,s,u,c){var f,h,y,v=0,m="0",x=o&&[],b=[],w=l,C=o||i&&r.find.TAG("*",c),E=T+=null==w?1:Math.random()||.1,k=C.length;for(c&&(l=a===d||a||c);m!==k&&null!=(f=C[m]);m++){if(i&&f){h=0,a||f.ownerDocument===d||(p(f),s=!g);while(y=e[h++])if(y(f,a||d,s)){u.push(f);break}c&&(T=E)}n&&((f=!y&&f)&&v--,o&&x.push(f))}if(v+=m,n&&m!==v){h=0;while(y=t[h++])y(x,b,a,s);if(o){if(v>0)while(m--)x[m]||b[m]||(b[m]=j.call(u));b=we(b)}L.apply(u,b),c&&!o&&b.length>0&&v+t.length>1&&oe.uniqueSort(u)}return c&&(T=E,l=w),x};return n?se(o):o}return s=oe.compile=function(e,t){var n,r=[],i=[],o=S[e+" "];if(!o){t||(t=a(e)),n=t.length;while(n--)(o=Ce(t[n]))[b]?r.push(o):i.push(o);(o=S(e,Ee(i,r))).selector=e}return o},u=oe.select=function(e,t,n,i){var o,u,l,c,f,p="function"==typeof e&&e,d=!i&&a(e=p.selector||e);if(n=n||[],1===d.length){if((u=d[0]=d[0].slice(0)).length>2&&"ID"===(l=u[0]).type&&9===t.nodeType&&g&&r.relative[u[1].type]){if(!(t=(r.find.ID(l.matches[0].replace(Z,ee),t)||[])[0]))return n;p&&(t=t.parentNode),e=e.slice(u.shift().value.length)}o=V.needsContext.test(e)?0:u.length;while(o--){if(l=u[o],r.relative[c=l.type])break;if((f=r.find[c])&&(i=f(l.matches[0].replace(Z,ee),K.test(u[0].type)&&ge(t.parentNode)||t))){if(u.splice(o,1),!(e=i.length&&ve(u)))return L.apply(n,i),n;break}}}return(p||s(e,d))(i,t,!g,n,!t||K.test(e)&&ge(t.parentNode)||t),n},n.sortStable=b.split("").sort(D).join("")===b,n.detectDuplicates=!!f,p(),n.sortDetached=ue(function(e){return 1&e.compareDocumentPosition(d.createElement("fieldset"))}),ue(function(e){return e.innerHTML="<a href='#'></a>","#"===e.firstChild.getAttribute("href")})||le("type|href|height|width",function(e,t,n){if(!n)return e.getAttribute(t,"type"===t.toLowerCase()?1:2)}),n.attributes&&ue(function(e){return e.innerHTML="<input/>",e.firstChild.setAttribute("value",""),""===e.firstChild.getAttribute("value")})||le("value",function(e,t,n){if(!n&&"input"===e.nodeName.toLowerCase())return e.defaultValue}),ue(function(e){return null==e.getAttribute("disabled")})||le(P,function(e,t,n){var r;if(!n)return!0===e[t]?t.toLowerCase():(r=e.getAttributeNode(t))&&r.specified?r.value:null}),oe}(e);w.find=E,w.expr=E.selectors,w.expr[":"]=w.expr.pseudos,w.uniqueSort=w.unique=E.uniqueSort,w.text=E.getText,w.isXMLDoc=E.isXML,w.contains=E.contains,w.escapeSelector=E.escape;var k=function(e,t,n){var r=[],i=void 0!==n;while((e=e[t])&&9!==e.nodeType)if(1===e.nodeType){if(i&&w(e).is(n))break;r.push(e)}return r},S=function(e,t){for(var n=[];e;e=e.nextSibling)1===e.nodeType&&e!==t&&n.push(e);return n},D=w.expr.match.needsContext;function N(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()}var A=/^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function j(e,t,n){return g(t)?w.grep(e,function(e,r){return!!t.call(e,r,e)!==n}):t.nodeType?w.grep(e,function(e){return e===t!==n}):"string"!=typeof t?w.grep(e,function(e){return u.call(t,e)>-1!==n}):w.filter(t,e,n)}w.filter=function(e,t,n){var r=t[0];return n&&(e=":not("+e+")"),1===t.length&&1===r.nodeType?w.find.matchesSelector(r,e)?[r]:[]:w.find.matches(e,w.grep(t,function(e){return 1===e.nodeType}))},w.fn.extend({find:function(e){var t,n,r=this.length,i=this;if("string"!=typeof e)return this.pushStack(w(e).filter(function(){for(t=0;t<r;t++)if(w.contains(i[t],this))return!0}));for(n=this.pushStack([]),t=0;t<r;t++)w.find(e,i[t],n);return r>1?w.uniqueSort(n):n},filter:function(e){return this.pushStack(j(this,e||[],!1))},not:function(e){return this.pushStack(j(this,e||[],!0))},is:function(e){return!!j(this,"string"==typeof e&&D.test(e)?w(e):e||[],!1).length}});var q,L=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/;(w.fn.init=function(e,t,n){var i,o;if(!e)return this;if(n=n||q,"string"==typeof e){if(!(i="<"===e[0]&&">"===e[e.length-1]&&e.length>=3?[null,e,null]:L.exec(e))||!i[1]&&t)return!t||t.jquery?(t||n).find(e):this.constructor(t).find(e);if(i[1]){if(t=t instanceof w?t[0]:t,w.merge(this,w.parseHTML(i[1],t&&t.nodeType?t.ownerDocument||t:r,!0)),A.test(i[1])&&w.isPlainObject(t))for(i in t)g(this[i])?this[i](t[i]):this.attr(i,t[i]);return this}return(o=r.getElementById(i[2]))&&(this[0]=o,this.length=1),this}return e.nodeType?(this[0]=e,this.length=1,this):g(e)?void 0!==n.ready?n.ready(e):e(w):w.makeArray(e,this)}).prototype=w.fn,q=w(r);var H=/^(?:parents|prev(?:Until|All))/,O={children:!0,contents:!0,next:!0,prev:!0};w.fn.extend({has:function(e){var t=w(e,this),n=t.length;return this.filter(function(){for(var e=0;e<n;e++)if(w.contains(this,t[e]))return!0})},closest:function(e,t){var n,r=0,i=this.length,o=[],a="string"!=typeof e&&w(e);if(!D.test(e))for(;r<i;r++)for(n=this[r];n&&n!==t;n=n.parentNode)if(n.nodeType<11&&(a?a.index(n)>-1:1===n.nodeType&&w.find.matchesSelector(n,e))){o.push(n);break}return this.pushStack(o.length>1?w.uniqueSort(o):o)},index:function(e){return e?"string"==typeof e?u.call(w(e),this[0]):u.call(this,e.jquery?e[0]:e):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(e,t){return this.pushStack(w.uniqueSort(w.merge(this.get(),w(e,t))))},addBack:function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}});function P(e,t){while((e=e[t])&&1!==e.nodeType);return e}w.each({parent:function(e){var t=e.parentNode;return t&&11!==t.nodeType?t:null},parents:function(e){return k(e,"parentNode")},parentsUntil:function(e,t,n){return k(e,"parentNode",n)},next:function(e){return P(e,"nextSibling")},prev:function(e){return P(e,"previousSibling")},nextAll:function(e){return k(e,"nextSibling")},prevAll:function(e){return k(e,"previousSibling")},nextUntil:function(e,t,n){return k(e,"nextSibling",n)},prevUntil:function(e,t,n){return k(e,"previousSibling",n)},siblings:function(e){return S((e.parentNode||{}).firstChild,e)},children:function(e){return S(e.firstChild)},contents:function(e){return N(e,"iframe")?e.contentDocument:(N(e,"template")&&(e=e.content||e),w.merge([],e.childNodes))}},function(e,t){w.fn[e]=function(n,r){var i=w.map(this,t,n);return"Until"!==e.slice(-5)&&(r=n),r&&"string"==typeof r&&(i=w.filter(r,i)),this.length>1&&(O[e]||w.uniqueSort(i),H.test(e)&&i.reverse()),this.pushStack(i)}});var M=/[^\x20\t\r\n\f]+/g;function R(e){var t={};return w.each(e.match(M)||[],function(e,n){t[n]=!0}),t}w.Callbacks=function(e){e="string"==typeof e?R(e):w.extend({},e);var t,n,r,i,o=[],a=[],s=-1,u=function(){for(i=i||e.once,r=t=!0;a.length;s=-1){n=a.shift();while(++s<o.length)!1===o[s].apply(n[0],n[1])&&e.stopOnFalse&&(s=o.length,n=!1)}e.memory||(n=!1),t=!1,i&&(o=n?[]:"")},l={add:function(){return o&&(n&&!t&&(s=o.length-1,a.push(n)),function t(n){w.each(n,function(n,r){g(r)?e.unique&&l.has(r)||o.push(r):r&&r.length&&"string"!==x(r)&&t(r)})}(arguments),n&&!t&&u()),this},remove:function(){return w.each(arguments,function(e,t){var n;while((n=w.inArray(t,o,n))>-1)o.splice(n,1),n<=s&&s--}),this},has:function(e){return e?w.inArray(e,o)>-1:o.length>0},empty:function(){return o&&(o=[]),this},disable:function(){return i=a=[],o=n="",this},disabled:function(){return!o},lock:function(){return i=a=[],n||t||(o=n=""),this},locked:function(){return!!i},fireWith:function(e,n){return i||(n=[e,(n=n||[]).slice?n.slice():n],a.push(n),t||u()),this},fire:function(){return l.fireWith(this,arguments),this},fired:function(){return!!r}};return l};function I(e){return e}function W(e){throw e}function $(e,t,n,r){var i;try{e&&g(i=e.promise)?i.call(e).done(t).fail(n):e&&g(i=e.then)?i.call(e,t,n):t.apply(void 0,[e].slice(r))}catch(e){n.apply(void 0,[e])}}w.extend({Deferred:function(t){var n=[["notify","progress",w.Callbacks("memory"),w.Callbacks("memory"),2],["resolve","done",w.Callbacks("once memory"),w.Callbacks("once memory"),0,"resolved"],["reject","fail",w.Callbacks("once memory"),w.Callbacks("once memory"),1,"rejected"]],r="pending",i={state:function(){return r},always:function(){return o.done(arguments).fail(arguments),this},"catch":function(e){return i.then(null,e)},pipe:function(){var e=arguments;return w.Deferred(function(t){w.each(n,function(n,r){var i=g(e[r[4]])&&e[r[4]];o[r[1]](function(){var e=i&&i.apply(this,arguments);e&&g(e.promise)?e.promise().progress(t.notify).done(t.resolve).fail(t.reject):t[r[0]+"With"](this,i?[e]:arguments)})}),e=null}).promise()},then:function(t,r,i){var o=0;function a(t,n,r,i){return function(){var s=this,u=arguments,l=function(){var e,l;if(!(t<o)){if((e=r.apply(s,u))===n.promise())throw new TypeError("Thenable self-resolution");l=e&&("object"==typeof e||"function"==typeof e)&&e.then,g(l)?i?l.call(e,a(o,n,I,i),a(o,n,W,i)):(o++,l.call(e,a(o,n,I,i),a(o,n,W,i),a(o,n,I,n.notifyWith))):(r!==I&&(s=void 0,u=[e]),(i||n.resolveWith)(s,u))}},c=i?l:function(){try{l()}catch(e){w.Deferred.exceptionHook&&w.Deferred.exceptionHook(e,c.stackTrace),t+1>=o&&(r!==W&&(s=void 0,u=[e]),n.rejectWith(s,u))}};t?c():(w.Deferred.getStackHook&&(c.stackTrace=w.Deferred.getStackHook()),e.setTimeout(c))}}return w.Deferred(function(e){n[0][3].add(a(0,e,g(i)?i:I,e.notifyWith)),n[1][3].add(a(0,e,g(t)?t:I)),n[2][3].add(a(0,e,g(r)?r:W))}).promise()},promise:function(e){return null!=e?w.extend(e,i):i}},o={};return w.each(n,function(e,t){var a=t[2],s=t[5];i[t[1]]=a.add,s&&a.add(function(){r=s},n[3-e][2].disable,n[3-e][3].disable,n[0][2].lock,n[0][3].lock),a.add(t[3].fire),o[t[0]]=function(){return o[t[0]+"With"](this===o?void 0:this,arguments),this},o[t[0]+"With"]=a.fireWith}),i.promise(o),t&&t.call(o,o),o},when:function(e){var t=arguments.length,n=t,r=Array(n),i=o.call(arguments),a=w.Deferred(),s=function(e){return function(n){r[e]=this,i[e]=arguments.length>1?o.call(arguments):n,--t||a.resolveWith(r,i)}};if(t<=1&&($(e,a.done(s(n)).resolve,a.reject,!t),"pending"===a.state()||g(i[n]&&i[n].then)))return a.then();while(n--)$(i[n],s(n),a.reject);return a.promise()}});var B=/^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;w.Deferred.exceptionHook=function(t,n){e.console&&e.console.warn&&t&&B.test(t.name)&&e.console.warn("jQuery.Deferred exception: "+t.message,t.stack,n)},w.readyException=function(t){e.setTimeout(function(){throw t})};var F=w.Deferred();w.fn.ready=function(e){return F.then(e)["catch"](function(e){w.readyException(e)}),this},w.extend({isReady:!1,readyWait:1,ready:function(e){(!0===e?--w.readyWait:w.isReady)||(w.isReady=!0,!0!==e&&--w.readyWait>0||F.resolveWith(r,[w]))}}),w.ready.then=F.then;function _(){r.removeEventListener("DOMContentLoaded",_),e.removeEventListener("load",_),w.ready()}"complete"===r.readyState||"loading"!==r.readyState&&!r.documentElement.doScroll?e.setTimeout(w.ready):(r.addEventListener("DOMContentLoaded",_),e.addEventListener("load",_));var z=function(e,t,n,r,i,o,a){var s=0,u=e.length,l=null==n;if("object"===x(n)){i=!0;for(s in n)z(e,t,s,n[s],!0,o,a)}else if(void 0!==r&&(i=!0,g(r)||(a=!0),l&&(a?(t.call(e,r),t=null):(l=t,t=function(e,t,n){return l.call(w(e),n)})),t))for(;s<u;s++)t(e[s],n,a?r:r.call(e[s],s,t(e[s],n)));return i?e:l?t.call(e):u?t(e[0],n):o},X=/^-ms-/,U=/-([a-z])/g;function V(e,t){return t.toUpperCase()}function G(e){return e.replace(X,"ms-").replace(U,V)}var Y=function(e){return 1===e.nodeType||9===e.nodeType||!+e.nodeType};function Q(){this.expando=w.expando+Q.uid++}Q.uid=1,Q.prototype={cache:function(e){var t=e[this.expando];return t||(t={},Y(e)&&(e.nodeType?e[this.expando]=t:Object.defineProperty(e,this.expando,{value:t,configurable:!0}))),t},set:function(e,t,n){var r,i=this.cache(e);if("string"==typeof t)i[G(t)]=n;else for(r in t)i[G(r)]=t[r];return i},get:function(e,t){return void 0===t?this.cache(e):e[this.expando]&&e[this.expando][G(t)]},access:function(e,t,n){return void 0===t||t&&"string"==typeof t&&void 0===n?this.get(e,t):(this.set(e,t,n),void 0!==n?n:t)},remove:function(e,t){var n,r=e[this.expando];if(void 0!==r){if(void 0!==t){n=(t=Array.isArray(t)?t.map(G):(t=G(t))in r?[t]:t.match(M)||[]).length;while(n--)delete r[t[n]]}(void 0===t||w.isEmptyObject(r))&&(e.nodeType?e[this.expando]=void 0:delete e[this.expando])}},hasData:function(e){var t=e[this.expando];return void 0!==t&&!w.isEmptyObject(t)}};var J=new Q,K=new Q,Z=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,ee=/[A-Z]/g;function te(e){return"true"===e||"false"!==e&&("null"===e?null:e===+e+""?+e:Z.test(e)?JSON.parse(e):e)}function ne(e,t,n){var r;if(void 0===n&&1===e.nodeType)if(r="data-"+t.replace(ee,"-$&").toLowerCase(),"string"==typeof(n=e.getAttribute(r))){try{n=te(n)}catch(e){}K.set(e,t,n)}else n=void 0;return n}w.extend({hasData:function(e){return K.hasData(e)||J.hasData(e)},data:function(e,t,n){return K.access(e,t,n)},removeData:function(e,t){K.remove(e,t)},_data:function(e,t,n){return J.access(e,t,n)},_removeData:function(e,t){J.remove(e,t)}}),w.fn.extend({data:function(e,t){var n,r,i,o=this[0],a=o&&o.attributes;if(void 0===e){if(this.length&&(i=K.get(o),1===o.nodeType&&!J.get(o,"hasDataAttrs"))){n=a.length;while(n--)a[n]&&0===(r=a[n].name).indexOf("data-")&&(r=G(r.slice(5)),ne(o,r,i[r]));J.set(o,"hasDataAttrs",!0)}return i}return"object"==typeof e?this.each(function(){K.set(this,e)}):z(this,function(t){var n;if(o&&void 0===t){if(void 0!==(n=K.get(o,e)))return n;if(void 0!==(n=ne(o,e)))return n}else this.each(function(){K.set(this,e,t)})},null,t,arguments.length>1,null,!0)},removeData:function(e){return this.each(function(){K.remove(this,e)})}}),w.extend({queue:function(e,t,n){var r;if(e)return t=(t||"fx")+"queue",r=J.get(e,t),n&&(!r||Array.isArray(n)?r=J.access(e,t,w.makeArray(n)):r.push(n)),r||[]},dequeue:function(e,t){t=t||"fx";var n=w.queue(e,t),r=n.length,i=n.shift(),o=w._queueHooks(e,t),a=function(){w.dequeue(e,t)};"inprogress"===i&&(i=n.shift(),r--),i&&("fx"===t&&n.unshift("inprogress"),delete o.stop,i.call(e,a,o)),!r&&o&&o.empty.fire()},_queueHooks:function(e,t){var n=t+"queueHooks";return J.get(e,n)||J.access(e,n,{empty:w.Callbacks("once memory").add(function(){J.remove(e,[t+"queue",n])})})}}),w.fn.extend({queue:function(e,t){var n=2;return"string"!=typeof e&&(t=e,e="fx",n--),arguments.length<n?w.queue(this[0],e):void 0===t?this:this.each(function(){var n=w.queue(this,e,t);w._queueHooks(this,e),"fx"===e&&"inprogress"!==n[0]&&w.dequeue(this,e)})},dequeue:function(e){return this.each(function(){w.dequeue(this,e)})},clearQueue:function(e){return this.queue(e||"fx",[])},promise:function(e,t){var n,r=1,i=w.Deferred(),o=this,a=this.length,s=function(){--r||i.resolveWith(o,[o])};"string"!=typeof e&&(t=e,e=void 0),e=e||"fx";while(a--)(n=J.get(o[a],e+"queueHooks"))&&n.empty&&(r++,n.empty.add(s));return s(),i.promise(t)}});var re=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,ie=new RegExp("^(?:([+-])=|)("+re+")([a-z%]*)$","i"),oe=["Top","Right","Bottom","Left"],ae=function(e,t){return"none"===(e=t||e).style.display||""===e.style.display&&w.contains(e.ownerDocument,e)&&"none"===w.css(e,"display")},se=function(e,t,n,r){var i,o,a={};for(o in t)a[o]=e.style[o],e.style[o]=t[o];i=n.apply(e,r||[]);for(o in t)e.style[o]=a[o];return i};function ue(e,t,n,r){var i,o,a=20,s=r?function(){return r.cur()}:function(){return w.css(e,t,"")},u=s(),l=n&&n[3]||(w.cssNumber[t]?"":"px"),c=(w.cssNumber[t]||"px"!==l&&+u)&&ie.exec(w.css(e,t));if(c&&c[3]!==l){u/=2,l=l||c[3],c=+u||1;while(a--)w.style(e,t,c+l),(1-o)*(1-(o=s()/u||.5))<=0&&(a=0),c/=o;c*=2,w.style(e,t,c+l),n=n||[]}return n&&(c=+c||+u||0,i=n[1]?c+(n[1]+1)*n[2]:+n[2],r&&(r.unit=l,r.start=c,r.end=i)),i}var le={};function ce(e){var t,n=e.ownerDocument,r=e.nodeName,i=le[r];return i||(t=n.body.appendChild(n.createElement(r)),i=w.css(t,"display"),t.parentNode.removeChild(t),"none"===i&&(i="block"),le[r]=i,i)}function fe(e,t){for(var n,r,i=[],o=0,a=e.length;o<a;o++)(r=e[o]).style&&(n=r.style.display,t?("none"===n&&(i[o]=J.get(r,"display")||null,i[o]||(r.style.display="")),""===r.style.display&&ae(r)&&(i[o]=ce(r))):"none"!==n&&(i[o]="none",J.set(r,"display",n)));for(o=0;o<a;o++)null!=i[o]&&(e[o].style.display=i[o]);return e}w.fn.extend({show:function(){return fe(this,!0)},hide:function(){return fe(this)},toggle:function(e){return"boolean"==typeof e?e?this.show():this.hide():this.each(function(){ae(this)?w(this).show():w(this).hide()})}});var pe=/^(?:checkbox|radio)$/i,de=/<([a-z][^\/\0>\x20\t\r\n\f]+)/i,he=/^$|^module$|\/(?:java|ecma)script/i,ge={option:[1,"<select multiple='multiple'>","</select>"],thead:[1,"<table>","</table>"],col:[2,"<table><colgroup>","</colgroup></table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],_default:[0,"",""]};ge.optgroup=ge.option,ge.tbody=ge.tfoot=ge.colgroup=ge.caption=ge.thead,ge.th=ge.td;function ye(e,t){var n;return n="undefined"!=typeof e.getElementsByTagName?e.getElementsByTagName(t||"*"):"undefined"!=typeof e.querySelectorAll?e.querySelectorAll(t||"*"):[],void 0===t||t&&N(e,t)?w.merge([e],n):n}function ve(e,t){for(var n=0,r=e.length;n<r;n++)J.set(e[n],"globalEval",!t||J.get(t[n],"globalEval"))}var me=/<|&#?\w+;/;function xe(e,t,n,r,i){for(var o,a,s,u,l,c,f=t.createDocumentFragment(),p=[],d=0,h=e.length;d<h;d++)if((o=e[d])||0===o)if("object"===x(o))w.merge(p,o.nodeType?[o]:o);else if(me.test(o)){a=a||f.appendChild(t.createElement("div")),s=(de.exec(o)||["",""])[1].toLowerCase(),u=ge[s]||ge._default,a.innerHTML=u[1]+w.htmlPrefilter(o)+u[2],c=u[0];while(c--)a=a.lastChild;w.merge(p,a.childNodes),(a=f.firstChild).textContent=""}else p.push(t.createTextNode(o));f.textContent="",d=0;while(o=p[d++])if(r&&w.inArray(o,r)>-1)i&&i.push(o);else if(l=w.contains(o.ownerDocument,o),a=ye(f.appendChild(o),"script"),l&&ve(a),n){c=0;while(o=a[c++])he.test(o.type||"")&&n.push(o)}return f}!function(){var e=r.createDocumentFragment().appendChild(r.createElement("div")),t=r.createElement("input");t.setAttribute("type","radio"),t.setAttribute("checked","checked"),t.setAttribute("name","t"),e.appendChild(t),h.checkClone=e.cloneNode(!0).cloneNode(!0).lastChild.checked,e.innerHTML="<textarea>x</textarea>",h.noCloneChecked=!!e.cloneNode(!0).lastChild.defaultValue}();var be=r.documentElement,we=/^key/,Te=/^(?:mouse|pointer|contextmenu|drag|drop)|click/,Ce=/^([^.]*)(?:\.(.+)|)/;function Ee(){return!0}function ke(){return!1}function Se(){try{return r.activeElement}catch(e){}}function De(e,t,n,r,i,o){var a,s;if("object"==typeof t){"string"!=typeof n&&(r=r||n,n=void 0);for(s in t)De(e,s,n,r,t[s],o);return e}if(null==r&&null==i?(i=n,r=n=void 0):null==i&&("string"==typeof n?(i=r,r=void 0):(i=r,r=n,n=void 0)),!1===i)i=ke;else if(!i)return e;return 1===o&&(a=i,(i=function(e){return w().off(e),a.apply(this,arguments)}).guid=a.guid||(a.guid=w.guid++)),e.each(function(){w.event.add(this,t,i,r,n)})}w.event={global:{},add:function(e,t,n,r,i){var o,a,s,u,l,c,f,p,d,h,g,y=J.get(e);if(y){n.handler&&(n=(o=n).handler,i=o.selector),i&&w.find.matchesSelector(be,i),n.guid||(n.guid=w.guid++),(u=y.events)||(u=y.events={}),(a=y.handle)||(a=y.handle=function(t){return"undefined"!=typeof w&&w.event.triggered!==t.type?w.event.dispatch.apply(e,arguments):void 0}),l=(t=(t||"").match(M)||[""]).length;while(l--)d=g=(s=Ce.exec(t[l])||[])[1],h=(s[2]||"").split(".").sort(),d&&(f=w.event.special[d]||{},d=(i?f.delegateType:f.bindType)||d,f=w.event.special[d]||{},c=w.extend({type:d,origType:g,data:r,handler:n,guid:n.guid,selector:i,needsContext:i&&w.expr.match.needsContext.test(i),namespace:h.join(".")},o),(p=u[d])||((p=u[d]=[]).delegateCount=0,f.setup&&!1!==f.setup.call(e,r,h,a)||e.addEventListener&&e.addEventListener(d,a)),f.add&&(f.add.call(e,c),c.handler.guid||(c.handler.guid=n.guid)),i?p.splice(p.delegateCount++,0,c):p.push(c),w.event.global[d]=!0)}},remove:function(e,t,n,r,i){var o,a,s,u,l,c,f,p,d,h,g,y=J.hasData(e)&&J.get(e);if(y&&(u=y.events)){l=(t=(t||"").match(M)||[""]).length;while(l--)if(s=Ce.exec(t[l])||[],d=g=s[1],h=(s[2]||"").split(".").sort(),d){f=w.event.special[d]||{},p=u[d=(r?f.delegateType:f.bindType)||d]||[],s=s[2]&&new RegExp("(^|\\.)"+h.join("\\.(?:.*\\.|)")+"(\\.|$)"),a=o=p.length;while(o--)c=p[o],!i&&g!==c.origType||n&&n.guid!==c.guid||s&&!s.test(c.namespace)||r&&r!==c.selector&&("**"!==r||!c.selector)||(p.splice(o,1),c.selector&&p.delegateCount--,f.remove&&f.remove.call(e,c));a&&!p.length&&(f.teardown&&!1!==f.teardown.call(e,h,y.handle)||w.removeEvent(e,d,y.handle),delete u[d])}else for(d in u)w.event.remove(e,d+t[l],n,r,!0);w.isEmptyObject(u)&&J.remove(e,"handle events")}},dispatch:function(e){var t=w.event.fix(e),n,r,i,o,a,s,u=new Array(arguments.length),l=(J.get(this,"events")||{})[t.type]||[],c=w.event.special[t.type]||{};for(u[0]=t,n=1;n<arguments.length;n++)u[n]=arguments[n];if(t.delegateTarget=this,!c.preDispatch||!1!==c.preDispatch.call(this,t)){s=w.event.handlers.call(this,t,l),n=0;while((o=s[n++])&&!t.isPropagationStopped()){t.currentTarget=o.elem,r=0;while((a=o.handlers[r++])&&!t.isImmediatePropagationStopped())t.rnamespace&&!t.rnamespace.test(a.namespace)||(t.handleObj=a,t.data=a.data,void 0!==(i=((w.event.special[a.origType]||{}).handle||a.handler).apply(o.elem,u))&&!1===(t.result=i)&&(t.preventDefault(),t.stopPropagation()))}return c.postDispatch&&c.postDispatch.call(this,t),t.result}},handlers:function(e,t){var n,r,i,o,a,s=[],u=t.delegateCount,l=e.target;if(u&&l.nodeType&&!("click"===e.type&&e.button>=1))for(;l!==this;l=l.parentNode||this)if(1===l.nodeType&&("click"!==e.type||!0!==l.disabled)){for(o=[],a={},n=0;n<u;n++)void 0===a[i=(r=t[n]).selector+" "]&&(a[i]=r.needsContext?w(i,this).index(l)>-1:w.find(i,this,null,[l]).length),a[i]&&o.push(r);o.length&&s.push({elem:l,handlers:o})}return l=this,u<t.length&&s.push({elem:l,handlers:t.slice(u)}),s},addProp:function(e,t){Object.defineProperty(w.Event.prototype,e,{enumerable:!0,configurable:!0,get:g(t)?function(){if(this.originalEvent)return t(this.originalEvent)}:function(){if(this.originalEvent)return this.originalEvent[e]},set:function(t){Object.defineProperty(this,e,{enumerable:!0,configurable:!0,writable:!0,value:t})}})},fix:function(e){return e[w.expando]?e:new w.Event(e)},special:{load:{noBubble:!0},focus:{trigger:function(){if(this!==Se()&&this.focus)return this.focus(),!1},delegateType:"focusin"},blur:{trigger:function(){if(this===Se()&&this.blur)return this.blur(),!1},delegateType:"focusout"},click:{trigger:function(){if("checkbox"===this.type&&this.click&&N(this,"input"))return this.click(),!1},_default:function(e){return N(e.target,"a")}},beforeunload:{postDispatch:function(e){void 0!==e.result&&e.originalEvent&&(e.originalEvent.returnValue=e.result)}}}},w.removeEvent=function(e,t,n){e.removeEventListener&&e.removeEventListener(t,n)},w.Event=function(e,t){if(!(this instanceof w.Event))return new w.Event(e,t);e&&e.type?(this.originalEvent=e,this.type=e.type,this.isDefaultPrevented=e.defaultPrevented||void 0===e.defaultPrevented&&!1===e.returnValue?Ee:ke,this.target=e.target&&3===e.target.nodeType?e.target.parentNode:e.target,this.currentTarget=e.currentTarget,this.relatedTarget=e.relatedTarget):this.type=e,t&&w.extend(this,t),this.timeStamp=e&&e.timeStamp||Date.now(),this[w.expando]=!0},w.Event.prototype={constructor:w.Event,isDefaultPrevented:ke,isPropagationStopped:ke,isImmediatePropagationStopped:ke,isSimulated:!1,preventDefault:function(){var e=this.originalEvent;this.isDefaultPrevented=Ee,e&&!this.isSimulated&&e.preventDefault()},stopPropagation:function(){var e=this.originalEvent;this.isPropagationStopped=Ee,e&&!this.isSimulated&&e.stopPropagation()},stopImmediatePropagation:function(){var e=this.originalEvent;this.isImmediatePropagationStopped=Ee,e&&!this.isSimulated&&e.stopImmediatePropagation(),this.stopPropagation()}},w.each({altKey:!0,bubbles:!0,cancelable:!0,changedTouches:!0,ctrlKey:!0,detail:!0,eventPhase:!0,metaKey:!0,pageX:!0,pageY:!0,shiftKey:!0,view:!0,"char":!0,charCode:!0,key:!0,keyCode:!0,button:!0,buttons:!0,clientX:!0,clientY:!0,offsetX:!0,offsetY:!0,pointerId:!0,pointerType:!0,screenX:!0,screenY:!0,targetTouches:!0,toElement:!0,touches:!0,which:function(e){var t=e.button;return null==e.which&&we.test(e.type)?null!=e.charCode?e.charCode:e.keyCode:!e.which&&void 0!==t&&Te.test(e.type)?1&t?1:2&t?3:4&t?2:0:e.which}},w.event.addProp),w.each({mouseenter:"mouseover",mouseleave:"mouseout",pointerenter:"pointerover",pointerleave:"pointerout"},function(e,t){w.event.special[e]={delegateType:t,bindType:t,handle:function(e){var n,r=this,i=e.relatedTarget,o=e.handleObj;return i&&(i===r||w.contains(r,i))||(e.type=o.origType,n=o.handler.apply(this,arguments),e.type=t),n}}}),w.fn.extend({on:function(e,t,n,r){return De(this,e,t,n,r)},one:function(e,t,n,r){return De(this,e,t,n,r,1)},off:function(e,t,n){var r,i;if(e&&e.preventDefault&&e.handleObj)return r=e.handleObj,w(e.delegateTarget).off(r.namespace?r.origType+"."+r.namespace:r.origType,r.selector,r.handler),this;if("object"==typeof e){for(i in e)this.off(i,t,e[i]);return this}return!1!==t&&"function"!=typeof t||(n=t,t=void 0),!1===n&&(n=ke),this.each(function(){w.event.remove(this,e,n,t)})}});var Ne=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi,Ae=/<script|<style|<link/i,je=/checked\s*(?:[^=]|=\s*.checked.)/i,qe=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g;function Le(e,t){return N(e,"table")&&N(11!==t.nodeType?t:t.firstChild,"tr")?w(e).children("tbody")[0]||e:e}function He(e){return e.type=(null!==e.getAttribute("type"))+"/"+e.type,e}function Oe(e){return"true/"===(e.type||"").slice(0,5)?e.type=e.type.slice(5):e.removeAttribute("type"),e}function Pe(e,t){var n,r,i,o,a,s,u,l;if(1===t.nodeType){if(J.hasData(e)&&(o=J.access(e),a=J.set(t,o),l=o.events)){delete a.handle,a.events={};for(i in l)for(n=0,r=l[i].length;n<r;n++)w.event.add(t,i,l[i][n])}K.hasData(e)&&(s=K.access(e),u=w.extend({},s),K.set(t,u))}}function Me(e,t){var n=t.nodeName.toLowerCase();"input"===n&&pe.test(e.type)?t.checked=e.checked:"input"!==n&&"textarea"!==n||(t.defaultValue=e.defaultValue)}function Re(e,t,n,r){t=a.apply([],t);var i,o,s,u,l,c,f=0,p=e.length,d=p-1,y=t[0],v=g(y);if(v||p>1&&"string"==typeof y&&!h.checkClone&&je.test(y))return e.each(function(i){var o=e.eq(i);v&&(t[0]=y.call(this,i,o.html())),Re(o,t,n,r)});if(p&&(i=xe(t,e[0].ownerDocument,!1,e,r),o=i.firstChild,1===i.childNodes.length&&(i=o),o||r)){for(u=(s=w.map(ye(i,"script"),He)).length;f<p;f++)l=i,f!==d&&(l=w.clone(l,!0,!0),u&&w.merge(s,ye(l,"script"))),n.call(e[f],l,f);if(u)for(c=s[s.length-1].ownerDocument,w.map(s,Oe),f=0;f<u;f++)l=s[f],he.test(l.type||"")&&!J.access(l,"globalEval")&&w.contains(c,l)&&(l.src&&"module"!==(l.type||"").toLowerCase()?w._evalUrl&&w._evalUrl(l.src):m(l.textContent.replace(qe,""),c,l))}return e}function Ie(e,t,n){for(var r,i=t?w.filter(t,e):e,o=0;null!=(r=i[o]);o++)n||1!==r.nodeType||w.cleanData(ye(r)),r.parentNode&&(n&&w.contains(r.ownerDocument,r)&&ve(ye(r,"script")),r.parentNode.removeChild(r));return e}w.extend({htmlPrefilter:function(e){return e.replace(Ne,"<$1></$2>")},clone:function(e,t,n){var r,i,o,a,s=e.cloneNode(!0),u=w.contains(e.ownerDocument,e);if(!(h.noCloneChecked||1!==e.nodeType&&11!==e.nodeType||w.isXMLDoc(e)))for(a=ye(s),r=0,i=(o=ye(e)).length;r<i;r++)Me(o[r],a[r]);if(t)if(n)for(o=o||ye(e),a=a||ye(s),r=0,i=o.length;r<i;r++)Pe(o[r],a[r]);else Pe(e,s);return(a=ye(s,"script")).length>0&&ve(a,!u&&ye(e,"script")),s},cleanData:function(e){for(var t,n,r,i=w.event.special,o=0;void 0!==(n=e[o]);o++)if(Y(n)){if(t=n[J.expando]){if(t.events)for(r in t.events)i[r]?w.event.remove(n,r):w.removeEvent(n,r,t.handle);n[J.expando]=void 0}n[K.expando]&&(n[K.expando]=void 0)}}}),w.fn.extend({detach:function(e){return Ie(this,e,!0)},remove:function(e){return Ie(this,e)},text:function(e){return z(this,function(e){return void 0===e?w.text(this):this.empty().each(function(){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||(this.textContent=e)})},null,e,arguments.length)},append:function(){return Re(this,arguments,function(e){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||Le(this,e).appendChild(e)})},prepend:function(){return Re(this,arguments,function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=Le(this,e);t.insertBefore(e,t.firstChild)}})},before:function(){return Re(this,arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this)})},after:function(){return Re(this,arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)})},empty:function(){for(var e,t=0;null!=(e=this[t]);t++)1===e.nodeType&&(w.cleanData(ye(e,!1)),e.textContent="");return this},clone:function(e,t){return e=null!=e&&e,t=null==t?e:t,this.map(function(){return w.clone(this,e,t)})},html:function(e){return z(this,function(e){var t=this[0]||{},n=0,r=this.length;if(void 0===e&&1===t.nodeType)return t.innerHTML;if("string"==typeof e&&!Ae.test(e)&&!ge[(de.exec(e)||["",""])[1].toLowerCase()]){e=w.htmlPrefilter(e);try{for(;n<r;n++)1===(t=this[n]||{}).nodeType&&(w.cleanData(ye(t,!1)),t.innerHTML=e);t=0}catch(e){}}t&&this.empty().append(e)},null,e,arguments.length)},replaceWith:function(){var e=[];return Re(this,arguments,function(t){var n=this.parentNode;w.inArray(this,e)<0&&(w.cleanData(ye(this)),n&&n.replaceChild(t,this))},e)}}),w.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(e,t){w.fn[e]=function(e){for(var n,r=[],i=w(e),o=i.length-1,a=0;a<=o;a++)n=a===o?this:this.clone(!0),w(i[a])[t](n),s.apply(r,n.get());return this.pushStack(r)}});var We=new RegExp("^("+re+")(?!px)[a-z%]+$","i"),$e=function(t){var n=t.ownerDocument.defaultView;return n&&n.opener||(n=e),n.getComputedStyle(t)},Be=new RegExp(oe.join("|"),"i");!function(){function t(){if(c){l.style.cssText="position:absolute;left:-11111px;width:60px;margin-top:1px;padding:0;border:0",c.style.cssText="position:relative;display:block;box-sizing:border-box;overflow:scroll;margin:auto;border:1px;padding:1px;width:60%;top:1%",be.appendChild(l).appendChild(c);var t=e.getComputedStyle(c);i="1%"!==t.top,u=12===n(t.marginLeft),c.style.right="60%",s=36===n(t.right),o=36===n(t.width),c.style.position="absolute",a=36===c.offsetWidth||"absolute",be.removeChild(l),c=null}}function n(e){return Math.round(parseFloat(e))}var i,o,a,s,u,l=r.createElement("div"),c=r.createElement("div");c.style&&(c.style.backgroundClip="content-box",c.cloneNode(!0).style.backgroundClip="",h.clearCloneStyle="content-box"===c.style.backgroundClip,w.extend(h,{boxSizingReliable:function(){return t(),o},pixelBoxStyles:function(){return t(),s},pixelPosition:function(){return t(),i},reliableMarginLeft:function(){return t(),u},scrollboxSize:function(){return t(),a}}))}();function Fe(e,t,n){var r,i,o,a,s=e.style;return(n=n||$e(e))&&(""!==(a=n.getPropertyValue(t)||n[t])||w.contains(e.ownerDocument,e)||(a=w.style(e,t)),!h.pixelBoxStyles()&&We.test(a)&&Be.test(t)&&(r=s.width,i=s.minWidth,o=s.maxWidth,s.minWidth=s.maxWidth=s.width=a,a=n.width,s.width=r,s.minWidth=i,s.maxWidth=o)),void 0!==a?a+"":a}function _e(e,t){return{get:function(){if(!e())return(this.get=t).apply(this,arguments);delete this.get}}}var ze=/^(none|table(?!-c[ea]).+)/,Xe=/^--/,Ue={position:"absolute",visibility:"hidden",display:"block"},Ve={letterSpacing:"0",fontWeight:"400"},Ge=["Webkit","Moz","ms"],Ye=r.createElement("div").style;function Qe(e){if(e in Ye)return e;var t=e[0].toUpperCase()+e.slice(1),n=Ge.length;while(n--)if((e=Ge[n]+t)in Ye)return e}function Je(e){var t=w.cssProps[e];return t||(t=w.cssProps[e]=Qe(e)||e),t}function Ke(e,t,n){var r=ie.exec(t);return r?Math.max(0,r[2]-(n||0))+(r[3]||"px"):t}function Ze(e,t,n,r,i,o){var a="width"===t?1:0,s=0,u=0;if(n===(r?"border":"content"))return 0;for(;a<4;a+=2)"margin"===n&&(u+=w.css(e,n+oe[a],!0,i)),r?("content"===n&&(u-=w.css(e,"padding"+oe[a],!0,i)),"margin"!==n&&(u-=w.css(e,"border"+oe[a]+"Width",!0,i))):(u+=w.css(e,"padding"+oe[a],!0,i),"padding"!==n?u+=w.css(e,"border"+oe[a]+"Width",!0,i):s+=w.css(e,"border"+oe[a]+"Width",!0,i));return!r&&o>=0&&(u+=Math.max(0,Math.ceil(e["offset"+t[0].toUpperCase()+t.slice(1)]-o-u-s-.5))),u}function et(e,t,n){var r=$e(e),i=Fe(e,t,r),o="border-box"===w.css(e,"boxSizing",!1,r),a=o;if(We.test(i)){if(!n)return i;i="auto"}return a=a&&(h.boxSizingReliable()||i===e.style[t]),("auto"===i||!parseFloat(i)&&"inline"===w.css(e,"display",!1,r))&&(i=e["offset"+t[0].toUpperCase()+t.slice(1)],a=!0),(i=parseFloat(i)||0)+Ze(e,t,n||(o?"border":"content"),a,r,i)+"px"}w.extend({cssHooks:{opacity:{get:function(e,t){if(t){var n=Fe(e,"opacity");return""===n?"1":n}}}},cssNumber:{animationIterationCount:!0,columnCount:!0,fillOpacity:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{},style:function(e,t,n,r){if(e&&3!==e.nodeType&&8!==e.nodeType&&e.style){var i,o,a,s=G(t),u=Xe.test(t),l=e.style;if(u||(t=Je(s)),a=w.cssHooks[t]||w.cssHooks[s],void 0===n)return a&&"get"in a&&void 0!==(i=a.get(e,!1,r))?i:l[t];"string"==(o=typeof n)&&(i=ie.exec(n))&&i[1]&&(n=ue(e,t,i),o="number"),null!=n&&n===n&&("number"===o&&(n+=i&&i[3]||(w.cssNumber[s]?"":"px")),h.clearCloneStyle||""!==n||0!==t.indexOf("background")||(l[t]="inherit"),a&&"set"in a&&void 0===(n=a.set(e,n,r))||(u?l.setProperty(t,n):l[t]=n))}},css:function(e,t,n,r){var i,o,a,s=G(t);return Xe.test(t)||(t=Je(s)),(a=w.cssHooks[t]||w.cssHooks[s])&&"get"in a&&(i=a.get(e,!0,n)),void 0===i&&(i=Fe(e,t,r)),"normal"===i&&t in Ve&&(i=Ve[t]),""===n||n?(o=parseFloat(i),!0===n||isFinite(o)?o||0:i):i}}),w.each(["height","width"],function(e,t){w.cssHooks[t]={get:function(e,n,r){if(n)return!ze.test(w.css(e,"display"))||e.getClientRects().length&&e.getBoundingClientRect().width?et(e,t,r):se(e,Ue,function(){return et(e,t,r)})},set:function(e,n,r){var i,o=$e(e),a="border-box"===w.css(e,"boxSizing",!1,o),s=r&&Ze(e,t,r,a,o);return a&&h.scrollboxSize()===o.position&&(s-=Math.ceil(e["offset"+t[0].toUpperCase()+t.slice(1)]-parseFloat(o[t])-Ze(e,t,"border",!1,o)-.5)),s&&(i=ie.exec(n))&&"px"!==(i[3]||"px")&&(e.style[t]=n,n=w.css(e,t)),Ke(e,n,s)}}}),w.cssHooks.marginLeft=_e(h.reliableMarginLeft,function(e,t){if(t)return(parseFloat(Fe(e,"marginLeft"))||e.getBoundingClientRect().left-se(e,{marginLeft:0},function(){return e.getBoundingClientRect().left}))+"px"}),w.each({margin:"",padding:"",border:"Width"},function(e,t){w.cssHooks[e+t]={expand:function(n){for(var r=0,i={},o="string"==typeof n?n.split(" "):[n];r<4;r++)i[e+oe[r]+t]=o[r]||o[r-2]||o[0];return i}},"margin"!==e&&(w.cssHooks[e+t].set=Ke)}),w.fn.extend({css:function(e,t){return z(this,function(e,t,n){var r,i,o={},a=0;if(Array.isArray(t)){for(r=$e(e),i=t.length;a<i;a++)o[t[a]]=w.css(e,t[a],!1,r);return o}return void 0!==n?w.style(e,t,n):w.css(e,t)},e,t,arguments.length>1)}});function tt(e,t,n,r,i){return new tt.prototype.init(e,t,n,r,i)}w.Tween=tt,tt.prototype={constructor:tt,init:function(e,t,n,r,i,o){this.elem=e,this.prop=n,this.easing=i||w.easing._default,this.options=t,this.start=this.now=this.cur(),this.end=r,this.unit=o||(w.cssNumber[n]?"":"px")},cur:function(){var e=tt.propHooks[this.prop];return e&&e.get?e.get(this):tt.propHooks._default.get(this)},run:function(e){var t,n=tt.propHooks[this.prop];return this.options.duration?this.pos=t=w.easing[this.easing](e,this.options.duration*e,0,1,this.options.duration):this.pos=t=e,this.now=(this.end-this.start)*t+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),n&&n.set?n.set(this):tt.propHooks._default.set(this),this}},tt.prototype.init.prototype=tt.prototype,tt.propHooks={_default:{get:function(e){var t;return 1!==e.elem.nodeType||null!=e.elem[e.prop]&&null==e.elem.style[e.prop]?e.elem[e.prop]:(t=w.css(e.elem,e.prop,""))&&"auto"!==t?t:0},set:function(e){w.fx.step[e.prop]?w.fx.step[e.prop](e):1!==e.elem.nodeType||null==e.elem.style[w.cssProps[e.prop]]&&!w.cssHooks[e.prop]?e.elem[e.prop]=e.now:w.style(e.elem,e.prop,e.now+e.unit)}}},tt.propHooks.scrollTop=tt.propHooks.scrollLeft={set:function(e){e.elem.nodeType&&e.elem.parentNode&&(e.elem[e.prop]=e.now)}},w.easing={linear:function(e){return e},swing:function(e){return.5-Math.cos(e*Math.PI)/2},_default:"swing"},w.fx=tt.prototype.init,w.fx.step={};var nt,rt,it=/^(?:toggle|show|hide)$/,ot=/queueHooks$/;function at(){rt&&(!1===r.hidden&&e.requestAnimationFrame?e.requestAnimationFrame(at):e.setTimeout(at,w.fx.interval),w.fx.tick())}function st(){return e.setTimeout(function(){nt=void 0}),nt=Date.now()}function ut(e,t){var n,r=0,i={height:e};for(t=t?1:0;r<4;r+=2-t)i["margin"+(n=oe[r])]=i["padding"+n]=e;return t&&(i.opacity=i.width=e),i}function lt(e,t,n){for(var r,i=(pt.tweeners[t]||[]).concat(pt.tweeners["*"]),o=0,a=i.length;o<a;o++)if(r=i[o].call(n,t,e))return r}function ct(e,t,n){var r,i,o,a,s,u,l,c,f="width"in t||"height"in t,p=this,d={},h=e.style,g=e.nodeType&&ae(e),y=J.get(e,"fxshow");n.queue||(null==(a=w._queueHooks(e,"fx")).unqueued&&(a.unqueued=0,s=a.empty.fire,a.empty.fire=function(){a.unqueued||s()}),a.unqueued++,p.always(function(){p.always(function(){a.unqueued--,w.queue(e,"fx").length||a.empty.fire()})}));for(r in t)if(i=t[r],it.test(i)){if(delete t[r],o=o||"toggle"===i,i===(g?"hide":"show")){if("show"!==i||!y||void 0===y[r])continue;g=!0}d[r]=y&&y[r]||w.style(e,r)}if((u=!w.isEmptyObject(t))||!w.isEmptyObject(d)){f&&1===e.nodeType&&(n.overflow=[h.overflow,h.overflowX,h.overflowY],null==(l=y&&y.display)&&(l=J.get(e,"display")),"none"===(c=w.css(e,"display"))&&(l?c=l:(fe([e],!0),l=e.style.display||l,c=w.css(e,"display"),fe([e]))),("inline"===c||"inline-block"===c&&null!=l)&&"none"===w.css(e,"float")&&(u||(p.done(function(){h.display=l}),null==l&&(c=h.display,l="none"===c?"":c)),h.display="inline-block")),n.overflow&&(h.overflow="hidden",p.always(function(){h.overflow=n.overflow[0],h.overflowX=n.overflow[1],h.overflowY=n.overflow[2]})),u=!1;for(r in d)u||(y?"hidden"in y&&(g=y.hidden):y=J.access(e,"fxshow",{display:l}),o&&(y.hidden=!g),g&&fe([e],!0),p.done(function(){g||fe([e]),J.remove(e,"fxshow");for(r in d)w.style(e,r,d[r])})),u=lt(g?y[r]:0,r,p),r in y||(y[r]=u.start,g&&(u.end=u.start,u.start=0))}}function ft(e,t){var n,r,i,o,a;for(n in e)if(r=G(n),i=t[r],o=e[n],Array.isArray(o)&&(i=o[1],o=e[n]=o[0]),n!==r&&(e[r]=o,delete e[n]),(a=w.cssHooks[r])&&"expand"in a){o=a.expand(o),delete e[r];for(n in o)n in e||(e[n]=o[n],t[n]=i)}else t[r]=i}function pt(e,t,n){var r,i,o=0,a=pt.prefilters.length,s=w.Deferred().always(function(){delete u.elem}),u=function(){if(i)return!1;for(var t=nt||st(),n=Math.max(0,l.startTime+l.duration-t),r=1-(n/l.duration||0),o=0,a=l.tweens.length;o<a;o++)l.tweens[o].run(r);return s.notifyWith(e,[l,r,n]),r<1&&a?n:(a||s.notifyWith(e,[l,1,0]),s.resolveWith(e,[l]),!1)},l=s.promise({elem:e,props:w.extend({},t),opts:w.extend(!0,{specialEasing:{},easing:w.easing._default},n),originalProperties:t,originalOptions:n,startTime:nt||st(),duration:n.duration,tweens:[],createTween:function(t,n){var r=w.Tween(e,l.opts,t,n,l.opts.specialEasing[t]||l.opts.easing);return l.tweens.push(r),r},stop:function(t){var n=0,r=t?l.tweens.length:0;if(i)return this;for(i=!0;n<r;n++)l.tweens[n].run(1);return t?(s.notifyWith(e,[l,1,0]),s.resolveWith(e,[l,t])):s.rejectWith(e,[l,t]),this}}),c=l.props;for(ft(c,l.opts.specialEasing);o<a;o++)if(r=pt.prefilters[o].call(l,e,c,l.opts))return g(r.stop)&&(w._queueHooks(l.elem,l.opts.queue).stop=r.stop.bind(r)),r;return w.map(c,lt,l),g(l.opts.start)&&l.opts.start.call(e,l),l.progress(l.opts.progress).done(l.opts.done,l.opts.complete).fail(l.opts.fail).always(l.opts.always),w.fx.timer(w.extend(u,{elem:e,anim:l,queue:l.opts.queue})),l}w.Animation=w.extend(pt,{tweeners:{"*":[function(e,t){var n=this.createTween(e,t);return ue(n.elem,e,ie.exec(t),n),n}]},tweener:function(e,t){g(e)?(t=e,e=["*"]):e=e.match(M);for(var n,r=0,i=e.length;r<i;r++)n=e[r],pt.tweeners[n]=pt.tweeners[n]||[],pt.tweeners[n].unshift(t)},prefilters:[ct],prefilter:function(e,t){t?pt.prefilters.unshift(e):pt.prefilters.push(e)}}),w.speed=function(e,t,n){var r=e&&"object"==typeof e?w.extend({},e):{complete:n||!n&&t||g(e)&&e,duration:e,easing:n&&t||t&&!g(t)&&t};return w.fx.off?r.duration=0:"number"!=typeof r.duration&&(r.duration in w.fx.speeds?r.duration=w.fx.speeds[r.duration]:r.duration=w.fx.speeds._default),null!=r.queue&&!0!==r.queue||(r.queue="fx"),r.old=r.complete,r.complete=function(){g(r.old)&&r.old.call(this),r.queue&&w.dequeue(this,r.queue)},r},w.fn.extend({fadeTo:function(e,t,n,r){return this.filter(ae).css("opacity",0).show().end().animate({opacity:t},e,n,r)},animate:function(e,t,n,r){var i=w.isEmptyObject(e),o=w.speed(t,n,r),a=function(){var t=pt(this,w.extend({},e),o);(i||J.get(this,"finish"))&&t.stop(!0)};return a.finish=a,i||!1===o.queue?this.each(a):this.queue(o.queue,a)},stop:function(e,t,n){var r=function(e){var t=e.stop;delete e.stop,t(n)};return"string"!=typeof e&&(n=t,t=e,e=void 0),t&&!1!==e&&this.queue(e||"fx",[]),this.each(function(){var t=!0,i=null!=e&&e+"queueHooks",o=w.timers,a=J.get(this);if(i)a[i]&&a[i].stop&&r(a[i]);else for(i in a)a[i]&&a[i].stop&&ot.test(i)&&r(a[i]);for(i=o.length;i--;)o[i].elem!==this||null!=e&&o[i].queue!==e||(o[i].anim.stop(n),t=!1,o.splice(i,1));!t&&n||w.dequeue(this,e)})},finish:function(e){return!1!==e&&(e=e||"fx"),this.each(function(){var t,n=J.get(this),r=n[e+"queue"],i=n[e+"queueHooks"],o=w.timers,a=r?r.length:0;for(n.finish=!0,w.queue(this,e,[]),i&&i.stop&&i.stop.call(this,!0),t=o.length;t--;)o[t].elem===this&&o[t].queue===e&&(o[t].anim.stop(!0),o.splice(t,1));for(t=0;t<a;t++)r[t]&&r[t].finish&&r[t].finish.call(this);delete n.finish})}}),w.each(["toggle","show","hide"],function(e,t){var n=w.fn[t];w.fn[t]=function(e,r,i){return null==e||"boolean"==typeof e?n.apply(this,arguments):this.animate(ut(t,!0),e,r,i)}}),w.each({slideDown:ut("show"),slideUp:ut("hide"),slideToggle:ut("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(e,t){w.fn[e]=function(e,n,r){return this.animate(t,e,n,r)}}),w.timers=[],w.fx.tick=function(){var e,t=0,n=w.timers;for(nt=Date.now();t<n.length;t++)(e=n[t])()||n[t]!==e||n.splice(t--,1);n.length||w.fx.stop(),nt=void 0},w.fx.timer=function(e){w.timers.push(e),w.fx.start()},w.fx.interval=13,w.fx.start=function(){rt||(rt=!0,at())},w.fx.stop=function(){rt=null},w.fx.speeds={slow:600,fast:200,_default:400},w.fn.delay=function(t,n){return t=w.fx?w.fx.speeds[t]||t:t,n=n||"fx",this.queue(n,function(n,r){var i=e.setTimeout(n,t);r.stop=function(){e.clearTimeout(i)}})},function(){var e=r.createElement("input"),t=r.createElement("select").appendChild(r.createElement("option"));e.type="checkbox",h.checkOn=""!==e.value,h.optSelected=t.selected,(e=r.createElement("input")).value="t",e.type="radio",h.radioValue="t"===e.value}();var dt,ht=w.expr.attrHandle;w.fn.extend({attr:function(e,t){return z(this,w.attr,e,t,arguments.length>1)},removeAttr:function(e){return this.each(function(){w.removeAttr(this,e)})}}),w.extend({attr:function(e,t,n){var r,i,o=e.nodeType;if(3!==o&&8!==o&&2!==o)return"undefined"==typeof e.getAttribute?w.prop(e,t,n):(1===o&&w.isXMLDoc(e)||(i=w.attrHooks[t.toLowerCase()]||(w.expr.match.bool.test(t)?dt:void 0)),void 0!==n?null===n?void w.removeAttr(e,t):i&&"set"in i&&void 0!==(r=i.set(e,n,t))?r:(e.setAttribute(t,n+""),n):i&&"get"in i&&null!==(r=i.get(e,t))?r:null==(r=w.find.attr(e,t))?void 0:r)},attrHooks:{type:{set:function(e,t){if(!h.radioValue&&"radio"===t&&N(e,"input")){var n=e.value;return e.setAttribute("type",t),n&&(e.value=n),t}}}},removeAttr:function(e,t){var n,r=0,i=t&&t.match(M);if(i&&1===e.nodeType)while(n=i[r++])e.removeAttribute(n)}}),dt={set:function(e,t,n){return!1===t?w.removeAttr(e,n):e.setAttribute(n,n),n}},w.each(w.expr.match.bool.source.match(/\w+/g),function(e,t){var n=ht[t]||w.find.attr;ht[t]=function(e,t,r){var i,o,a=t.toLowerCase();return r||(o=ht[a],ht[a]=i,i=null!=n(e,t,r)?a:null,ht[a]=o),i}});var gt=/^(?:input|select|textarea|button)$/i,yt=/^(?:a|area)$/i;w.fn.extend({prop:function(e,t){return z(this,w.prop,e,t,arguments.length>1)},removeProp:function(e){return this.each(function(){delete this[w.propFix[e]||e]})}}),w.extend({prop:function(e,t,n){var r,i,o=e.nodeType;if(3!==o&&8!==o&&2!==o)return 1===o&&w.isXMLDoc(e)||(t=w.propFix[t]||t,i=w.propHooks[t]),void 0!==n?i&&"set"in i&&void 0!==(r=i.set(e,n,t))?r:e[t]=n:i&&"get"in i&&null!==(r=i.get(e,t))?r:e[t]},propHooks:{tabIndex:{get:function(e){var t=w.find.attr(e,"tabindex");return t?parseInt(t,10):gt.test(e.nodeName)||yt.test(e.nodeName)&&e.href?0:-1}}},propFix:{"for":"htmlFor","class":"className"}}),h.optSelected||(w.propHooks.selected={get:function(e){var t=e.parentNode;return t&&t.parentNode&&t.parentNode.selectedIndex,null},set:function(e){var t=e.parentNode;t&&(t.selectedIndex,t.parentNode&&t.parentNode.selectedIndex)}}),w.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){w.propFix[this.toLowerCase()]=this});function vt(e){return(e.match(M)||[]).join(" ")}function mt(e){return e.getAttribute&&e.getAttribute("class")||""}function xt(e){return Array.isArray(e)?e:"string"==typeof e?e.match(M)||[]:[]}w.fn.extend({addClass:function(e){var t,n,r,i,o,a,s,u=0;if(g(e))return this.each(function(t){w(this).addClass(e.call(this,t,mt(this)))});if((t=xt(e)).length)while(n=this[u++])if(i=mt(n),r=1===n.nodeType&&" "+vt(i)+" "){a=0;while(o=t[a++])r.indexOf(" "+o+" ")<0&&(r+=o+" ");i!==(s=vt(r))&&n.setAttribute("class",s)}return this},removeClass:function(e){var t,n,r,i,o,a,s,u=0;if(g(e))return this.each(function(t){w(this).removeClass(e.call(this,t,mt(this)))});if(!arguments.length)return this.attr("class","");if((t=xt(e)).length)while(n=this[u++])if(i=mt(n),r=1===n.nodeType&&" "+vt(i)+" "){a=0;while(o=t[a++])while(r.indexOf(" "+o+" ")>-1)r=r.replace(" "+o+" "," ");i!==(s=vt(r))&&n.setAttribute("class",s)}return this},toggleClass:function(e,t){var n=typeof e,r="string"===n||Array.isArray(e);return"boolean"==typeof t&&r?t?this.addClass(e):this.removeClass(e):g(e)?this.each(function(n){w(this).toggleClass(e.call(this,n,mt(this),t),t)}):this.each(function(){var t,i,o,a;if(r){i=0,o=w(this),a=xt(e);while(t=a[i++])o.hasClass(t)?o.removeClass(t):o.addClass(t)}else void 0!==e&&"boolean"!==n||((t=mt(this))&&J.set(this,"__className__",t),this.setAttribute&&this.setAttribute("class",t||!1===e?"":J.get(this,"__className__")||""))})},hasClass:function(e){var t,n,r=0;t=" "+e+" ";while(n=this[r++])if(1===n.nodeType&&(" "+vt(mt(n))+" ").indexOf(t)>-1)return!0;return!1}});var bt=/\r/g;w.fn.extend({val:function(e){var t,n,r,i=this[0];{if(arguments.length)return r=g(e),this.each(function(n){var i;1===this.nodeType&&(null==(i=r?e.call(this,n,w(this).val()):e)?i="":"number"==typeof i?i+="":Array.isArray(i)&&(i=w.map(i,function(e){return null==e?"":e+""})),(t=w.valHooks[this.type]||w.valHooks[this.nodeName.toLowerCase()])&&"set"in t&&void 0!==t.set(this,i,"value")||(this.value=i))});if(i)return(t=w.valHooks[i.type]||w.valHooks[i.nodeName.toLowerCase()])&&"get"in t&&void 0!==(n=t.get(i,"value"))?n:"string"==typeof(n=i.value)?n.replace(bt,""):null==n?"":n}}}),w.extend({valHooks:{option:{get:function(e){var t=w.find.attr(e,"value");return null!=t?t:vt(w.text(e))}},select:{get:function(e){var t,n,r,i=e.options,o=e.selectedIndex,a="select-one"===e.type,s=a?null:[],u=a?o+1:i.length;for(r=o<0?u:a?o:0;r<u;r++)if(((n=i[r]).selected||r===o)&&!n.disabled&&(!n.parentNode.disabled||!N(n.parentNode,"optgroup"))){if(t=w(n).val(),a)return t;s.push(t)}return s},set:function(e,t){var n,r,i=e.options,o=w.makeArray(t),a=i.length;while(a--)((r=i[a]).selected=w.inArray(w.valHooks.option.get(r),o)>-1)&&(n=!0);return n||(e.selectedIndex=-1),o}}}}),w.each(["radio","checkbox"],function(){w.valHooks[this]={set:function(e,t){if(Array.isArray(t))return e.checked=w.inArray(w(e).val(),t)>-1}},h.checkOn||(w.valHooks[this].get=function(e){return null===e.getAttribute("value")?"on":e.value})}),h.focusin="onfocusin"in e;var wt=/^(?:focusinfocus|focusoutblur)$/,Tt=function(e){e.stopPropagation()};w.extend(w.event,{trigger:function(t,n,i,o){var a,s,u,l,c,p,d,h,v=[i||r],m=f.call(t,"type")?t.type:t,x=f.call(t,"namespace")?t.namespace.split("."):[];if(s=h=u=i=i||r,3!==i.nodeType&&8!==i.nodeType&&!wt.test(m+w.event.triggered)&&(m.indexOf(".")>-1&&(m=(x=m.split(".")).shift(),x.sort()),c=m.indexOf(":")<0&&"on"+m,t=t[w.expando]?t:new w.Event(m,"object"==typeof t&&t),t.isTrigger=o?2:3,t.namespace=x.join("."),t.rnamespace=t.namespace?new RegExp("(^|\\.)"+x.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,t.result=void 0,t.target||(t.target=i),n=null==n?[t]:w.makeArray(n,[t]),d=w.event.special[m]||{},o||!d.trigger||!1!==d.trigger.apply(i,n))){if(!o&&!d.noBubble&&!y(i)){for(l=d.delegateType||m,wt.test(l+m)||(s=s.parentNode);s;s=s.parentNode)v.push(s),u=s;u===(i.ownerDocument||r)&&v.push(u.defaultView||u.parentWindow||e)}a=0;while((s=v[a++])&&!t.isPropagationStopped())h=s,t.type=a>1?l:d.bindType||m,(p=(J.get(s,"events")||{})[t.type]&&J.get(s,"handle"))&&p.apply(s,n),(p=c&&s[c])&&p.apply&&Y(s)&&(t.result=p.apply(s,n),!1===t.result&&t.preventDefault());return t.type=m,o||t.isDefaultPrevented()||d._default&&!1!==d._default.apply(v.pop(),n)||!Y(i)||c&&g(i[m])&&!y(i)&&((u=i[c])&&(i[c]=null),w.event.triggered=m,t.isPropagationStopped()&&h.addEventListener(m,Tt),i[m](),t.isPropagationStopped()&&h.removeEventListener(m,Tt),w.event.triggered=void 0,u&&(i[c]=u)),t.result}},simulate:function(e,t,n){var r=w.extend(new w.Event,n,{type:e,isSimulated:!0});w.event.trigger(r,null,t)}}),w.fn.extend({trigger:function(e,t){return this.each(function(){w.event.trigger(e,t,this)})},triggerHandler:function(e,t){var n=this[0];if(n)return w.event.trigger(e,t,n,!0)}}),h.focusin||w.each({focus:"focusin",blur:"focusout"},function(e,t){var n=function(e){w.event.simulate(t,e.target,w.event.fix(e))};w.event.special[t]={setup:function(){var r=this.ownerDocument||this,i=J.access(r,t);i||r.addEventListener(e,n,!0),J.access(r,t,(i||0)+1)},teardown:function(){var r=this.ownerDocument||this,i=J.access(r,t)-1;i?J.access(r,t,i):(r.removeEventListener(e,n,!0),J.remove(r,t))}}});var Ct=e.location,Et=Date.now(),kt=/\?/;w.parseXML=function(t){var n;if(!t||"string"!=typeof t)return null;try{n=(new e.DOMParser).parseFromString(t,"text/xml")}catch(e){n=void 0}return n&&!n.getElementsByTagName("parsererror").length||w.error("Invalid XML: "+t),n};var St=/\[\]$/,Dt=/\r?\n/g,Nt=/^(?:submit|button|image|reset|file)$/i,At=/^(?:input|select|textarea|keygen)/i;function jt(e,t,n,r){var i;if(Array.isArray(t))w.each(t,function(t,i){n||St.test(e)?r(e,i):jt(e+"["+("object"==typeof i&&null!=i?t:"")+"]",i,n,r)});else if(n||"object"!==x(t))r(e,t);else for(i in t)jt(e+"["+i+"]",t[i],n,r)}w.param=function(e,t){var n,r=[],i=function(e,t){var n=g(t)?t():t;r[r.length]=encodeURIComponent(e)+"="+encodeURIComponent(null==n?"":n)};if(Array.isArray(e)||e.jquery&&!w.isPlainObject(e))w.each(e,function(){i(this.name,this.value)});else for(n in e)jt(n,e[n],t,i);return r.join("&")},w.fn.extend({serialize:function(){return w.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var e=w.prop(this,"elements");return e?w.makeArray(e):this}).filter(function(){var e=this.type;return this.name&&!w(this).is(":disabled")&&At.test(this.nodeName)&&!Nt.test(e)&&(this.checked||!pe.test(e))}).map(function(e,t){var n=w(this).val();return null==n?null:Array.isArray(n)?w.map(n,function(e){return{name:t.name,value:e.replace(Dt,"\r\n")}}):{name:t.name,value:n.replace(Dt,"\r\n")}}).get()}});var qt=/%20/g,Lt=/#.*$/,Ht=/([?&])_=[^&]*/,Ot=/^(.*?):[ \t]*([^\r\n]*)$/gm,Pt=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,Mt=/^(?:GET|HEAD)$/,Rt=/^\/\//,It={},Wt={},$t="*/".concat("*"),Bt=r.createElement("a");Bt.href=Ct.href;function Ft(e){return function(t,n){"string"!=typeof t&&(n=t,t="*");var r,i=0,o=t.toLowerCase().match(M)||[];if(g(n))while(r=o[i++])"+"===r[0]?(r=r.slice(1)||"*",(e[r]=e[r]||[]).unshift(n)):(e[r]=e[r]||[]).push(n)}}function _t(e,t,n,r){var i={},o=e===Wt;function a(s){var u;return i[s]=!0,w.each(e[s]||[],function(e,s){var l=s(t,n,r);return"string"!=typeof l||o||i[l]?o?!(u=l):void 0:(t.dataTypes.unshift(l),a(l),!1)}),u}return a(t.dataTypes[0])||!i["*"]&&a("*")}function zt(e,t){var n,r,i=w.ajaxSettings.flatOptions||{};for(n in t)void 0!==t[n]&&((i[n]?e:r||(r={}))[n]=t[n]);return r&&w.extend(!0,e,r),e}function Xt(e,t,n){var r,i,o,a,s=e.contents,u=e.dataTypes;while("*"===u[0])u.shift(),void 0===r&&(r=e.mimeType||t.getResponseHeader("Content-Type"));if(r)for(i in s)if(s[i]&&s[i].test(r)){u.unshift(i);break}if(u[0]in n)o=u[0];else{for(i in n){if(!u[0]||e.converters[i+" "+u[0]]){o=i;break}a||(a=i)}o=o||a}if(o)return o!==u[0]&&u.unshift(o),n[o]}function Ut(e,t,n,r){var i,o,a,s,u,l={},c=e.dataTypes.slice();if(c[1])for(a in e.converters)l[a.toLowerCase()]=e.converters[a];o=c.shift();while(o)if(e.responseFields[o]&&(n[e.responseFields[o]]=t),!u&&r&&e.dataFilter&&(t=e.dataFilter(t,e.dataType)),u=o,o=c.shift())if("*"===o)o=u;else if("*"!==u&&u!==o){if(!(a=l[u+" "+o]||l["* "+o]))for(i in l)if((s=i.split(" "))[1]===o&&(a=l[u+" "+s[0]]||l["* "+s[0]])){!0===a?a=l[i]:!0!==l[i]&&(o=s[0],c.unshift(s[1]));break}if(!0!==a)if(a&&e["throws"])t=a(t);else try{t=a(t)}catch(e){return{state:"parsererror",error:a?e:"No conversion from "+u+" to "+o}}}return{state:"success",data:t}}w.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:Ct.href,type:"GET",isLocal:Pt.test(Ct.protocol),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":$t,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/\bxml\b/,html:/\bhtml/,json:/\bjson\b/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":JSON.parse,"text xml":w.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(e,t){return t?zt(zt(e,w.ajaxSettings),t):zt(w.ajaxSettings,e)},ajaxPrefilter:Ft(It),ajaxTransport:Ft(Wt),ajax:function(t,n){"object"==typeof t&&(n=t,t=void 0),n=n||{};var i,o,a,s,u,l,c,f,p,d,h=w.ajaxSetup({},n),g=h.context||h,y=h.context&&(g.nodeType||g.jquery)?w(g):w.event,v=w.Deferred(),m=w.Callbacks("once memory"),x=h.statusCode||{},b={},T={},C="canceled",E={readyState:0,getResponseHeader:function(e){var t;if(c){if(!s){s={};while(t=Ot.exec(a))s[t[1].toLowerCase()]=t[2]}t=s[e.toLowerCase()]}return null==t?null:t},getAllResponseHeaders:function(){return c?a:null},setRequestHeader:function(e,t){return null==c&&(e=T[e.toLowerCase()]=T[e.toLowerCase()]||e,b[e]=t),this},overrideMimeType:function(e){return null==c&&(h.mimeType=e),this},statusCode:function(e){var t;if(e)if(c)E.always(e[E.status]);else for(t in e)x[t]=[x[t],e[t]];return this},abort:function(e){var t=e||C;return i&&i.abort(t),k(0,t),this}};if(v.promise(E),h.url=((t||h.url||Ct.href)+"").replace(Rt,Ct.protocol+"//"),h.type=n.method||n.type||h.method||h.type,h.dataTypes=(h.dataType||"*").toLowerCase().match(M)||[""],null==h.crossDomain){l=r.createElement("a");try{l.href=h.url,l.href=l.href,h.crossDomain=Bt.protocol+"//"+Bt.host!=l.protocol+"//"+l.host}catch(e){h.crossDomain=!0}}if(h.data&&h.processData&&"string"!=typeof h.data&&(h.data=w.param(h.data,h.traditional)),_t(It,h,n,E),c)return E;(f=w.event&&h.global)&&0==w.active++&&w.event.trigger("ajaxStart"),h.type=h.type.toUpperCase(),h.hasContent=!Mt.test(h.type),o=h.url.replace(Lt,""),h.hasContent?h.data&&h.processData&&0===(h.contentType||"").indexOf("application/x-www-form-urlencoded")&&(h.data=h.data.replace(qt,"+")):(d=h.url.slice(o.length),h.data&&(h.processData||"string"==typeof h.data)&&(o+=(kt.test(o)?"&":"?")+h.data,delete h.data),!1===h.cache&&(o=o.replace(Ht,"$1"),d=(kt.test(o)?"&":"?")+"_="+Et+++d),h.url=o+d),h.ifModified&&(w.lastModified[o]&&E.setRequestHeader("If-Modified-Since",w.lastModified[o]),w.etag[o]&&E.setRequestHeader("If-None-Match",w.etag[o])),(h.data&&h.hasContent&&!1!==h.contentType||n.contentType)&&E.setRequestHeader("Content-Type",h.contentType),E.setRequestHeader("Accept",h.dataTypes[0]&&h.accepts[h.dataTypes[0]]?h.accepts[h.dataTypes[0]]+("*"!==h.dataTypes[0]?", "+$t+"; q=0.01":""):h.accepts["*"]);for(p in h.headers)E.setRequestHeader(p,h.headers[p]);if(h.beforeSend&&(!1===h.beforeSend.call(g,E,h)||c))return E.abort();if(C="abort",m.add(h.complete),E.done(h.success),E.fail(h.error),i=_t(Wt,h,n,E)){if(E.readyState=1,f&&y.trigger("ajaxSend",[E,h]),c)return E;h.async&&h.timeout>0&&(u=e.setTimeout(function(){E.abort("timeout")},h.timeout));try{c=!1,i.send(b,k)}catch(e){if(c)throw e;k(-1,e)}}else k(-1,"No Transport");function k(t,n,r,s){var l,p,d,b,T,C=n;c||(c=!0,u&&e.clearTimeout(u),i=void 0,a=s||"",E.readyState=t>0?4:0,l=t>=200&&t<300||304===t,r&&(b=Xt(h,E,r)),b=Ut(h,b,E,l),l?(h.ifModified&&((T=E.getResponseHeader("Last-Modified"))&&(w.lastModified[o]=T),(T=E.getResponseHeader("etag"))&&(w.etag[o]=T)),204===t||"HEAD"===h.type?C="nocontent":304===t?C="notmodified":(C=b.state,p=b.data,l=!(d=b.error))):(d=C,!t&&C||(C="error",t<0&&(t=0))),E.status=t,E.statusText=(n||C)+"",l?v.resolveWith(g,[p,C,E]):v.rejectWith(g,[E,C,d]),E.statusCode(x),x=void 0,f&&y.trigger(l?"ajaxSuccess":"ajaxError",[E,h,l?p:d]),m.fireWith(g,[E,C]),f&&(y.trigger("ajaxComplete",[E,h]),--w.active||w.event.trigger("ajaxStop")))}return E},getJSON:function(e,t,n){return w.get(e,t,n,"json")},getScript:function(e,t){return w.get(e,void 0,t,"script")}}),w.each(["get","post"],function(e,t){w[t]=function(e,n,r,i){return g(n)&&(i=i||r,r=n,n=void 0),w.ajax(w.extend({url:e,type:t,dataType:i,data:n,success:r},w.isPlainObject(e)&&e))}}),w._evalUrl=function(e){return w.ajax({url:e,type:"GET",dataType:"script",cache:!0,async:!1,global:!1,"throws":!0})},w.fn.extend({wrapAll:function(e){var t;return this[0]&&(g(e)&&(e=e.call(this[0])),t=w(e,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&t.insertBefore(this[0]),t.map(function(){var e=this;while(e.firstElementChild)e=e.firstElementChild;return e}).append(this)),this},wrapInner:function(e){return g(e)?this.each(function(t){w(this).wrapInner(e.call(this,t))}):this.each(function(){var t=w(this),n=t.contents();n.length?n.wrapAll(e):t.append(e)})},wrap:function(e){var t=g(e);return this.each(function(n){w(this).wrapAll(t?e.call(this,n):e)})},unwrap:function(e){return this.parent(e).not("body").each(function(){w(this).replaceWith(this.childNodes)}),this}}),w.expr.pseudos.hidden=function(e){return!w.expr.pseudos.visible(e)},w.expr.pseudos.visible=function(e){return!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)},w.ajaxSettings.xhr=function(){try{return new e.XMLHttpRequest}catch(e){}};var Vt={0:200,1223:204},Gt=w.ajaxSettings.xhr();h.cors=!!Gt&&"withCredentials"in Gt,h.ajax=Gt=!!Gt,w.ajaxTransport(function(t){var n,r;if(h.cors||Gt&&!t.crossDomain)return{send:function(i,o){var a,s=t.xhr();if(s.open(t.type,t.url,t.async,t.username,t.password),t.xhrFields)for(a in t.xhrFields)s[a]=t.xhrFields[a];t.mimeType&&s.overrideMimeType&&s.overrideMimeType(t.mimeType),t.crossDomain||i["X-Requested-With"]||(i["X-Requested-With"]="XMLHttpRequest");for(a in i)s.setRequestHeader(a,i[a]);n=function(e){return function(){n&&(n=r=s.onload=s.onerror=s.onabort=s.ontimeout=s.onreadystatechange=null,"abort"===e?s.abort():"error"===e?"number"!=typeof s.status?o(0,"error"):o(s.status,s.statusText):o(Vt[s.status]||s.status,s.statusText,"text"!==(s.responseType||"text")||"string"!=typeof s.responseText?{binary:s.response}:{text:s.responseText},s.getAllResponseHeaders()))}},s.onload=n(),r=s.onerror=s.ontimeout=n("error"),void 0!==s.onabort?s.onabort=r:s.onreadystatechange=function(){4===s.readyState&&e.setTimeout(function(){n&&r()})},n=n("abort");try{s.send(t.hasContent&&t.data||null)}catch(e){if(n)throw e}},abort:function(){n&&n()}}}),w.ajaxPrefilter(function(e){e.crossDomain&&(e.contents.script=!1)}),w.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/\b(?:java|ecma)script\b/},converters:{"text script":function(e){return w.globalEval(e),e}}}),w.ajaxPrefilter("script",function(e){void 0===e.cache&&(e.cache=!1),e.crossDomain&&(e.type="GET")}),w.ajaxTransport("script",function(e){if(e.crossDomain){var t,n;return{send:function(i,o){t=w("<script>").prop({charset:e.scriptCharset,src:e.url}).on("load error",n=function(e){t.remove(),n=null,e&&o("error"===e.type?404:200,e.type)}),r.head.appendChild(t[0])},abort:function(){n&&n()}}}});var Yt=[],Qt=/(=)\?(?=&|$)|\?\?/;w.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=Yt.pop()||w.expando+"_"+Et++;return this[e]=!0,e}}),w.ajaxPrefilter("json jsonp",function(t,n,r){var i,o,a,s=!1!==t.jsonp&&(Qt.test(t.url)?"url":"string"==typeof t.data&&0===(t.contentType||"").indexOf("application/x-www-form-urlencoded")&&Qt.test(t.data)&&"data");if(s||"jsonp"===t.dataTypes[0])return i=t.jsonpCallback=g(t.jsonpCallback)?t.jsonpCallback():t.jsonpCallback,s?t[s]=t[s].replace(Qt,"$1"+i):!1!==t.jsonp&&(t.url+=(kt.test(t.url)?"&":"?")+t.jsonp+"="+i),t.converters["script json"]=function(){return a||w.error(i+" was not called"),a[0]},t.dataTypes[0]="json",o=e[i],e[i]=function(){a=arguments},r.always(function(){void 0===o?w(e).removeProp(i):e[i]=o,t[i]&&(t.jsonpCallback=n.jsonpCallback,Yt.push(i)),a&&g(o)&&o(a[0]),a=o=void 0}),"script"}),h.createHTMLDocument=function(){var e=r.implementation.createHTMLDocument("").body;return e.innerHTML="<form></form><form></form>",2===e.childNodes.length}(),w.parseHTML=function(e,t,n){if("string"!=typeof e)return[];"boolean"==typeof t&&(n=t,t=!1);var i,o,a;return t||(h.createHTMLDocument?((i=(t=r.implementation.createHTMLDocument("")).createElement("base")).href=r.location.href,t.head.appendChild(i)):t=r),o=A.exec(e),a=!n&&[],o?[t.createElement(o[1])]:(o=xe([e],t,a),a&&a.length&&w(a).remove(),w.merge([],o.childNodes))},w.fn.load=function(e,t,n){var r,i,o,a=this,s=e.indexOf(" ");return s>-1&&(r=vt(e.slice(s)),e=e.slice(0,s)),g(t)?(n=t,t=void 0):t&&"object"==typeof t&&(i="POST"),a.length>0&&w.ajax({url:e,type:i||"GET",dataType:"html",data:t}).done(function(e){o=arguments,a.html(r?w("<div>").append(w.parseHTML(e)).find(r):e)}).always(n&&function(e,t){a.each(function(){n.apply(this,o||[e.responseText,t,e])})}),this},w.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){w.fn[t]=function(e){return this.on(t,e)}}),w.expr.pseudos.animated=function(e){return w.grep(w.timers,function(t){return e===t.elem}).length},w.offset={setOffset:function(e,t,n){var r,i,o,a,s,u,l,c=w.css(e,"position"),f=w(e),p={};"static"===c&&(e.style.position="relative"),s=f.offset(),o=w.css(e,"top"),u=w.css(e,"left"),(l=("absolute"===c||"fixed"===c)&&(o+u).indexOf("auto")>-1)?(a=(r=f.position()).top,i=r.left):(a=parseFloat(o)||0,i=parseFloat(u)||0),g(t)&&(t=t.call(e,n,w.extend({},s))),null!=t.top&&(p.top=t.top-s.top+a),null!=t.left&&(p.left=t.left-s.left+i),"using"in t?t.using.call(e,p):f.css(p)}},w.fn.extend({offset:function(e){if(arguments.length)return void 0===e?this:this.each(function(t){w.offset.setOffset(this,e,t)});var t,n,r=this[0];if(r)return r.getClientRects().length?(t=r.getBoundingClientRect(),n=r.ownerDocument.defaultView,{top:t.top+n.pageYOffset,left:t.left+n.pageXOffset}):{top:0,left:0}},position:function(){if(this[0]){var e,t,n,r=this[0],i={top:0,left:0};if("fixed"===w.css(r,"position"))t=r.getBoundingClientRect();else{t=this.offset(),n=r.ownerDocument,e=r.offsetParent||n.documentElement;while(e&&(e===n.body||e===n.documentElement)&&"static"===w.css(e,"position"))e=e.parentNode;e&&e!==r&&1===e.nodeType&&((i=w(e).offset()).top+=w.css(e,"borderTopWidth",!0),i.left+=w.css(e,"borderLeftWidth",!0))}return{top:t.top-i.top-w.css(r,"marginTop",!0),left:t.left-i.left-w.css(r,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var e=this.offsetParent;while(e&&"static"===w.css(e,"position"))e=e.offsetParent;return e||be})}}),w.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(e,t){var n="pageYOffset"===t;w.fn[e]=function(r){return z(this,function(e,r,i){var o;if(y(e)?o=e:9===e.nodeType&&(o=e.defaultView),void 0===i)return o?o[t]:e[r];o?o.scrollTo(n?o.pageXOffset:i,n?i:o.pageYOffset):e[r]=i},e,r,arguments.length)}}),w.each(["top","left"],function(e,t){w.cssHooks[t]=_e(h.pixelPosition,function(e,n){if(n)return n=Fe(e,t),We.test(n)?w(e).position()[t]+"px":n})}),w.each({Height:"height",Width:"width"},function(e,t){w.each({padding:"inner"+e,content:t,"":"outer"+e},function(n,r){w.fn[r]=function(i,o){var a=arguments.length&&(n||"boolean"!=typeof i),s=n||(!0===i||!0===o?"margin":"border");return z(this,function(t,n,i){var o;return y(t)?0===r.indexOf("outer")?t["inner"+e]:t.document.documentElement["client"+e]:9===t.nodeType?(o=t.documentElement,Math.max(t.body["scroll"+e],o["scroll"+e],t.body["offset"+e],o["offset"+e],o["client"+e])):void 0===i?w.css(t,n,s):w.style(t,n,i,s)},t,a?i:void 0,a)}})}),w.each("blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu".split(" "),function(e,t){w.fn[t]=function(e,n){return arguments.length>0?this.on(t,null,e,n):this.trigger(t)}}),w.fn.extend({hover:function(e,t){return this.mouseenter(e).mouseleave(t||e)}}),w.fn.extend({bind:function(e,t,n){return this.on(e,null,t,n)},unbind:function(e,t){return this.off(e,null,t)},delegate:function(e,t,n,r){return this.on(t,e,n,r)},undelegate:function(e,t,n){return 1===arguments.length?this.off(e,"**"):this.off(t,e||"**",n)}}),w.proxy=function(e,t){var n,r,i;if("string"==typeof t&&(n=e[t],t=e,e=n),g(e))return r=o.call(arguments,2),i=function(){return e.apply(t||this,r.concat(o.call(arguments)))},i.guid=e.guid=e.guid||w.guid++,i},w.holdReady=function(e){e?w.readyWait++:w.ready(!0)},w.isArray=Array.isArray,w.parseJSON=JSON.parse,w.nodeName=N,w.isFunction=g,w.isWindow=y,w.camelCase=G,w.type=x,w.now=Date.now,w.isNumeric=function(e){var t=w.type(e);return("number"===t||"string"===t)&&!isNaN(e-parseFloat(e))},"function"==typeof define&&define.amd&&define("jquery",[],function(){return w});var Jt=e.jQuery,Kt=e.$;return w.noConflict=function(t){return e.$===w&&(e.$=Kt),t&&e.jQuery===w&&(e.jQuery=Jt),w},t||(e.jQuery=e.$=w),w});
/*
* sm2-1.0.js
*
* Copyright (c) 2019 RuXing Liang
*/
/**
* @name sm2-1.0.js
* @author RuXing Liang
* @version 1.0.0 (2019-04-16)
*/
var debug = false;
//国密推荐曲线
var sm2_ecParams = {
p: "FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFF",
a: "FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFC",
b: "28E9FA9E9D9F5E344D5A9E4BCF6509A7F39789F515AB8F92DDBCBD414D940E93",
n: "FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFF7203DF6B21C6052B53BBF40939D54123",
gx: "32C4AE2C1F1981195F9904466A39C9948FE30BBFF2660BE1715A4589334C74C7",
gy: "BC3736A2F4F6779C59BDCEE36B692153D0A9877CC62A474002DF32E52139F0A0",
keylen: 256,
};
function SM2() {
this.ecc_p = new BigInteger(sm2_ecParams["p"], 16);
this.ecc_a = new BigInteger(sm2_ecParams["a"], 16);
this.ecc_b = new BigInteger(sm2_ecParams["b"], 16);
this.ecc_n = new BigInteger(sm2_ecParams["n"], 16);
this.ecc_gx = new BigInteger(sm2_ecParams["gx"], 16);
this.ecc_gy = new BigInteger(sm2_ecParams["gy"], 16);
this.rng = new SecureRandom();
this.ecCurve = new ECCurveFp(this.ecc_p, this.ecc_a, this.ecc_b);
this.ecPointG = ECPointFp.decodeFromHex(
this.ecCurve,
"04" + sm2_ecParams["gx"] + sm2_ecParams["gy"]
);
if (debug == true) {
console.log("ax1=" + this.ecCurve.getA().toBigInteger().toString(16));
console.log("by1=" + this.ecCurve.getB().toBigInteger().toString(16));
console.log("gx1=" + this.ecPointG.getX().toBigInteger().toString(16));
console.log("gy1=" + this.ecPointG.getY().toBigInteger().toString(16));
}
}
SM2.prototype = {
getBigRandom: function (limit) {
return new BigInteger(limit.bitLength(), this.rng)
.mod(limit.subtract(BigInteger.ONE))
.add(BigInteger.ONE);
},
generateKeyPairHex: function () {
var key = this.generateKeyPairBigInteger();
var biX = key["pubkey"].getX().toBigInteger();
var biY = key["pubkey"].getY().toBigInteger();
var charlen = sm2_ecParams["keylen"] / 4;
var hPrv = ("0000000000" + key["privkey"].toString(16)).slice(-charlen);
var hX = ("0000000000" + biX.toString(16)).slice(-charlen);
var hY = ("0000000000" + biY.toString(16)).slice(-charlen);
var hPub = "04" + hX + hY;
return { privkeyhex: hPrv, pubkeyhex: hPub };
},
generateKeyPairBigInteger: function () {
var biN = this.ecc_n;
var biPrv = null;
var epPub = null;
while (true) {
do {
biPrv = this.getBigRandom(biN);
} while (
biPrv.equals(BigInteger.ZERO) ||
biPrv.compareTo(biN) >= 0 ||
biPrv.bitLength() < 249
);
epPub = this.ecPointG.multiply(biPrv);
if (
epPub.getX().toBigInteger().bitLength() >= 249 &&
epPub.getY().toBigInteger().bitLength() >= 249
) {
break;
}
}
return { privkey: biPrv, pubkey: epPub };
},
formartXY: function (bg, needLength) {
var tmp = new Array(needLength);
for (var i = 0; i < tmp.length; i++) {
tmp[i] = 0;
}
var bgByte = bg.toByteArray();
if (bgByte == null) {
return null;
}
if (bgByte.length > needLength) {
arrayCopy(bgByte, bgByte.length - needLength, tmp, 0, needLength);
} else if (bgByte.length == needLength) {
tmp = bgByte;
} else {
arrayCopy(bgByte, 0, tmp, needLength - bgByte.length, bgByte.length);
}
return tmp;
},
kdf: function (xy, data) {
// int ct = 1;
// var loop = data.length%32!=0 ? (data.length/32+1):data.length/32;
var loop = Math.ceil(data.length / 32); //向上取整
var sm3;
var hash = new Array(32);
for (var i = 0; i < loop; i++) {
sm3 = new SM3Digest();
sm3.update(xy, 0, xy.length);
sm3.update(intToByte(i + 1), 0, 4);
hash = sm3.doFinal();
for (var j = 0; j < hash.length && i * 32 + j < data.length; j++) {
data[i * 32 + j] ^= hash[j];
}
}
return 0;
},
arrayCompare: function (src1, pos1, src2, pos2, len) {
if (src1.length - pos1 < len) {
return -1;
}
if (src2.length - pos2 < len) {
return -1;
}
for (var i = 0; i < len; i++) {
if (src1[pos1++] != src2[pos2++]) {
return -1;
}
}
return 0;
},
encrypt: function (pubkey, dataHex) {
var cipher;
//1、创建sm2曲线,公钥P1加压缩标志0x04 2、将公钥转为曲线上的点 u1
//3、生成随机公私钥:k、P2 ,新公钥P2即为(x1,y1)点 ,x1y1拼接,即为:c1 (注意长度保持64字节)
//4、新私钥k与公钥P1相乘,即为(x2,y2)点,通过kdf算法,得到t字符串,t字符串和明文做异或运算,得到c2
//5、x2||明文||y2 三者拼接然后做sm3运算,得到c3
//说明,kdf主要是:循环次数loop(明文字节长度除以32,向上取整,运算时依次从1到最大值)拼接x2y2,即:x2||y2||loop(loop是int类型,须转成四字节),
//然后对拼接后的字符串做sm3运算,依次将每次的结果拼接,得到最终结果
if (
pubkey == null ||
pubkey.length == 0 ||
dataHex == null ||
dataHex.length == 0
) {
return null;
}
if (pubkey.length == 128) {
pubkey = "04" + pubkey;
}
var data = Hex.decode(dataHex);
var userKey = ECPointFp.decodeFromHex(this.ecCurve, pubkey);
var c2 = null;
var c1 = null;
var x2 = null;
var y2 = null;
var loop = 0;
do {
var kp = this.generateKeyPairBigInteger(); //创建公私钥对,这里私钥当做随机数k,公钥为c1点(x1,y1)
if (debug == true) {
console.log("priv" + kp["privkey"].toString(16));
console.log("x1=" + kp["pubkey"].getX().toBigInteger().toString(16));
console.log("y1=" + kp["pubkey"].getY().toBigInteger().toString(16));
}
c1 = kp["pubkey"];
var x2y2 = userKey.multiply(kp["privkey"]); //(x2,y2)
x2 = this.formartXY(x2y2.getX().toBigInteger(), 32);
y2 = this.formartXY(x2y2.getY().toBigInteger(), 32);
if (debug == true) {
console.log("x2=" + x2);
console.log("y2=" + y2);
console.log("x2=" + Hex.encode(x2, 0, x2.length));
console.log("y2=" + Hex.encode(y2, 0, y2.length));
}
c2 = new Array(data.length);
arrayCopy(data, 0, c2, 0, data.length);
var xy = new Array(x2.length + y2.length);
arrayCopy(x2, 0, xy, 0, x2.length);
arrayCopy(y2, 0, xy, x2.length, y2.length);
this.kdf(xy, c2);
loop++;
} while (this.arrayCompare(c2, 0, data, 0, data.length) == 0 && loop < 10);
if (loop >= 10) {
//失败超过一定次数,不再尝试
return null;
}
var sm3 = new SM3Digest();
sm3.update(x2, 0, x2.length);
sm3.update(data, 0, data.length);
sm3.update(y2, 0, y2.length);
var c3 = sm3.doFinal();
if (debug == true) {
console.log("data=" + Hex.encode(data, 0, data.length));
console.log("c3=" + Hex.encode(c3, 0, c3.length));
}
// cipher = new Array(96+c2.length);
/*var c1x = this.formartXY(c1.getX().toBigInteger(), 33);
var c1y = this.formartXY(c1.getY().toBigInteger(), 33);*/
var c1x = c1.getX().toBigInteger().toByteArray();
var c1y = c1.getY().toBigInteger().toByteArray();
/*arrayCopy(c1x, 0, cipher, 0, c1x.length);
arrayCopy(c1y, 0, cipher, c1x.length, c1y.length);
arrayCopy(c3, 0, cipher, c1x.length+c1y.length, c3.length);
arrayCopy(c2, 0, cipher, c1x.length+c1y.length+c3.length, c2.length);
console.log(Hex.encode(cipher,0,cipher.length));*/
var cipher = this.cipherToDer(c1x, c1y, c2, c3);
return Hex.encode(cipher, 0, cipher.length);
},
decrypt: function (privkey, cipherHex) {
console.log('l233 cipherHex:', cipherHex)
cipher = Hex.decode(cipherHex);
var dec = this.derDecode(cipher);
console.log('l233 cipher:', cipher)
console.log('l233 dec["c2"]:', dec["c2"])
var c1 = new Array(64 + 1);
var c2 = new Array(dec["c2"].length);
var c3 = new Array(32);
//1、创建sm2曲线,截取密文前64字节,转化为点(x1,y1)
//2、点(x1,y1)与私钥k相乘,得到(x2,y2)
//3、x2y2通过kdf算法得到字符串t,t再和密文c2做异或运算,得到明文M
//4、x2||M||y2 拼接,然后做sm3运算,得到hash值,对比密文的c3,一致则解密成功
for (var i = 0; i < c1.length; i++) {
c1[i] = 0;
}
if (dec["c1x"].length <= 32) {
//由于c1x/y两个元素长度可能不等于32,须调整为32
arrayCopy(
dec["c1x"],
0,
c1,
1 + (32 - dec["c1x"].length),
dec["c1x"].length
);
} else {
arrayCopy(dec["c1x"], dec["c1x"].length - 32, c1, 1, 32);
}
if (dec["c1y"].length <= 32) {
arrayCopy(
dec["c1y"],
0,
c1,
1 + 32 + (32 - dec["c1y"].length),
dec["c1y"].length
);
} else {
arrayCopy(dec["c1y"], dec["c1y"].length - 32, c1, 1 + 32, 32);
}
c1[0] = 0x04;
var c1Point = ECPointFp.decodeFromHex(
this.ecCurve,
Hex.encode(c1, 0, c1.length)
);
var x2y2Point = c1Point.multiply(new BigInteger(privkey, 16));
var x2 = this.formartXY(x2y2Point.getX().toBigInteger(), 32);
var y2 = this.formartXY(x2y2Point.getY().toBigInteger(), 32);
var xy = new Array(x2.length + y2.length);
arrayCopy(x2, 0, xy, 0, x2.length);
arrayCopy(y2, 0, xy, x2.length, y2.length);
arrayCopy(dec["c2"], 0, c2, 0, c2.length);
var c2Copy = new Array(c2.length);
arrayCopy(c2, 0, c2Copy, 0, c2.length);
this.kdf(xy, c2);
if (this.arrayCompare(c2Copy, 0, c2, 0, c2.length) == 0) {
console.log("t is all 0 and decrypt is failed!");
return null;
}
var sm3 = new SM3Digest();
var hash = new Array(32);
// arrayCopy(cipher, c1.length-1, c3, 0, c3.length);
sm3.update(x2, 0, x2.length);
sm3.update(c2, 0, c2.length);
sm3.update(y2, 0, y2.length);
hash = sm3.doFinal();
if (this.arrayCompare(hash, 0, dec["c3"], 0, 32) != 0) {
return null;
}
return Hex.encode(c2, 0, c2.length);
},
cipherToDer: function (c1x, c1y, c2, c3) {
var c2Len = c2.length;
var c2Tag = [];
if (c2Len < 0x80) {
c2Tag[0] = 0x04;
c2Tag[1] = c2Len;
} else {
c2Tag[0] = 0x04;
var c2LenBytes = intToByte(c2Len);
var i = 0;
while (c2LenBytes[i] == 0 && i < c2LenBytes.length) {
i++;
}
c2Tag[1] = 0x80 | (c2LenBytes.length - i);
for (var j = 2; i < c2LenBytes.length; i++, j++) {
c2Tag[j] = c2LenBytes[i];
}
}
var totalTagLen =
c1x.length + c1y.length + c2.length + c3.length + 6 + c2Tag.length;
var totalTag = [];
totalTag[0] = 0x30;
if (totalTagLen < 0x80) {
totalTag[1] = totalTagLen;
} else {
var totalTagLenBytes = intToByte(totalTagLen);
var i = 0;
while (totalTagLenBytes[i] == 0 && i < totalTagLenBytes.length) {
i++;
}
totalTag[1] = 0x80 | (totalTagLenBytes.length - i);
for (var j = 2; i < totalTagLenBytes.length; i++, j++) {
totalTag[j] = totalTagLenBytes[i];
}
}
var der = new Array(totalTagLen + totalTag.length);
var derLen = 0;
arrayCopy(totalTag, 0, der, 0, totalTag.length);
derLen += totalTag.length;
der[derLen++] = 0x02;
der[derLen++] = c1x.length;
arrayCopy(c1x, 0, der, derLen, c1x.length);
derLen += c1x.length;
der[derLen++] = 0x02;
der[derLen++] = c1y.length;
arrayCopy(c1y, 0, der, derLen, c1y.length);
derLen += c1y.length;
der[derLen++] = 0x04;
der[derLen++] = c3.length;
arrayCopy(c3, 0, der, derLen, c3.length);
derLen += c3.length;
arrayCopy(c2Tag, 0, der, derLen, c2Tag.length);
derLen += c2Tag.length;
arrayCopy(c2, 0, der, derLen, c2.length);
return der;
},
derDecode: function (der) {
var pos = 0;
var totalLen = 0;
if (der[pos++] != 0x30) {
return null;
}
if ((der[pos] & 0xff) <= 0x7f) {
// totalLen = der[pos++] & 0xFF;
pos++;
} else {
pos += (der[pos] & 0x7f) + 1;
}
pos++;
var c1xLen = der[pos];
var c1x = new Array(c1xLen);
arrayCopy(der, ++pos, c1x, 0, c1xLen);
pos += c1xLen;
pos++;
var c1yLen = der[pos];
var c1y = new Array(c1yLen);
arrayCopy(der, ++pos, c1y, 0, c1yLen);
pos += c1yLen;
pos++;
var c3Len = der[pos];
var c3 = new Array(c3Len);
arrayCopy(der, ++pos, c3, 0, c3Len);
pos += c3Len;
pos++;
var c2Len = 0;
if ((der[pos] & 0xff) <= 0x7f) {
c2Len = der[pos] & 0xff;
} else {
for (
var i = 0, j = (der[pos] & 0x7f) - 1;
i < (der[pos] & 0x7f);
i++, j--
) {
c2Len = c2Len | ((der[pos + i + 1] & 0xff) << (j * 8));
}
pos += der[pos] & 0x7f;
}
var c2 = new Array(c2Len);
arrayCopy(der, ++pos, c2, 0, c2Len);
pos += c2Len;
return { c1x: c1x, c1y: c1y, c2: c2, c3: c3 };
},
};
/*
* sm3-1.0.js
*
* Copyright (c) 2019 RuXing Liang
*/
/**
* @name sm3-1.0.js
* @author RuXing Liang
* @version 1.0.0 (2019-04-16)
*/
//加密数据不能超过500M
function SM3Digest(){
this.ivByte = new Array( 0x73, 0x80, 0x16, 0x6f, 0x49,
0x14, 0xb2, 0xb9, 0x17, 0x24, 0x42, 0xd7,
0xda, 0x8a, 0x06, 0x00, 0xa9, 0x6f, 0x30,
0xbc, 0x16, 0x31, 0x38, 0xaa, 0xe3,
0x8d, 0xee, 0x4d, 0xb0, 0xfb, 0x0e,
0x4e );
this.iv = byteArrayToIntArray(
this.ivByte
);
this.tj = new Array(64);
this.BLOCK_BYTE_LEN = 64;
this.vbuf = new Array(8);
//数据缓冲区
this.dataBuf = new Array(64);
//缓冲区长度
this.dataBufLen = 0;
//缓冲区总长度
this.totalLen = 0;//事实上需要long,后续需改进
for(var i = 0;i<64;i++) {
if(i<=15) {
this.tj[i] = 0x79cc4519;
}else {
this.tj[i] = 0x7a879d8a;
}
}
arrayCopy(this.iv, 0, this.vbuf, 0, this.vbuf.length);
}
SM3Digest.prototype = {
ffj:function(x,y,z,i){
var tmp;
if(i<=15) {
tmp = x^y^z;
}else{
tmp = (x&y)|(x&z)|(y&z);
}
return tmp;
},
ggj:function(x,y,z,i){
var tmp = 0;
if(i<=15) {
tmp = x^y^z;
}else {
tmp = (x&y)|(~x&z);
}
return tmp;
},
p0:function(x) {
//这里的公式是:对于一个二进制有n位的数字循环左移(循环右移)m位,
//可以将此数字左移(无符号右移)m位的结果与此数字 无符号 右移(左移)n-m位的结果进行或操作。
return x^(x<<9|(x>>>(32-9)))^(x<<17|(x>>>(32-17)));
},
p1:function(x) {
//这里的公式是:对于一个二进制有n位的数字循环左移(循环右移)m位,
//可以将此数字左移(无符号右移)m位的结果与此数字 无符号 右移(左移)n-m位的结果进行或操作。
return x^(x<<15|(x>>>(32-15)))^(x<<23|(x>>>(32-23)));
},
/**
* 循环左移
*/
cycleLeft:function(x,moveLen) {
return x<<moveLen|(x>>>(32-moveLen));
},
/**
* 消息填充函数
* @param data
* @return
*/
padding:function(data) {
var k = 0;
var len = data.length;
var padding;
k = 64 - (len + 1 + 8)%64;
if(k>=64) {
k = 0;
}
padding = new Array(k+1+len+8);
padding[len] = 1<<7;
arrayCopy(data, 0, padding, 0, len);
arrayCopy(longToByte(this.totalLen<<3), 0, padding, len+k+1, 8);
return padding;
},
/**
* 对数据进行分组迭代,每64个字节迭代一次
* <br>1、对消息进行分组,由于是int类型,则每16个分一组,对每一组再调用{@link #expand}进行拓展
* <br>2、使用上一轮的迭代结果V,调用{@link #cf}进行本轮迭代
* <br>3、最后一轮迭代结果复制进缓冲区vbuf
* @param message
*/
iterate:function(message) {
var len = message.length;
var n = parseInt(len/16);
var v,b;
var ep;
v = this.vbuf;
b = new Array(16);
for(var i = 0;i<n;i++) {
arrayCopy(message, i*16, b, 0, b.length);
ep = this.expand(b);
v = this.cf(v, ep[0], ep[1]);
}
arrayCopy(v, 0, this.vbuf, 0, v.length);
},
/**
* 消息数据拓展函数
* @param b
* @return
*/
expand:function(b) {
var w1 = new Array(68);
var w2 = new Array(64);
arrayCopy(b, 0, w1, 0, b.length);
for(var i = 16;i<w1.length;i++) {
w1[i] = this.p1(w1[i-16]^w1[i-9]^this.cycleLeft(w1[i-3], 15))^this.cycleLeft(w1[i-13],7)^w1[i-6];
}
for(var i = 0;i<w2.length;i++) {
w2[i] = w1[i]^w1[i+4];
}
return new Array(w1,w2);
},
/**
* 迭代压缩函数
*
* @param v
* @param w1
* @param w2
* @return
*/
cf:function(v,w1,w2) {
var result;
var a,b,c,d,e,f,g,h,ss1,ss2,tt1,tt2;
a = v[0];
b = v[1];
c = v[2];
d = v[3];
e = v[4];
f = v[5];
g = v[6];
h = v[7];
for(var i = 0;i<64;i++) {
ss1 = this.cycleLeft(this.cycleLeft(a, 12)+e+this.cycleLeft(this.tj[i], i),7);
ss2 = ss1^this.cycleLeft(a, 12);
tt1 = this.ffj(a, b, c,i)+d+ss2+w2[i];
tt2 = this.ggj(e,f,g,i)+h+ss1+w1[i];
d = c;
c = this.cycleLeft(b, 9);
b = a;
a = tt1;
h = g;
g = this.cycleLeft(f, 19);
f = e;
e = this.p0(tt2);
}
result = new Array(8);
result[0] = a^v[0];
result[1] = b^v[1];
result[2] = c^v[2];
result[3] = d^v[3];
result[4] = e^v[4];
result[5] = f^v[5];
result[6] = g^v[6];
result[7] = h^v[7];
return result;
},
digest:function(data) {
var mac;
var padding = this.padding(data);
var paddingInt = byteArrayToIntArray(padding);
this.iterate(paddingInt);
var macInt = this.vbuf;
mac = intArrayToByteArray(macInt);
return mac;
},
update:function(data,pos,len) {
var loop = parseInt((len+this.dataBufLen)/64);//向下取整
this.totalLen += len;
if(len+this.dataBufLen<this.BLOCK_BYTE_LEN) {
arrayCopy(data, 0, this.dataBuf, this.dataBufLen, len);
this.dataBufLen = len+this.dataBufLen;
}else {
var dataInt;
arrayCopy(data, 0 , this.dataBuf, this.dataBufLen, this.BLOCK_BYTE_LEN-this.dataBufLen);
dataInt = byteArrayToIntArray(this.dataBuf);
this.iterate(dataInt);
for(var i = 1;i<loop;i++) {
arrayCopy(data, i*this.BLOCK_BYTE_LEN-this.dataBufLen, this.dataBuf, 0, this.BLOCK_BYTE_LEN);
dataInt = byteArrayToIntArray(this.dataBuf);
this.iterate(dataInt);
}
arrayCopy(data, loop*this.BLOCK_BYTE_LEN-this.dataBufLen , this.dataBuf, 0, len-(loop*this.BLOCK_BYTE_LEN-this.dataBufLen));
this.dataBufLen = len-(loop*this.BLOCK_BYTE_LEN-this.dataBufLen);
}
},
doFinal:function() {
var mac;
var finalData = new Array(this.dataBufLen);
arrayCopy(this.dataBuf, 0, finalData, 0, this.dataBufLen);
//对不足64字节的数据进行填充
var paddingArr = this.padding(finalData);
var paddingInt = byteArrayToIntArray(paddingArr);
this.iterate(paddingInt);
var macInt = this.vbuf;
mac = intArrayToByteArray(macInt);
return mac;
}
}
\ No newline at end of file
/*
* sm4-1.0.js
*
* Copyright (c) 2019 RuXing Liang
*/
/**
* @name sm4-1.0.js
* @author RuXing Liang
* @version 1.0.0 (2019-04-19)
*/
var debug = false;
function SM4(){
this.sbox = new Array(
0xd6,0x90,0xe9,0xfe,0xcc,0xe1,0x3d,0xb7,0x16,0xb6,0x14,0xc2,0x28,0xfb,0x2c,0x05,
0x2b,0x67,0x9a,0x76,0x2a,0xbe,0x04,0xc3,0xaa,0x44,0x13,0x26,0x49,0x86,0x06,0x99,
0x9c,0x42,0x50,0xf4,0x91,0xef,0x98,0x7a,0x33,0x54,0x0b,0x43,0xed,0xcf,0xac,0x62,
0xe4,0xb3,0x1c,0xa9,0xc9,0x08,0xe8,0x95,0x80,0xdf,0x94,0xfa,0x75,0x8f,0x3f,0xa6,
0x47,0x07,0xa7,0xfc,0xf3,0x73,0x17,0xba,0x83,0x59,0x3c,0x19,0xe6,0x85,0x4f,0xa8,
0x68,0x6b,0x81,0xb2,0x71,0x64,0xda,0x8b,0xf8,0xeb,0x0f,0x4b,0x70,0x56,0x9d,0x35,
0x1e,0x24,0x0e,0x5e,0x63,0x58,0xd1,0xa2,0x25,0x22,0x7c,0x3b,0x01,0x21,0x78,0x87,
0xd4,0x00,0x46,0x57,0x9f,0xd3,0x27,0x52,0x4c,0x36,0x02,0xe7,0xa0,0xc4,0xc8,0x9e,
0xea,0xbf,0x8a,0xd2,0x40,0xc7,0x38,0xb5,0xa3,0xf7,0xf2,0xce,0xf9,0x61,0x15,0xa1,
0xe0,0xae,0x5d,0xa4,0x9b,0x34,0x1a,0x55,0xad,0x93,0x32,0x30,0xf5,0x8c,0xb1,0xe3,
0x1d,0xf6,0xe2,0x2e,0x82,0x66,0xca,0x60,0xc0,0x29,0x23,0xab,0x0d,0x53,0x4e,0x6f,
0xd5,0xdb,0x37,0x45,0xde,0xfd,0x8e,0x2f,0x03,0xff,0x6a,0x72,0x6d,0x6c,0x5b,0x51,
0x8d,0x1b,0xaf,0x92,0xbb,0xdd,0xbc,0x7f,0x11,0xd9,0x5c,0x41,0x1f,0x10,0x5a,0xd8,
0x0a,0xc1,0x31,0x88,0xa5,0xcd,0x7b,0xbd,0x2d,0x74,0xd0,0x12,0xb8,0xe5,0xb4,0xb0,
0x89,0x69,0x97,0x4a,0x0c,0x96,0x77,0x7e,0x65,0xb9,0xf1,0x09,0xc5,0x6e,0xc6,0x84,
0x18,0xf0,0x7d,0xec,0x3a,0xdc,0x4d,0x20,0x79,0xee,0x5f,0x3e,0xd7,0xcb,0x39,0x48
);
this.fk = new Array(0xa3b1bac6, 0x56aa3350, 0x677d9197, 0xb27022dc);
this.ck = new Array(
0x00070e15,0x1c232a31,0x383f464d,0x545b6269,
0x70777e85,0x8c939aa1,0xa8afb6bd,0xc4cbd2d9,
0xe0e7eef5,0xfc030a11,0x181f262d,0x343b4249,
0x50575e65,0x6c737a81,0x888f969d,0xa4abb2b9,
0xc0c7ced5,0xdce3eaf1,0xf8ff060d,0x141b2229,
0x30373e45,0x4c535a61,0x686f767d,0x848b9299,
0xa0a7aeb5,0xbcc3cad1,0xd8dfe6ed,0xf4fb0209,
0x10171e25,0x2c333a41,0x484f565d,0x646b7279
);
}
SM4.prototype = {
expandKey:function(key){
var k = new Array(36);
var mk = byteArrayToIntArray(key);
k[0] = mk[0] ^ this.fk[0];
k[1] = mk[1] ^ this.fk[1];
k[2] = mk[2] ^ this.fk[2];
k[3] = mk[3] ^ this.fk[3];
var rk = new Array(32);
for (var i = 0; i < 32; i++)
{
k[(i + 4)] = (k[i] ^ this.T1(k[(i + 1)] ^ k[(i + 2)] ^ k[(i + 3)] ^ this.ck[i]));
rk[i] = k[(i + 4)];
}
return rk;
},
T1:function(ta){
var rk = 0;
var b = new Array(4);
var a = intToByte(ta);
b[0] = this.sbox[a[0] & 0xFF];
b[1] = this.sbox[a[1] & 0xFF];
b[2] = this.sbox[a[2] & 0xFF];
b[3] = this.sbox[a[3] & 0xFF];
var bint = byteToInt(b,0);
var rk = bint ^ (bint<<13|(bint>>>(32-13))) ^ (bint<<23|(bint>>>(32-23)));
return rk;
},
one_encrypt:function(rk, data){
var x = new Array(36);
x[0] = byteToInt(data, 0);
x[1] = byteToInt(data, 4);
x[2] = byteToInt(data, 8);
x[3] = byteToInt(data, 12);
for(var i = 0;i < 32;i++)
{
x[(i + 4)] = x[i] ^ this.T0(x[(i + 1)]^x[(i + 2)]^x[(i + 3)]^rk[i]);
}
var tmpx = new Array(4);
for(var i = 35;i >= 32;i--){
tmpx[35-i] = x[i];
}
var xbyte = intArrayToByteArray(tmpx);
return xbyte;
},
T0:function(ta){
var a = intToByte(ta);
var b = new Array(4);
b[0] = this.sbox[a[0] & 0xFF];
b[1] = this.sbox[a[1] & 0xFF];
b[2] = this.sbox[a[2] & 0xFF];
b[3] = this.sbox[a[3] & 0xFF];
var bint = byteToInt(b,0);
var c = bint ^ (bint<<2|(bint>>>(32-2))) ^ (bint<<10|(bint>>>(32-10))) ^ (bint<<18|(bint>>>(32-18))) ^ (bint<<24|(bint>>>(32-24)));
return c;
},
pkcs7padding:function(input,mode){
if (input == null)
{
return null;
}
var ret = null;
if (mode == 1)//填充
{
var p = 16 - input.length % 16;
ret = new Array(input.length + p);
arrayCopy(input, 0, ret, 0, input.length);
for (var i = 0; i < p; i++)
{
ret[input.length + i] = p;
}
}
else//去除填充
{
var p = input[input.length - 1];
ret = new Array(input.length - p);
arrayCopy(input, 0, ret, 0, input.length - p);
}
return ret;
},
encrypt_ecb:function(key,data){
if(key == undefined || key == null || key.length%16 != 0){
console.log("sm4 key is error!");
return null;
}
if(data == undefined || data == null || data.length <= 0){
console.log("data is error!");
return null;
}
var rk = this.expandKey(key);
/*if(debug){
var rkb = intArrayToByteArray(rk);
console.log(Hex.encode(rkb,0,rkb.length));
}*/
var blockLen = 16;
var loop = parseInt(data.length/blockLen);//注意不能整除会有小数,要取整
var cipher = new Array((loop+1)*blockLen);
var tmp = new Array(blockLen);
var oneCipher = null;
for(var i = 0;i<loop;i++){
arrayCopy(data,i*blockLen,tmp,0,blockLen);
oneCipher = this.one_encrypt(rk,tmp);
arrayCopy(oneCipher,0,cipher,i*blockLen,blockLen);
}
var lessData = new Array(data.length%blockLen);
if(lessData.length > 0){
arrayCopy(data,loop*blockLen,lessData,0,data.length%blockLen);
}
var padding = this.pkcs7padding(lessData,1);
oneCipher = this.one_encrypt(rk,padding);
arrayCopy(oneCipher,0,cipher,loop*blockLen,blockLen);
return cipher;
},
decrypt_ecb:function(key,data){
if(key == undefined || key == null || key.length%16 != 0){
console.log("sm4 key is error!");
return null;
}
if(data == undefined || data == null || data.length%16 != 0){
console.log("data is error!");
return null;
}
var rk = this.expandKey(key);
var nrk = new Array(32);
for(var i = 0;i<rk.length;i++){
nrk[i] = rk[32-i-1];
}
/*if(debug){
var rkb = intArrayToByteArray(rk);
console.log(Hex.encode(rkb,0,rkb.length));
}*/
var blockLen = 16;
var loop = data.length/blockLen - 1;
var tmp = new Array(blockLen);
var onePlain = null;
var plain = null;
//先解密最后一部分,确定数据长度
arrayCopy(data,loop*blockLen,tmp,0,blockLen);
onePlain = this.one_encrypt(nrk,tmp);
var lastPart = this.pkcs7padding(onePlain,0);
plain = new Array(loop*blockLen+lastPart.length);
arrayCopy(lastPart,0,plain,loop*blockLen,lastPart.length);
//解密剩下部分数据
for(var i = 0;i<loop;i++){
arrayCopy(data,i*blockLen,tmp,0,blockLen);
onePlain = this.one_encrypt(nrk,tmp);
arrayCopy(onePlain,0,plain,i*blockLen,blockLen);
}
return plain;
},
encrypt_cbc:function(key,iv,data){
if(key == undefined || key == null || key.length%16 != 0){
console.log("sm4 key is error!");
return null;
}
if(data == undefined || data == null || data.length <= 0){
console.log("data is error!");
return null;
}
if(iv == undefined || iv == null || iv.length%16 != 0){
console.log("iv is error!");
return null;
}
var rk = this.expandKey(key);
/*if(debug){
var rkb = intArrayToByteArray(rk);
console.log(Hex.encode(rkb,0,rkb.length));
}*/
var blockLen = 16;
var loop = parseInt(data.length/blockLen);//注意不能整除会有小数,要取整
var cipher = new Array((loop+1)*blockLen);
var tmp = new Array(blockLen);
var oneCipher = null;
for(var i = 0;i<loop;i++){
arrayCopy(data,i*blockLen,tmp,0,blockLen);
for(var j = 0;j<blockLen;j++){
tmp[j] = tmp[j] ^ iv[j];
}
iv = this.one_encrypt(rk,tmp);
arrayCopy(iv,0,cipher,i*blockLen,blockLen);
}
var lessData = new Array(data.length%blockLen);
if(lessData.length > 0){
arrayCopy(data,loop*blockLen,lessData,0,data.length%blockLen);
}
var padding = this.pkcs7padding(lessData,1);
for(var i = 0;i<blockLen;i++){
padding[i] = padding[i] ^ iv[i];
}
iv = this.one_encrypt(rk,padding);
arrayCopy(iv,0,cipher,loop*blockLen,blockLen);
return cipher;
},
decrypt_cbc:function(key,iv,data){
if(key == undefined || key == null || key.length%16 != 0){
console.log("sm4 key is error!");
return null;
}
if(data == undefined || data == null || data.length%16 != 0){
console.log("data is error!");
return null;
}
if(iv == undefined || iv == null || iv.length%16 != 0){
console.log("iv is error!");
return null;
}
var rk = this.expandKey(key);
var nrk = new Array(32);
for(var i = 0;i<rk.length;i++){
nrk[i] = rk[32-i-1];
}
/*if(debug){
var rkb = intArrayToByteArray(rk);
console.log(Hex.encode(rkb,0,rkb.length));
}*/
var blockLen = 16;
var loop = data.length/blockLen;
var tmp = new Array(blockLen);
var onePlain = null;
var plain = null;
//解密
plain = new Array(data.length);
for(var i = 0;i<loop;i++){
arrayCopy(data,i*blockLen,tmp,0,blockLen);
onePlain = this.one_encrypt(nrk,tmp);
for(var j = 0;j<blockLen;j++){
onePlain[j] = onePlain[j] ^ iv[j];
}
arrayCopy(tmp,0,iv,0,blockLen);
arrayCopy(onePlain,0,plain,i*blockLen,blockLen);
}
//去填充,确定数据长度
//arrayCopy(data,data.length-blockLen,tmp,0,blockLen);
var lastPart = this.pkcs7padding(onePlain,0);
var realPlain = new Array(plain.length-blockLen+lastPart.length);
arrayCopy(plain,0,realPlain,0,plain.length-blockLen);
arrayCopy(lastPart,0,realPlain,plain.length-blockLen,lastPart.length);
//先解密最后一部分,确定数据长度
/*arrayCopy(data,loop*blockLen,tmp,0,blockLen);
onePlain = this.one_encrypt(nrk,tmp);
for(var i = 0;i<blockLen;i++){
onePlain[i] = onePlain[i] ^ iv[i];
}
var lastPart = this.pkcs7padding(onePlain,0);
plain = new Array(loop*blockLen+lastPart.length);
arrayCopy(lastPart,0,plain,loop*blockLen,lastPart.length);
//解密剩下部分数据
for(var i = 0;i<loop;i++){
arrayCopy(data,i*blockLen,tmp,0,blockLen);
onePlain = this.one_encrypt(nrk,tmp);
arrayCopy(onePlain,0,plain,i*blockLen,blockLen);
}*/
return realPlain;
}
}
/*! (c) Stefan Thomas | https://github.com/bitcoinjs/bitcoinjs-lib
*/
/*
* splitted from bitcoin-lib/ecdsa.js
*
* version 1.0.0 is the original of bitcoin-lib/ecdsa.js
*/
ECFieldElementFp.prototype.getByteLength = function () {
return Math.floor((this.toBigInteger().bitLength() + 7) / 8);
};
ECPointFp.prototype.getEncoded = function (compressed) {
var integerToBytes = function(i, len) {
var bytes = i.toByteArrayUnsigned();
if (len < bytes.length) {
bytes = bytes.slice(bytes.length-len);
} else while (len > bytes.length) {
bytes.unshift(0);
}
return bytes;
};
var x = this.getX().toBigInteger();
var y = this.getY().toBigInteger();
// Get value as a 32-byte Buffer
// Fixed length based on a patch by bitaddress.org and Casascius
var enc = integerToBytes(x, 32);
if (compressed) {
if (y.isEven()) {
// Compressed even pubkey
// M = 02 || X
enc.unshift(0x02);
} else {
// Compressed uneven pubkey
// M = 03 || X
enc.unshift(0x03);
}
} else {
// Uncompressed pubkey
// M = 04 || X || Y
enc.unshift(0x04);
enc = enc.concat(integerToBytes(y, 32));
}
return enc;
};
ECPointFp.decodeFrom = function (curve, enc) {
var type = enc[0];
var dataLen = enc.length-1;
// Extract x and y as byte arrays
var xBa = enc.slice(1, 1 + dataLen/2);
var yBa = enc.slice(1 + dataLen/2, 1 + dataLen);
// Prepend zero byte to prevent interpretation as negative integer
xBa.unshift(0);
yBa.unshift(0);
// Convert to BigIntegers
var x = new BigInteger(xBa);
var y = new BigInteger(yBa);
// Return point
return new ECPointFp(curve, curve.fromBigInteger(x), curve.fromBigInteger(y));
};
/*
* @since ec-patch.js 1.0.1
*/
ECPointFp.decodeFromHex = function (curve, encHex) {
var type = encHex.substr(0, 2); // shall be "04"
var dataLen = encHex.length - 2;
// Extract x and y as byte arrays
var xHex = encHex.substr(2, dataLen / 2);
var yHex = encHex.substr(2 + dataLen / 2, dataLen / 2);
// Convert to BigIntegers
var x = new BigInteger(xHex, 16);
var y = new BigInteger(yHex, 16);
// Return point
return new ECPointFp(curve, curve.fromBigInteger(x), curve.fromBigInteger(y));
};
ECPointFp.prototype.add2D = function (b) {
if(this.isInfinity()) return b;
if(b.isInfinity()) return this;
if (this.x.equals(b.x)) {
if (this.y.equals(b.y)) {
// this = b, i.e. this must be doubled
return this.twice();
}
// this = -b, i.e. the result is the point at infinity
return this.curve.getInfinity();
}
var x_x = b.x.subtract(this.x);
var y_y = b.y.subtract(this.y);
var gamma = y_y.divide(x_x);
var x3 = gamma.square().subtract(this.x).subtract(b.x);
var y3 = gamma.multiply(this.x.subtract(x3)).subtract(this.y);
return new ECPointFp(this.curve, x3, y3);
};
ECPointFp.prototype.twice2D = function () {
if (this.isInfinity()) return this;
if (this.y.toBigInteger().signum() == 0) {
// if y1 == 0, then (x1, y1) == (x1, -y1)
// and hence this = -this and thus 2(x1, y1) == infinity
return this.curve.getInfinity();
}
var TWO = this.curve.fromBigInteger(BigInteger.valueOf(2));
var THREE = this.curve.fromBigInteger(BigInteger.valueOf(3));
var gamma = this.x.square().multiply(THREE).add(this.curve.a).divide(this.y.multiply(TWO));
var x3 = gamma.square().subtract(this.x.multiply(TWO));
var y3 = gamma.multiply(this.x.subtract(x3)).subtract(this.y);
return new ECPointFp(this.curve, x3, y3);
};
ECPointFp.prototype.multiply2D = function (k) {
if(this.isInfinity()) return this;
if(k.signum() == 0) return this.curve.getInfinity();
var e = k;
var h = e.multiply(new BigInteger("3"));
var neg = this.negate();
var R = this;
var i;
for (i = h.bitLength() - 2; i > 0; --i) {
R = R.twice();
var hBit = h.testBit(i);
var eBit = e.testBit(i);
if (hBit != eBit) {
R = R.add2D(hBit ? this : neg);
}
}
return R;
};
ECPointFp.prototype.isOnCurve = function () {
var x = this.getX().toBigInteger();
var y = this.getY().toBigInteger();
var a = this.curve.getA().toBigInteger();
var b = this.curve.getB().toBigInteger();
var n = this.curve.getQ();
var lhs = y.multiply(y).mod(n);
var rhs = x.multiply(x).multiply(x)
.add(a.multiply(x)).add(b).mod(n);
return lhs.equals(rhs);
};
ECPointFp.prototype.toString = function () {
return '('+this.getX().toBigInteger().toString()+','+
this.getY().toBigInteger().toString()+')';
};
/**
* Validate an elliptic curve point.
*
* See SEC 1, section 3.2.2.1: Elliptic Curve Public Key Validation Primitive
*/
ECPointFp.prototype.validate = function () {
var n = this.curve.getQ();
// Check Q != O
if (this.isInfinity()) {
throw new Error("Point is at infinity.");
}
// Check coordinate bounds
var x = this.getX().toBigInteger();
var y = this.getY().toBigInteger();
if (x.compareTo(BigInteger.ONE) < 0 ||
x.compareTo(n.subtract(BigInteger.ONE)) > 0) {
throw new Error('x coordinate out of bounds');
}
if (y.compareTo(BigInteger.ONE) < 0 ||
y.compareTo(n.subtract(BigInteger.ONE)) > 0) {
throw new Error('y coordinate out of bounds');
}
// Check y^2 = x^3 + ax + b (mod n)
if (!this.isOnCurve()) {
throw new Error("Point is not on the curve.");
}
// Check nQ = 0 (Q is a scalar multiple of G)
if (this.multiply(n).isInfinity()) {
// TODO: This check doesn't work - fix.
throw new Error("Point is not a scalar multiple of G.");
}
return true;
};
/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/
*/
// Basic Javascript Elliptic Curve implementation
// Ported loosely from BouncyCastle's Java EC code
// Only Fp curves implemented for now
// Requires jsbn.js and jsbn2.js
// ----------------
// ECFieldElementFp
// constructor
function ECFieldElementFp(q,x) {
this.x = x;
// TODO if(x.compareTo(q) >= 0) error
this.q = q;
}
function feFpEquals(other) {
if(other == this) return true;
return (this.q.equals(other.q) && this.x.equals(other.x));
}
function feFpToBigInteger() {
return this.x;
}
function feFpNegate() {
return new ECFieldElementFp(this.q, this.x.negate().mod(this.q));
}
function feFpAdd(b) {
return new ECFieldElementFp(this.q, this.x.add(b.toBigInteger()).mod(this.q));
}
function feFpSubtract(b) {
return new ECFieldElementFp(this.q, this.x.subtract(b.toBigInteger()).mod(this.q));
}
function feFpMultiply(b) {
return new ECFieldElementFp(this.q, this.x.multiply(b.toBigInteger()).mod(this.q));
}
function feFpSquare() {
return new ECFieldElementFp(this.q, this.x.square().mod(this.q));
}
function feFpDivide(b) {
return new ECFieldElementFp(this.q, this.x.multiply(b.toBigInteger().modInverse(this.q)).mod(this.q));
}
ECFieldElementFp.prototype.equals = feFpEquals;
ECFieldElementFp.prototype.toBigInteger = feFpToBigInteger;
ECFieldElementFp.prototype.negate = feFpNegate;
ECFieldElementFp.prototype.add = feFpAdd;
ECFieldElementFp.prototype.subtract = feFpSubtract;
ECFieldElementFp.prototype.multiply = feFpMultiply;
ECFieldElementFp.prototype.square = feFpSquare;
ECFieldElementFp.prototype.divide = feFpDivide;
// ----------------
// ECPointFp
// constructor
function ECPointFp(curve,x,y,z) {
this.curve = curve;
this.x = x;
this.y = y;
// Projective coordinates: either zinv == null or z * zinv == 1
// z and zinv are just BigIntegers, not fieldElements
if(z == null) {
this.z = BigInteger.ONE;
}
else {
this.z = z;
}
this.zinv = null;
//TODO: compression flag
}
function pointFpGetX() {
if(this.zinv == null) {
this.zinv = this.z.modInverse(this.curve.q);
}
return this.curve.fromBigInteger(this.x.toBigInteger().multiply(this.zinv).mod(this.curve.q));
}
function pointFpGetY() {
if(this.zinv == null) {
this.zinv = this.z.modInverse(this.curve.q);
}
return this.curve.fromBigInteger(this.y.toBigInteger().multiply(this.zinv).mod(this.curve.q));
}
function pointFpEquals(other) {
if(other == this) return true;
if(this.isInfinity()) return other.isInfinity();
if(other.isInfinity()) return this.isInfinity();
var u, v;
// u = Y2 * Z1 - Y1 * Z2
u = other.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(other.z)).mod(this.curve.q);
if(!u.equals(BigInteger.ZERO)) return false;
// v = X2 * Z1 - X1 * Z2
v = other.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(other.z)).mod(this.curve.q);
return v.equals(BigInteger.ZERO);
}
function pointFpIsInfinity() {
if((this.x == null) && (this.y == null)) return true;
return this.z.equals(BigInteger.ZERO) && !this.y.toBigInteger().equals(BigInteger.ZERO);
}
function pointFpNegate() {
return new ECPointFp(this.curve, this.x, this.y.negate(), this.z);
}
function pointFpAdd(b) {
if(this.isInfinity()) return b;
if(b.isInfinity()) return this;
// u = Y2 * Z1 - Y1 * Z2
var u = b.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(b.z)).mod(this.curve.q);
// v = X2 * Z1 - X1 * Z2
var v = b.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(b.z)).mod(this.curve.q);
if(BigInteger.ZERO.equals(v)) {
if(BigInteger.ZERO.equals(u)) {
return this.twice(); // this == b, so double
}
return this.curve.getInfinity(); // this = -b, so infinity
}
var THREE = new BigInteger("3");
var x1 = this.x.toBigInteger();
var y1 = this.y.toBigInteger();
var x2 = b.x.toBigInteger();
var y2 = b.y.toBigInteger();
var v2 = v.square();
var v3 = v2.multiply(v);
var x1v2 = x1.multiply(v2);
var zu2 = u.square().multiply(this.z);
// x3 = v * (z2 * (z1 * u^2 - 2 * x1 * v^2) - v^3)
var x3 = zu2.subtract(x1v2.shiftLeft(1)).multiply(b.z).subtract(v3).multiply(v).mod(this.curve.q);
// y3 = z2 * (3 * x1 * u * v^2 - y1 * v^3 - z1 * u^3) + u * v^3
var y3 = x1v2.multiply(THREE).multiply(u).subtract(y1.multiply(v3)).subtract(zu2.multiply(u)).multiply(b.z).add(u.multiply(v3)).mod(this.curve.q);
// z3 = v^3 * z1 * z2
var z3 = v3.multiply(this.z).multiply(b.z).mod(this.curve.q);
return new ECPointFp(this.curve, this.curve.fromBigInteger(x3), this.curve.fromBigInteger(y3), z3);
}
function pointFpTwice() {
if(this.isInfinity()) return this;
if(this.y.toBigInteger().signum() == 0) return this.curve.getInfinity();
// TODO: optimized handling of constants
var THREE = new BigInteger("3");
var x1 = this.x.toBigInteger();
var y1 = this.y.toBigInteger();
var y1z1 = y1.multiply(this.z);
var y1sqz1 = y1z1.multiply(y1).mod(this.curve.q);
var a = this.curve.a.toBigInteger();
// w = 3 * x1^2 + a * z1^2
var w = x1.square().multiply(THREE);
if(!BigInteger.ZERO.equals(a)) {
w = w.add(this.z.square().multiply(a));
}
w = w.mod(this.curve.q);
// x3 = 2 * y1 * z1 * (w^2 - 8 * x1 * y1^2 * z1)
var x3 = w.square().subtract(x1.shiftLeft(3).multiply(y1sqz1)).shiftLeft(1).multiply(y1z1).mod(this.curve.q);
// y3 = 4 * y1^2 * z1 * (3 * w * x1 - 2 * y1^2 * z1) - w^3
var y3 = w.multiply(THREE).multiply(x1).subtract(y1sqz1.shiftLeft(1)).shiftLeft(2).multiply(y1sqz1).subtract(w.square().multiply(w)).mod(this.curve.q);
// z3 = 8 * (y1 * z1)^3
var z3 = y1z1.square().multiply(y1z1).shiftLeft(3).mod(this.curve.q);
return new ECPointFp(this.curve, this.curve.fromBigInteger(x3), this.curve.fromBigInteger(y3), z3);
}
// Simple NAF (Non-Adjacent Form) multiplication algorithm
// TODO: modularize the multiplication algorithm
function pointFpMultiply(k) {
if(this.isInfinity()) return this;
if(k.signum() == 0) return this.curve.getInfinity();
var e = k;
var h = e.multiply(new BigInteger("3"));
var neg = this.negate();
var R = this;
var i;
for(i = h.bitLength() - 2; i > 0; --i) {
R = R.twice();
var hBit = h.testBit(i);
var eBit = e.testBit(i);
if (hBit != eBit) {
R = R.add(hBit ? this : neg);
}
}
return R;
}
// Compute this*j + x*k (simultaneous multiplication)
function pointFpMultiplyTwo(j,x,k) {
var i;
if(j.bitLength() > k.bitLength())
i = j.bitLength() - 1;
else
i = k.bitLength() - 1;
var R = this.curve.getInfinity();
var both = this.add(x);
while(i >= 0) {
R = R.twice();
if(j.testBit(i)) {
if(k.testBit(i)) {
R = R.add(both);
}
else {
R = R.add(this);
}
}
else {
if(k.testBit(i)) {
R = R.add(x);
}
}
--i;
}
return R;
}
ECPointFp.prototype.getX = pointFpGetX;
ECPointFp.prototype.getY = pointFpGetY;
ECPointFp.prototype.equals = pointFpEquals;
ECPointFp.prototype.isInfinity = pointFpIsInfinity;
ECPointFp.prototype.negate = pointFpNegate;
ECPointFp.prototype.add = pointFpAdd;
ECPointFp.prototype.twice = pointFpTwice;
ECPointFp.prototype.multiply = pointFpMultiply;
ECPointFp.prototype.multiplyTwo = pointFpMultiplyTwo;
// ----------------
// ECCurveFp
// constructor
function ECCurveFp(q,a,b) {
this.q = q;
this.a = this.fromBigInteger(a);
this.b = this.fromBigInteger(b);
this.infinity = new ECPointFp(this, null, null);
}
function curveFpGetQ() {
return this.q;
}
function curveFpGetA() {
return this.a;
}
function curveFpGetB() {
return this.b;
}
function curveFpEquals(other) {
if(other == this) return true;
return(this.q.equals(other.q) && this.a.equals(other.a) && this.b.equals(other.b));
}
function curveFpGetInfinity() {
return this.infinity;
}
function curveFpFromBigInteger(x) {
return new ECFieldElementFp(this.q, x);
}
// for now, work with hex strings because they're easier in JS
function curveFpDecodePointHex(s) {
switch(parseInt(s.substr(0,2), 16)) { // first byte
case 0:
return this.infinity;
case 2:
case 3:
// point compression not supported yet
return null;
case 4:
case 6:
case 7:
var len = (s.length - 2) / 2;
var xHex = s.substr(2, len);
var yHex = s.substr(len+2, len);
return new ECPointFp(this,
this.fromBigInteger(new BigInteger(xHex, 16)),
this.fromBigInteger(new BigInteger(yHex, 16)));
default: // unsupported
return null;
}
}
ECCurveFp.prototype.getQ = curveFpGetQ;
ECCurveFp.prototype.getA = curveFpGetA;
ECCurveFp.prototype.getB = curveFpGetB;
ECCurveFp.prototype.equals = curveFpEquals;
ECCurveFp.prototype.getInfinity = curveFpGetInfinity;
ECCurveFp.prototype.fromBigInteger = curveFpFromBigInteger;
ECCurveFp.prototype.decodePointHex = curveFpDecodePointHex;
/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/
*/
// Copyright (c) 2005 Tom Wu
// All Rights Reserved.
// See "LICENSE" for details.
// Basic JavaScript BN library - subset useful for RSA encryption.
// Bits per digit
var dbits;
// JavaScript engine analysis
var canary = 0xdeadbeefcafe;
var j_lm = ((canary&0xffffff)==0xefcafe);
// (public) Constructor
function BigInteger(a,b,c) {
if(a != null)
if("number" == typeof a) this.fromNumber(a,b,c);
else if(b == null && "string" != typeof a) this.fromString(a,256);
else this.fromString(a,b);
}
// return new, unset BigInteger
function nbi() { return new BigInteger(null); }
// am: Compute w_j += (x*this_i), propagate carries,
// c is initial carry, returns final carry.
// c < 3*dvalue, x < 2*dvalue, this_i < dvalue
// We need to select the fastest one that works in this environment.
// am1: use a single mult and divide to get the high bits,
// max digit bits should be 26 because
// max internal value = 2*dvalue^2-2*dvalue (< 2^53)
function am1(i,x,w,j,c,n) {
while(--n >= 0) {
var v = x*this[i++]+w[j]+c;
c = Math.floor(v/0x4000000);
w[j++] = v&0x3ffffff;
}
return c;
}
// am2 avoids a big mult-and-extract completely.
// Max digit bits should be <= 30 because we do bitwise ops
// on values up to 2*hdvalue^2-hdvalue-1 (< 2^31)
function am2(i,x,w,j,c,n) {
var xl = x&0x7fff, xh = x>>15;
while(--n >= 0) {
var l = this[i]&0x7fff;
var h = this[i++]>>15;
var m = xh*l+h*xl;
l = xl*l+((m&0x7fff)<<15)+w[j]+(c&0x3fffffff);
c = (l>>>30)+(m>>>15)+xh*h+(c>>>30);
w[j++] = l&0x3fffffff;
}
return c;
}
// Alternately, set max digit bits to 28 since some
// browsers slow down when dealing with 32-bit numbers.
function am3(i,x,w,j,c,n) {
var xl = x&0x3fff, xh = x>>14;
while(--n >= 0) {
var l = this[i]&0x3fff;
var h = this[i++]>>14;
var m = xh*l+h*xl;
l = xl*l+((m&0x3fff)<<14)+w[j]+c;
c = (l>>28)+(m>>14)+xh*h;
w[j++] = l&0xfffffff;
}
return c;
}
if(j_lm && (navigator.appName == "Microsoft Internet Explorer")) {
BigInteger.prototype.am = am2;
dbits = 30;
}
else if(j_lm && (navigator.appName != "Netscape")) {
BigInteger.prototype.am = am1;
dbits = 26;
}
else { // Mozilla/Netscape seems to prefer am3
BigInteger.prototype.am = am3;
dbits = 28;
}
BigInteger.prototype.DB = dbits;
BigInteger.prototype.DM = ((1<<dbits)-1);
BigInteger.prototype.DV = (1<<dbits);
var BI_FP = 52;
BigInteger.prototype.FV = Math.pow(2,BI_FP);
BigInteger.prototype.F1 = BI_FP-dbits;
BigInteger.prototype.F2 = 2*dbits-BI_FP;
// Digit conversions
var BI_RM = "0123456789abcdefghijklmnopqrstuvwxyz";
var BI_RC = new Array();
var rr,vv;
rr = "0".charCodeAt(0);
for(vv = 0; vv <= 9; ++vv) BI_RC[rr++] = vv;
rr = "a".charCodeAt(0);
for(vv = 10; vv < 36; ++vv) BI_RC[rr++] = vv;
rr = "A".charCodeAt(0);
for(vv = 10; vv < 36; ++vv) BI_RC[rr++] = vv;
function int2char(n) { return BI_RM.charAt(n); }
function intAt(s,i) {
var c = BI_RC[s.charCodeAt(i)];
return (c==null)?-1:c;
}
// (protected) copy this to r
function bnpCopyTo(r) {
for(var i = this.t-1; i >= 0; --i) r[i] = this[i];
r.t = this.t;
r.s = this.s;
}
// (protected) set from integer value x, -DV <= x < DV
function bnpFromInt(x) {
this.t = 1;
this.s = (x<0)?-1:0;
if(x > 0) this[0] = x;
else if(x < -1) this[0] = x+this.DV;
else this.t = 0;
}
// return bigint initialized to value
function nbv(i) { var r = nbi(); r.fromInt(i); return r; }
// (protected) set from string and radix
function bnpFromString(s,b) {
var k;
if(b == 16) k = 4;
else if(b == 8) k = 3;
else if(b == 256) k = 8; // byte array
else if(b == 2) k = 1;
else if(b == 32) k = 5;
else if(b == 4) k = 2;
else { this.fromRadix(s,b); return; }
this.t = 0;
this.s = 0;
var i = s.length, mi = false, sh = 0;
while(--i >= 0) {
var x = (k==8)?s[i]&0xff:intAt(s,i);
if(x < 0) {
if(s.charAt(i) == "-") mi = true;
continue;
}
mi = false;
if(sh == 0)
this[this.t++] = x;
else if(sh+k > this.DB) {
this[this.t-1] |= (x&((1<<(this.DB-sh))-1))<<sh;
this[this.t++] = (x>>(this.DB-sh));
}
else
this[this.t-1] |= x<<sh;
sh += k;
if(sh >= this.DB) sh -= this.DB;
}
if(k == 8 && (s[0]&0x80) != 0) {
this.s = -1;
if(sh > 0) this[this.t-1] |= ((1<<(this.DB-sh))-1)<<sh;
}
this.clamp();
if(mi) BigInteger.ZERO.subTo(this,this);
}
// (protected) clamp off excess high words
function bnpClamp() {
var c = this.s&this.DM;
while(this.t > 0 && this[this.t-1] == c) --this.t;
}
// (public) return string representation in given radix
function bnToString(b) {
if(this.s < 0) return "-"+this.negate().toString(b);
var k;
if(b == 16) k = 4;
else if(b == 8) k = 3;
else if(b == 2) k = 1;
else if(b == 32) k = 5;
else if(b == 4) k = 2;
else return this.toRadix(b);
var km = (1<<k)-1, d, m = false, r = "", i = this.t;
var p = this.DB-(i*this.DB)%k;
if(i-- > 0) {
if(p < this.DB && (d = this[i]>>p) > 0) { m = true; r = int2char(d); }
while(i >= 0) {
if(p < k) {
d = (this[i]&((1<<p)-1))<<(k-p);
d |= this[--i]>>(p+=this.DB-k);
}
else {
d = (this[i]>>(p-=k))&km;
if(p <= 0) { p += this.DB; --i; }
}
if(d > 0) m = true;
if(m) r += int2char(d);
}
}
return m?r:"0";
}
// (public) -this
function bnNegate() { var r = nbi(); BigInteger.ZERO.subTo(this,r); return r; }
// (public) |this|
function bnAbs() { return (this.s<0)?this.negate():this; }
// (public) return + if this > a, - if this < a, 0 if equal
function bnCompareTo(a) {
var r = this.s-a.s;
if(r != 0) return r;
var i = this.t;
r = i-a.t;
if(r != 0) return (this.s<0)?-r:r;
while(--i >= 0) if((r=this[i]-a[i]) != 0) return r;
return 0;
}
// returns bit length of the integer x
function nbits(x) {
var r = 1, t;
if((t=x>>>16) != 0) { x = t; r += 16; }
if((t=x>>8) != 0) { x = t; r += 8; }
if((t=x>>4) != 0) { x = t; r += 4; }
if((t=x>>2) != 0) { x = t; r += 2; }
if((t=x>>1) != 0) { x = t; r += 1; }
return r;
}
// (public) return the number of bits in "this"
function bnBitLength() {
if(this.t <= 0) return 0;
return this.DB*(this.t-1)+nbits(this[this.t-1]^(this.s&this.DM));
}
// (protected) r = this << n*DB
function bnpDLShiftTo(n,r) {
var i;
for(i = this.t-1; i >= 0; --i) r[i+n] = this[i];
for(i = n-1; i >= 0; --i) r[i] = 0;
r.t = this.t+n;
r.s = this.s;
}
// (protected) r = this >> n*DB
function bnpDRShiftTo(n,r) {
for(var i = n; i < this.t; ++i) r[i-n] = this[i];
r.t = Math.max(this.t-n,0);
r.s = this.s;
}
// (protected) r = this << n
function bnpLShiftTo(n,r) {
var bs = n%this.DB;
var cbs = this.DB-bs;
var bm = (1<<cbs)-1;
var ds = Math.floor(n/this.DB), c = (this.s<<bs)&this.DM, i;
for(i = this.t-1; i >= 0; --i) {
r[i+ds+1] = (this[i]>>cbs)|c;
c = (this[i]&bm)<<bs;
}
for(i = ds-1; i >= 0; --i) r[i] = 0;
r[ds] = c;
r.t = this.t+ds+1;
r.s = this.s;
r.clamp();
}
// (protected) r = this >> n
function bnpRShiftTo(n,r) {
r.s = this.s;
var ds = Math.floor(n/this.DB);
if(ds >= this.t) { r.t = 0; return; }
var bs = n%this.DB;
var cbs = this.DB-bs;
var bm = (1<<bs)-1;
r[0] = this[ds]>>bs;
for(var i = ds+1; i < this.t; ++i) {
r[i-ds-1] |= (this[i]&bm)<<cbs;
r[i-ds] = this[i]>>bs;
}
if(bs > 0) r[this.t-ds-1] |= (this.s&bm)<<cbs;
r.t = this.t-ds;
r.clamp();
}
// (protected) r = this - a
function bnpSubTo(a,r) {
var i = 0, c = 0, m = Math.min(a.t,this.t);
while(i < m) {
c += this[i]-a[i];
r[i++] = c&this.DM;
c >>= this.DB;
}
if(a.t < this.t) {
c -= a.s;
while(i < this.t) {
c += this[i];
r[i++] = c&this.DM;
c >>= this.DB;
}
c += this.s;
}
else {
c += this.s;
while(i < a.t) {
c -= a[i];
r[i++] = c&this.DM;
c >>= this.DB;
}
c -= a.s;
}
r.s = (c<0)?-1:0;
if(c < -1) r[i++] = this.DV+c;
else if(c > 0) r[i++] = c;
r.t = i;
r.clamp();
}
// (protected) r = this * a, r != this,a (HAC 14.12)
// "this" should be the larger one if appropriate.
function bnpMultiplyTo(a,r) {
var x = this.abs(), y = a.abs();
var i = x.t;
r.t = i+y.t;
while(--i >= 0) r[i] = 0;
for(i = 0; i < y.t; ++i) r[i+x.t] = x.am(0,y[i],r,i,0,x.t);
r.s = 0;
r.clamp();
if(this.s != a.s) BigInteger.ZERO.subTo(r,r);
}
// (protected) r = this^2, r != this (HAC 14.16)
function bnpSquareTo(r) {
var x = this.abs();
var i = r.t = 2*x.t;
while(--i >= 0) r[i] = 0;
for(i = 0; i < x.t-1; ++i) {
var c = x.am(i,x[i],r,2*i,0,1);
if((r[i+x.t]+=x.am(i+1,2*x[i],r,2*i+1,c,x.t-i-1)) >= x.DV) {
r[i+x.t] -= x.DV;
r[i+x.t+1] = 1;
}
}
if(r.t > 0) r[r.t-1] += x.am(i,x[i],r,2*i,0,1);
r.s = 0;
r.clamp();
}
// (protected) divide this by m, quotient and remainder to q, r (HAC 14.20)
// r != q, this != m. q or r may be null.
function bnpDivRemTo(m,q,r) {
var pm = m.abs();
if(pm.t <= 0) return;
var pt = this.abs();
if(pt.t < pm.t) {
if(q != null) q.fromInt(0);
if(r != null) this.copyTo(r);
return;
}
if(r == null) r = nbi();
var y = nbi(), ts = this.s, ms = m.s;
var nsh = this.DB-nbits(pm[pm.t-1]); // normalize modulus
if(nsh > 0) { pm.lShiftTo(nsh,y); pt.lShiftTo(nsh,r); }
else { pm.copyTo(y); pt.copyTo(r); }
var ys = y.t;
var y0 = y[ys-1];
if(y0 == 0) return;
var yt = y0*(1<<this.F1)+((ys>1)?y[ys-2]>>this.F2:0);
var d1 = this.FV/yt, d2 = (1<<this.F1)/yt, e = 1<<this.F2;
var i = r.t, j = i-ys, t = (q==null)?nbi():q;
y.dlShiftTo(j,t);
if(r.compareTo(t) >= 0) {
r[r.t++] = 1;
r.subTo(t,r);
}
BigInteger.ONE.dlShiftTo(ys,t);
t.subTo(y,y); // "negative" y so we can replace sub with am later
while(y.t < ys) y[y.t++] = 0;
while(--j >= 0) {
// Estimate quotient digit
var qd = (r[--i]==y0)?this.DM:Math.floor(r[i]*d1+(r[i-1]+e)*d2);
if((r[i]+=y.am(0,qd,r,j,0,ys)) < qd) { // Try it out
y.dlShiftTo(j,t);
r.subTo(t,r);
while(r[i] < --qd) r.subTo(t,r);
}
}
if(q != null) {
r.drShiftTo(ys,q);
if(ts != ms) BigInteger.ZERO.subTo(q,q);
}
r.t = ys;
r.clamp();
if(nsh > 0) r.rShiftTo(nsh,r); // Denormalize remainder
if(ts < 0) BigInteger.ZERO.subTo(r,r);
}
// (public) this mod a
function bnMod(a) {
var r = nbi();
this.abs().divRemTo(a,null,r);
if(this.s < 0 && r.compareTo(BigInteger.ZERO) > 0) a.subTo(r,r);
return r;
}
// Modular reduction using "classic" algorithm
function Classic(m) { this.m = m; }
function cConvert(x) {
if(x.s < 0 || x.compareTo(this.m) >= 0) return x.mod(this.m);
else return x;
}
function cRevert(x) { return x; }
function cReduce(x) { x.divRemTo(this.m,null,x); }
function cMulTo(x,y,r) { x.multiplyTo(y,r); this.reduce(r); }
function cSqrTo(x,r) { x.squareTo(r); this.reduce(r); }
Classic.prototype.convert = cConvert;
Classic.prototype.revert = cRevert;
Classic.prototype.reduce = cReduce;
Classic.prototype.mulTo = cMulTo;
Classic.prototype.sqrTo = cSqrTo;
// (protected) return "-1/this % 2^DB"; useful for Mont. reduction
// justification:
// xy == 1 (mod m)
// xy = 1+km
// xy(2-xy) = (1+km)(1-km)
// x[y(2-xy)] = 1-k^2m^2
// x[y(2-xy)] == 1 (mod m^2)
// if y is 1/x mod m, then y(2-xy) is 1/x mod m^2
// should reduce x and y(2-xy) by m^2 at each step to keep size bounded.
// JS multiply "overflows" differently from C/C++, so care is needed here.
function bnpInvDigit() {
if(this.t < 1) return 0;
var x = this[0];
if((x&1) == 0) return 0;
var y = x&3; // y == 1/x mod 2^2
y = (y*(2-(x&0xf)*y))&0xf; // y == 1/x mod 2^4
y = (y*(2-(x&0xff)*y))&0xff; // y == 1/x mod 2^8
y = (y*(2-(((x&0xffff)*y)&0xffff)))&0xffff; // y == 1/x mod 2^16
// last step - calculate inverse mod DV directly;
// assumes 16 < DB <= 32 and assumes ability to handle 48-bit ints
y = (y*(2-x*y%this.DV))%this.DV; // y == 1/x mod 2^dbits
// we really want the negative inverse, and -DV < y < DV
return (y>0)?this.DV-y:-y;
}
// Montgomery reduction
function Montgomery(m) {
this.m = m;
this.mp = m.invDigit();
this.mpl = this.mp&0x7fff;
this.mph = this.mp>>15;
this.um = (1<<(m.DB-15))-1;
this.mt2 = 2*m.t;
}
// xR mod m
function montConvert(x) {
var r = nbi();
x.abs().dlShiftTo(this.m.t,r);
r.divRemTo(this.m,null,r);
if(x.s < 0 && r.compareTo(BigInteger.ZERO) > 0) this.m.subTo(r,r);
return r;
}
// x/R mod m
function montRevert(x) {
var r = nbi();
x.copyTo(r);
this.reduce(r);
return r;
}
// x = x/R mod m (HAC 14.32)
function montReduce(x) {
while(x.t <= this.mt2) // pad x so am has enough room later
x[x.t++] = 0;
for(var i = 0; i < this.m.t; ++i) {
// faster way of calculating u0 = x[i]*mp mod DV
var j = x[i]&0x7fff;
var u0 = (j*this.mpl+(((j*this.mph+(x[i]>>15)*this.mpl)&this.um)<<15))&x.DM;
// use am to combine the multiply-shift-add into one call
j = i+this.m.t;
x[j] += this.m.am(0,u0,x,i,0,this.m.t);
// propagate carry
while(x[j] >= x.DV) { x[j] -= x.DV; x[++j]++; }
}
x.clamp();
x.drShiftTo(this.m.t,x);
if(x.compareTo(this.m) >= 0) x.subTo(this.m,x);
}
// r = "x^2/R mod m"; x != r
function montSqrTo(x,r) { x.squareTo(r); this.reduce(r); }
// r = "xy/R mod m"; x,y != r
function montMulTo(x,y,r) { x.multiplyTo(y,r); this.reduce(r); }
Montgomery.prototype.convert = montConvert;
Montgomery.prototype.revert = montRevert;
Montgomery.prototype.reduce = montReduce;
Montgomery.prototype.mulTo = montMulTo;
Montgomery.prototype.sqrTo = montSqrTo;
// (protected) true iff this is even
function bnpIsEven() { return ((this.t>0)?(this[0]&1):this.s) == 0; }
// (protected) this^e, e < 2^32, doing sqr and mul with "r" (HAC 14.79)
function bnpExp(e,z) {
if(e > 0xffffffff || e < 1) return BigInteger.ONE;
var r = nbi(), r2 = nbi(), g = z.convert(this), i = nbits(e)-1;
g.copyTo(r);
while(--i >= 0) {
z.sqrTo(r,r2);
if((e&(1<<i)) > 0) z.mulTo(r2,g,r);
else { var t = r; r = r2; r2 = t; }
}
return z.revert(r);
}
// (public) this^e % m, 0 <= e < 2^32
function bnModPowInt(e,m) {
var z;
if(e < 256 || m.isEven()) z = new Classic(m); else z = new Montgomery(m);
return this.exp(e,z);
}
// protected
BigInteger.prototype.copyTo = bnpCopyTo;
BigInteger.prototype.fromInt = bnpFromInt;
BigInteger.prototype.fromString = bnpFromString;
BigInteger.prototype.clamp = bnpClamp;
BigInteger.prototype.dlShiftTo = bnpDLShiftTo;
BigInteger.prototype.drShiftTo = bnpDRShiftTo;
BigInteger.prototype.lShiftTo = bnpLShiftTo;
BigInteger.prototype.rShiftTo = bnpRShiftTo;
BigInteger.prototype.subTo = bnpSubTo;
BigInteger.prototype.multiplyTo = bnpMultiplyTo;
BigInteger.prototype.squareTo = bnpSquareTo;
BigInteger.prototype.divRemTo = bnpDivRemTo;
BigInteger.prototype.invDigit = bnpInvDigit;
BigInteger.prototype.isEven = bnpIsEven;
BigInteger.prototype.exp = bnpExp;
// public
BigInteger.prototype.toString = bnToString;
BigInteger.prototype.negate = bnNegate;
BigInteger.prototype.abs = bnAbs;
BigInteger.prototype.compareTo = bnCompareTo;
BigInteger.prototype.bitLength = bnBitLength;
BigInteger.prototype.mod = bnMod;
BigInteger.prototype.modPowInt = bnModPowInt;
// "constants"
BigInteger.ZERO = nbv(0);
BigInteger.ONE = nbv(1);
/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/
*/
// Copyright (c) 2005-2009 Tom Wu
// All Rights Reserved.
// See "LICENSE" for details.
// Extended JavaScript BN functions, required for RSA private ops.
// Version 1.1: new BigInteger("0", 10) returns "proper" zero
// Version 1.2: square() API, isProbablePrime fix
// (public)
function bnClone() { var r = nbi(); this.copyTo(r); return r; }
// (public) return value as integer
function bnIntValue() {
if(this.s < 0) {
if(this.t == 1) return this[0]-this.DV;
else if(this.t == 0) return -1;
}
else if(this.t == 1) return this[0];
else if(this.t == 0) return 0;
// assumes 16 < DB < 32
return ((this[1]&((1<<(32-this.DB))-1))<<this.DB)|this[0];
}
// (public) return value as byte
function bnByteValue() { return (this.t==0)?this.s:(this[0]<<24)>>24; }
// (public) return value as short (assumes DB>=16)
function bnShortValue() { return (this.t==0)?this.s:(this[0]<<16)>>16; }
// (protected) return x s.t. r^x < DV
function bnpChunkSize(r) { return Math.floor(Math.LN2*this.DB/Math.log(r)); }
// (public) 0 if this == 0, 1 if this > 0
function bnSigNum() {
if(this.s < 0) return -1;
else if(this.t <= 0 || (this.t == 1 && this[0] <= 0)) return 0;
else return 1;
}
// (protected) convert to radix string
function bnpToRadix(b) {
if(b == null) b = 10;
if(this.signum() == 0 || b < 2 || b > 36) return "0";
var cs = this.chunkSize(b);
var a = Math.pow(b,cs);
var d = nbv(a), y = nbi(), z = nbi(), r = "";
this.divRemTo(d,y,z);
while(y.signum() > 0) {
r = (a+z.intValue()).toString(b).substr(1) + r;
y.divRemTo(d,y,z);
}
return z.intValue().toString(b) + r;
}
// (protected) convert from radix string
function bnpFromRadix(s,b) {
this.fromInt(0);
if(b == null) b = 10;
var cs = this.chunkSize(b);
var d = Math.pow(b,cs), mi = false, j = 0, w = 0;
for(var i = 0; i < s.length; ++i) {
var x = intAt(s,i);
if(x < 0) {
if(s.charAt(i) == "-" && this.signum() == 0) mi = true;
continue;
}
w = b*w+x;
if(++j >= cs) {
this.dMultiply(d);
this.dAddOffset(w,0);
j = 0;
w = 0;
}
}
if(j > 0) {
this.dMultiply(Math.pow(b,j));
this.dAddOffset(w,0);
}
if(mi) BigInteger.ZERO.subTo(this,this);
}
// (protected) alternate constructor
function bnpFromNumber(a,b,c) {
if("number" == typeof b) {
// new BigInteger(int,int,RNG)
if(a < 2) this.fromInt(1);
else {
this.fromNumber(a,c);
if(!this.testBit(a-1)) // force MSB set
this.bitwiseTo(BigInteger.ONE.shiftLeft(a-1),op_or,this);
if(this.isEven()) this.dAddOffset(1,0); // force odd
while(!this.isProbablePrime(b)) {
this.dAddOffset(2,0);
if(this.bitLength() > a) this.subTo(BigInteger.ONE.shiftLeft(a-1),this);
}
}
}
else {
// new BigInteger(int,RNG)
var x = new Array(), t = a&7;
x.length = (a>>3)+1;
b.nextBytes(x);
if(t > 0) x[0] &= ((1<<t)-1); else x[0] = 0;
this.fromString(x,256);
}
}
// (public) convert to bigendian byte array
function bnToByteArray() {
var i = this.t, r = new Array();
r[0] = this.s;
var p = this.DB-(i*this.DB)%8, d, k = 0;
if(i-- > 0) {
if(p < this.DB && (d = this[i]>>p) != (this.s&this.DM)>>p)
r[k++] = d|(this.s<<(this.DB-p));
while(i >= 0) {
if(p < 8) {
d = (this[i]&((1<<p)-1))<<(8-p);
d |= this[--i]>>(p+=this.DB-8);
}
else {
d = (this[i]>>(p-=8))&0xff;
if(p <= 0) { p += this.DB; --i; }
}
if((d&0x80) != 0) d |= -256;
if(k == 0 && (this.s&0x80) != (d&0x80)) ++k;
if(k > 0 || d != this.s) r[k++] = d;
}
}
return r;
}
function bnEquals(a) { return(this.compareTo(a)==0); }
function bnMin(a) { return(this.compareTo(a)<0)?this:a; }
function bnMax(a) { return(this.compareTo(a)>0)?this:a; }
// (protected) r = this op a (bitwise)
function bnpBitwiseTo(a,op,r) {
var i, f, m = Math.min(a.t,this.t);
for(i = 0; i < m; ++i) r[i] = op(this[i],a[i]);
if(a.t < this.t) {
f = a.s&this.DM;
for(i = m; i < this.t; ++i) r[i] = op(this[i],f);
r.t = this.t;
}
else {
f = this.s&this.DM;
for(i = m; i < a.t; ++i) r[i] = op(f,a[i]);
r.t = a.t;
}
r.s = op(this.s,a.s);
r.clamp();
}
// (public) this & a
function op_and(x,y) { return x&y; }
function bnAnd(a) { var r = nbi(); this.bitwiseTo(a,op_and,r); return r; }
// (public) this | a
function op_or(x,y) { return x|y; }
function bnOr(a) { var r = nbi(); this.bitwiseTo(a,op_or,r); return r; }
// (public) this ^ a
function op_xor(x,y) { return x^y; }
function bnXor(a) { var r = nbi(); this.bitwiseTo(a,op_xor,r); return r; }
// (public) this & ~a
function op_andnot(x,y) { return x&~y; }
function bnAndNot(a) { var r = nbi(); this.bitwiseTo(a,op_andnot,r); return r; }
// (public) ~this
function bnNot() {
var r = nbi();
for(var i = 0; i < this.t; ++i) r[i] = this.DM&~this[i];
r.t = this.t;
r.s = ~this.s;
return r;
}
// (public) this << n
function bnShiftLeft(n) {
var r = nbi();
if(n < 0) this.rShiftTo(-n,r); else this.lShiftTo(n,r);
return r;
}
// (public) this >> n
function bnShiftRight(n) {
var r = nbi();
if(n < 0) this.lShiftTo(-n,r); else this.rShiftTo(n,r);
return r;
}
// return index of lowest 1-bit in x, x < 2^31
function lbit(x) {
if(x == 0) return -1;
var r = 0;
if((x&0xffff) == 0) { x >>= 16; r += 16; }
if((x&0xff) == 0) { x >>= 8; r += 8; }
if((x&0xf) == 0) { x >>= 4; r += 4; }
if((x&3) == 0) { x >>= 2; r += 2; }
if((x&1) == 0) ++r;
return r;
}
// (public) returns index of lowest 1-bit (or -1 if none)
function bnGetLowestSetBit() {
for(var i = 0; i < this.t; ++i)
if(this[i] != 0) return i*this.DB+lbit(this[i]);
if(this.s < 0) return this.t*this.DB;
return -1;
}
// return number of 1 bits in x
function cbit(x) {
var r = 0;
while(x != 0) { x &= x-1; ++r; }
return r;
}
// (public) return number of set bits
function bnBitCount() {
var r = 0, x = this.s&this.DM;
for(var i = 0; i < this.t; ++i) r += cbit(this[i]^x);
return r;
}
// (public) true iff nth bit is set
function bnTestBit(n) {
var j = Math.floor(n/this.DB);
if(j >= this.t) return(this.s!=0);
return((this[j]&(1<<(n%this.DB)))!=0);
}
// (protected) this op (1<<n)
function bnpChangeBit(n,op) {
var r = BigInteger.ONE.shiftLeft(n);
this.bitwiseTo(r,op,r);
return r;
}
// (public) this | (1<<n)
function bnSetBit(n) { return this.changeBit(n,op_or); }
// (public) this & ~(1<<n)
function bnClearBit(n) { return this.changeBit(n,op_andnot); }
// (public) this ^ (1<<n)
function bnFlipBit(n) { return this.changeBit(n,op_xor); }
// (protected) r = this + a
function bnpAddTo(a,r) {
var i = 0, c = 0, m = Math.min(a.t,this.t);
while(i < m) {
c += this[i]+a[i];
r[i++] = c&this.DM;
c >>= this.DB;
}
if(a.t < this.t) {
c += a.s;
while(i < this.t) {
c += this[i];
r[i++] = c&this.DM;
c >>= this.DB;
}
c += this.s;
}
else {
c += this.s;
while(i < a.t) {
c += a[i];
r[i++] = c&this.DM;
c >>= this.DB;
}
c += a.s;
}
r.s = (c<0)?-1:0;
if(c > 0) r[i++] = c;
else if(c < -1) r[i++] = this.DV+c;
r.t = i;
r.clamp();
}
// (public) this + a
function bnAdd(a) { var r = nbi(); this.addTo(a,r); return r; }
// (public) this - a
function bnSubtract(a) { var r = nbi(); this.subTo(a,r); return r; }
// (public) this * a
function bnMultiply(a) { var r = nbi(); this.multiplyTo(a,r); return r; }
// (public) this^2
function bnSquare() { var r = nbi(); this.squareTo(r); return r; }
// (public) this / a
function bnDivide(a) { var r = nbi(); this.divRemTo(a,r,null); return r; }
// (public) this % a
function bnRemainder(a) { var r = nbi(); this.divRemTo(a,null,r); return r; }
// (public) [this/a,this%a]
function bnDivideAndRemainder(a) {
var q = nbi(), r = nbi();
this.divRemTo(a,q,r);
return new Array(q,r);
}
// (protected) this *= n, this >= 0, 1 < n < DV
function bnpDMultiply(n) {
this[this.t] = this.am(0,n-1,this,0,0,this.t);
++this.t;
this.clamp();
}
// (protected) this += n << w words, this >= 0
function bnpDAddOffset(n,w) {
if(n == 0) return;
while(this.t <= w) this[this.t++] = 0;
this[w] += n;
while(this[w] >= this.DV) {
this[w] -= this.DV;
if(++w >= this.t) this[this.t++] = 0;
++this[w];
}
}
// A "null" reducer
function NullExp() {}
function nNop(x) { return x; }
function nMulTo(x,y,r) { x.multiplyTo(y,r); }
function nSqrTo(x,r) { x.squareTo(r); }
NullExp.prototype.convert = nNop;
NullExp.prototype.revert = nNop;
NullExp.prototype.mulTo = nMulTo;
NullExp.prototype.sqrTo = nSqrTo;
// (public) this^e
function bnPow(e) { return this.exp(e,new NullExp()); }
// (protected) r = lower n words of "this * a", a.t <= n
// "this" should be the larger one if appropriate.
function bnpMultiplyLowerTo(a,n,r) {
var i = Math.min(this.t+a.t,n);
r.s = 0; // assumes a,this >= 0
r.t = i;
while(i > 0) r[--i] = 0;
var j;
for(j = r.t-this.t; i < j; ++i) r[i+this.t] = this.am(0,a[i],r,i,0,this.t);
for(j = Math.min(a.t,n); i < j; ++i) this.am(0,a[i],r,i,0,n-i);
r.clamp();
}
// (protected) r = "this * a" without lower n words, n > 0
// "this" should be the larger one if appropriate.
function bnpMultiplyUpperTo(a,n,r) {
--n;
var i = r.t = this.t+a.t-n;
r.s = 0; // assumes a,this >= 0
while(--i >= 0) r[i] = 0;
for(i = Math.max(n-this.t,0); i < a.t; ++i)
r[this.t+i-n] = this.am(n-i,a[i],r,0,0,this.t+i-n);
r.clamp();
r.drShiftTo(1,r);
}
// Barrett modular reduction
function Barrett(m) {
// setup Barrett
this.r2 = nbi();
this.q3 = nbi();
BigInteger.ONE.dlShiftTo(2*m.t,this.r2);
this.mu = this.r2.divide(m);
this.m = m;
}
function barrettConvert(x) {
if(x.s < 0 || x.t > 2*this.m.t) return x.mod(this.m);
else if(x.compareTo(this.m) < 0) return x;
else { var r = nbi(); x.copyTo(r); this.reduce(r); return r; }
}
function barrettRevert(x) { return x; }
// x = x mod m (HAC 14.42)
function barrettReduce(x) {
x.drShiftTo(this.m.t-1,this.r2);
if(x.t > this.m.t+1) { x.t = this.m.t+1; x.clamp(); }
this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3);
this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);
while(x.compareTo(this.r2) < 0) x.dAddOffset(1,this.m.t+1);
x.subTo(this.r2,x);
while(x.compareTo(this.m) >= 0) x.subTo(this.m,x);
}
// r = x^2 mod m; x != r
function barrettSqrTo(x,r) { x.squareTo(r); this.reduce(r); }
// r = x*y mod m; x,y != r
function barrettMulTo(x,y,r) { x.multiplyTo(y,r); this.reduce(r); }
Barrett.prototype.convert = barrettConvert;
Barrett.prototype.revert = barrettRevert;
Barrett.prototype.reduce = barrettReduce;
Barrett.prototype.mulTo = barrettMulTo;
Barrett.prototype.sqrTo = barrettSqrTo;
// (public) this^e % m (HAC 14.85)
function bnModPow(e,m) {
var i = e.bitLength(), k, r = nbv(1), z;
if(i <= 0) return r;
else if(i < 18) k = 1;
else if(i < 48) k = 3;
else if(i < 144) k = 4;
else if(i < 768) k = 5;
else k = 6;
if(i < 8)
z = new Classic(m);
else if(m.isEven())
z = new Barrett(m);
else
z = new Montgomery(m);
// precomputation
var g = new Array(), n = 3, k1 = k-1, km = (1<<k)-1;
g[1] = z.convert(this);
if(k > 1) {
var g2 = nbi();
z.sqrTo(g[1],g2);
while(n <= km) {
g[n] = nbi();
z.mulTo(g2,g[n-2],g[n]);
n += 2;
}
}
var j = e.t-1, w, is1 = true, r2 = nbi(), t;
i = nbits(e[j])-1;
while(j >= 0) {
if(i >= k1) w = (e[j]>>(i-k1))&km;
else {
w = (e[j]&((1<<(i+1))-1))<<(k1-i);
if(j > 0) w |= e[j-1]>>(this.DB+i-k1);
}
n = k;
while((w&1) == 0) { w >>= 1; --n; }
if((i -= n) < 0) { i += this.DB; --j; }
if(is1) { // ret == 1, don't bother squaring or multiplying it
g[w].copyTo(r);
is1 = false;
}
else {
while(n > 1) { z.sqrTo(r,r2); z.sqrTo(r2,r); n -= 2; }
if(n > 0) z.sqrTo(r,r2); else { t = r; r = r2; r2 = t; }
z.mulTo(r2,g[w],r);
}
while(j >= 0 && (e[j]&(1<<i)) == 0) {
z.sqrTo(r,r2); t = r; r = r2; r2 = t;
if(--i < 0) { i = this.DB-1; --j; }
}
}
return z.revert(r);
}
// (public) gcd(this,a) (HAC 14.54)
function bnGCD(a) {
var x = (this.s<0)?this.negate():this.clone();
var y = (a.s<0)?a.negate():a.clone();
if(x.compareTo(y) < 0) { var t = x; x = y; y = t; }
var i = x.getLowestSetBit(), g = y.getLowestSetBit();
if(g < 0) return x;
if(i < g) g = i;
if(g > 0) {
x.rShiftTo(g,x);
y.rShiftTo(g,y);
}
while(x.signum() > 0) {
if((i = x.getLowestSetBit()) > 0) x.rShiftTo(i,x);
if((i = y.getLowestSetBit()) > 0) y.rShiftTo(i,y);
if(x.compareTo(y) >= 0) {
x.subTo(y,x);
x.rShiftTo(1,x);
}
else {
y.subTo(x,y);
y.rShiftTo(1,y);
}
}
if(g > 0) y.lShiftTo(g,y);
return y;
}
// (protected) this % n, n < 2^26
function bnpModInt(n) {
if(n <= 0) return 0;
var d = this.DV%n, r = (this.s<0)?n-1:0;
if(this.t > 0)
if(d == 0) r = this[0]%n;
else for(var i = this.t-1; i >= 0; --i) r = (d*r+this[i])%n;
return r;
}
// (public) 1/this % m (HAC 14.61)
function bnModInverse(m) {
var ac = m.isEven();
if((this.isEven() && ac) || m.signum() == 0) return BigInteger.ZERO;
var u = m.clone(), v = this.clone();
var a = nbv(1), b = nbv(0), c = nbv(0), d = nbv(1);
while(u.signum() != 0) {
while(u.isEven()) {
u.rShiftTo(1,u);
if(ac) {
if(!a.isEven() || !b.isEven()) { a.addTo(this,a); b.subTo(m,b); }
a.rShiftTo(1,a);
}
else if(!b.isEven()) b.subTo(m,b);
b.rShiftTo(1,b);
}
while(v.isEven()) {
v.rShiftTo(1,v);
if(ac) {
if(!c.isEven() || !d.isEven()) { c.addTo(this,c); d.subTo(m,d); }
c.rShiftTo(1,c);
}
else if(!d.isEven()) d.subTo(m,d);
d.rShiftTo(1,d);
}
if(u.compareTo(v) >= 0) {
u.subTo(v,u);
if(ac) a.subTo(c,a);
b.subTo(d,b);
}
else {
v.subTo(u,v);
if(ac) c.subTo(a,c);
d.subTo(b,d);
}
}
if(v.compareTo(BigInteger.ONE) != 0) return BigInteger.ZERO;
if(d.compareTo(m) >= 0) return d.subtract(m);
if(d.signum() < 0) d.addTo(m,d); else return d;
if(d.signum() < 0) return d.add(m); else return d;
}
var lowprimes = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997];
var lplim = (1<<26)/lowprimes[lowprimes.length-1];
// (public) test primality with certainty >= 1-.5^t
function bnIsProbablePrime(t) {
var i, x = this.abs();
if(x.t == 1 && x[0] <= lowprimes[lowprimes.length-1]) {
for(i = 0; i < lowprimes.length; ++i)
if(x[0] == lowprimes[i]) return true;
return false;
}
if(x.isEven()) return false;
i = 1;
while(i < lowprimes.length) {
var m = lowprimes[i], j = i+1;
while(j < lowprimes.length && m < lplim) m *= lowprimes[j++];
m = x.modInt(m);
while(i < j) if(m%lowprimes[i++] == 0) return false;
}
return x.millerRabin(t);
}
// (protected) true if probably prime (HAC 4.24, Miller-Rabin)
function bnpMillerRabin(t) {
var n1 = this.subtract(BigInteger.ONE);
var k = n1.getLowestSetBit();
if(k <= 0) return false;
var r = n1.shiftRight(k);
t = (t+1)>>1;
if(t > lowprimes.length) t = lowprimes.length;
var a = nbi();
for(var i = 0; i < t; ++i) {
//Pick bases at random, instead of starting at 2
a.fromInt(lowprimes[Math.floor(Math.random()*lowprimes.length)]);
var y = a.modPow(r,this);
if(y.compareTo(BigInteger.ONE) != 0 && y.compareTo(n1) != 0) {
var j = 1;
while(j++ < k && y.compareTo(n1) != 0) {
y = y.modPowInt(2,this);
if(y.compareTo(BigInteger.ONE) == 0) return false;
}
if(y.compareTo(n1) != 0) return false;
}
}
return true;
}
// protected
BigInteger.prototype.chunkSize = bnpChunkSize;
BigInteger.prototype.toRadix = bnpToRadix;
BigInteger.prototype.fromRadix = bnpFromRadix;
BigInteger.prototype.fromNumber = bnpFromNumber;
BigInteger.prototype.bitwiseTo = bnpBitwiseTo;
BigInteger.prototype.changeBit = bnpChangeBit;
BigInteger.prototype.addTo = bnpAddTo;
BigInteger.prototype.dMultiply = bnpDMultiply;
BigInteger.prototype.dAddOffset = bnpDAddOffset;
BigInteger.prototype.multiplyLowerTo = bnpMultiplyLowerTo;
BigInteger.prototype.multiplyUpperTo = bnpMultiplyUpperTo;
BigInteger.prototype.modInt = bnpModInt;
BigInteger.prototype.millerRabin = bnpMillerRabin;
// public
BigInteger.prototype.clone = bnClone;
BigInteger.prototype.intValue = bnIntValue;
BigInteger.prototype.byteValue = bnByteValue;
BigInteger.prototype.shortValue = bnShortValue;
BigInteger.prototype.signum = bnSigNum;
BigInteger.prototype.toByteArray = bnToByteArray;
BigInteger.prototype.equals = bnEquals;
BigInteger.prototype.min = bnMin;
BigInteger.prototype.max = bnMax;
BigInteger.prototype.and = bnAnd;
BigInteger.prototype.or = bnOr;
BigInteger.prototype.xor = bnXor;
BigInteger.prototype.andNot = bnAndNot;
BigInteger.prototype.not = bnNot;
BigInteger.prototype.shiftLeft = bnShiftLeft;
BigInteger.prototype.shiftRight = bnShiftRight;
BigInteger.prototype.getLowestSetBit = bnGetLowestSetBit;
BigInteger.prototype.bitCount = bnBitCount;
BigInteger.prototype.testBit = bnTestBit;
BigInteger.prototype.setBit = bnSetBit;
BigInteger.prototype.clearBit = bnClearBit;
BigInteger.prototype.flipBit = bnFlipBit;
BigInteger.prototype.add = bnAdd;
BigInteger.prototype.subtract = bnSubtract;
BigInteger.prototype.multiply = bnMultiply;
BigInteger.prototype.divide = bnDivide;
BigInteger.prototype.remainder = bnRemainder;
BigInteger.prototype.divideAndRemainder = bnDivideAndRemainder;
BigInteger.prototype.modPow = bnModPow;
BigInteger.prototype.modInverse = bnModInverse;
BigInteger.prototype.pow = bnPow;
BigInteger.prototype.gcd = bnGCD;
BigInteger.prototype.isProbablePrime = bnIsProbablePrime;
// JSBN-specific extension
BigInteger.prototype.square = bnSquare;
// BigInteger interfaces not implemented in jsbn:
// BigInteger(int signum, byte[] magnitude)
// double doubleValue()
// float floatValue()
// int hashCode()
// long longValue()
// static BigInteger valueOf(long val)
/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/
*/
// prng4.js - uses Arcfour as a PRNG
function Arcfour() {
this.i = 0;
this.j = 0;
this.S = new Array();
}
// Initialize arcfour context from key, an array of ints, each from [0..255]
function ARC4init(key) {
var i, j, t;
for(i = 0; i < 256; ++i)
this.S[i] = i;
j = 0;
for(i = 0; i < 256; ++i) {
j = (j + this.S[i] + key[i % key.length]) & 255;
t = this.S[i];
this.S[i] = this.S[j];
this.S[j] = t;
}
this.i = 0;
this.j = 0;
}
function ARC4next() {
var t;
this.i = (this.i + 1) & 255;
this.j = (this.j + this.S[this.i]) & 255;
t = this.S[this.i];
this.S[this.i] = this.S[this.j];
this.S[this.j] = t;
return this.S[(t + this.S[this.i]) & 255];
}
Arcfour.prototype.init = ARC4init;
Arcfour.prototype.next = ARC4next;
// Plug in your RNG constructor here
function prng_newstate() {
return new Arcfour();
}
// Pool size must be a multiple of 4 and greater than 32.
// An array of bytes the size of the pool will be passed to init()
var rng_psize = 256;
/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/
*/
// Random number generator - requires a PRNG backend, e.g. prng4.js
// For best results, put code like
// <body onClick='rng_seed_time();' onKeyPress='rng_seed_time();'>
// in your main HTML document.
var rng_state;
var rng_pool;
var rng_pptr;
// Mix in a 32-bit integer into the pool
function rng_seed_int(x) {
rng_pool[rng_pptr++] ^= x & 255;
rng_pool[rng_pptr++] ^= (x >> 8) & 255;
rng_pool[rng_pptr++] ^= (x >> 16) & 255;
rng_pool[rng_pptr++] ^= (x >> 24) & 255;
if(rng_pptr >= rng_psize) rng_pptr -= rng_psize;
}
// Mix in the current time (w/milliseconds) into the pool
function rng_seed_time() {
rng_seed_int(new Date().getTime());
}
// Initialize the pool with junk if needed.
if(rng_pool == null) {
rng_pool = new Array();
rng_pptr = 0;
var t;
if(navigator.appName == "Netscape" && navigator.appVersion < "5" && window.crypto) {
// Extract entropy (256 bits) from NS4 RNG if available
var z = window.crypto.random(32);
for(t = 0; t < z.length; ++t)
rng_pool[rng_pptr++] = z.charCodeAt(t) & 255;
}
while(rng_pptr < rng_psize) { // extract some randomness from Math.random()
t = Math.floor(65536 * Math.random());
rng_pool[rng_pptr++] = t >>> 8;
rng_pool[rng_pptr++] = t & 255;
}
rng_pptr = 0;
rng_seed_time();
//rng_seed_int(window.screenX);
//rng_seed_int(window.screenY);
}
function rng_get_byte() {
if(rng_state == null) {
rng_seed_time();
rng_state = prng_newstate();
rng_state.init(rng_pool);
for(rng_pptr = 0; rng_pptr < rng_pool.length; ++rng_pptr)
rng_pool[rng_pptr] = 0;
rng_pptr = 0;
//rng_pool = null;
}
// TODO: allow reseeding after first request
return rng_state.next();
}
function rng_get_bytes(ba) {
var i;
for(i = 0; i < ba.length; ++i) ba[i] = rng_get_byte();
}
function SecureRandom() {}
SecureRandom.prototype.nextBytes = rng_get_bytes;
/*
*
* 字节流转换工具js
*
*/
/*
* 数组复制
*/
function arrayCopy(src,pos1,dest,pos2,len){
var realLen = len;
if(pos1+len>src.length&&pos2+len<=dest.length){
realLen = src.length-pos1;
}else if(pos2+len>dest.length&&pos1+len<=src.length){
realLen = dest.length-pos2;
}else if(pos1+len<=src.length&&pos2+len<=dest.length){
realLen = len;
}else if(dest.length<src.length){
realLen = dest.length-pos2;
}else{
realLen = src.length-pos2;
}
for(var i=0;i<realLen;i++){
dest[i+pos2] = src[i+pos1];
}
}
/*
* 长整型转成字节,一个长整型为8字节
* 返回:字节数组
*/
function longToByte(num){
//TODO 这里目前只转换了低四字节,因为js没有长整型,得要封装
return new Array(
0,
0,
0,
0,
(num >> 24)&0x000000FF,
(num >> 16)&0x000000FF,
(num >> 8)&0x000000FF,
(num)&0x000000FF
);
}
/*
* int数转成byte数组
* 事实上只不过转成byte大小的数,实际占用空间还是4字节
* 返回:字节数组
*/
function intToByte(num) {
return new Array(
(num >> 24)&0x000000FF,
(num >> 16)&0x000000FF,
(num >> 8)&0x000000FF,
(num)&0x000000FF
);
}
/*
* int数组转成byte数组,一个int数值转成四个byte
* 返回:byte数组
*/
function intArrayToByteArray(nums) {
var b = new Array(nums.length*4);
for(var i = 0;i<nums.length;i++) {
arrayCopy(intToByte(nums[i]), 0, b, i*4, 4);
}
return b;
}
/*
* byte数组转成int数值
* 返回:int数值
*/
function byteToInt(b,pos) {
if(pos+3<b.length) {
return ((b[pos])<<24) | ((b[pos+1])<<16) | ((b[pos+2])<<8) | ((b[pos+3]));
}else if(pos+2<b.length) {
return ((b[pos+1])<<16) | ((b[pos+2])<<8 ) | ((b[pos+3]));
}else if(pos+1<b.length) {
return ((b[pos])<<8) | ((b[pos+1]));
}else {
return ((b[pos]));
}
}
/*
* byte数组转成int数组,每四个字节转成一个int数值
*
*/
function byteArrayToIntArray(b) {
// var arrLen = b.length%4==0 ? b.length/4:b.length/4+1;
var arrLen = Math.ceil(b.length/4);//向上取整
var out = new Array(arrLen);
for(var i = 0;i<b.length;i++){
b[i] = b[i]&0xFF;//避免负数造成影响
}
for(var i = 0;i<out.length;i++) {
out[i] = byteToInt(b,i*4);
}
return out;
}
\ No newline at end of file
/*
CryptoJS v3.1.2
code.google.com/p/crypto-js
(c) 2009-2013 by Jeff Mott. All rights reserved.
code.google.com/p/crypto-js/wiki/License
*/
/**
* CryptoJS core components.
*/
var CryptoJS = CryptoJS || (function (Math, undefined) {
/**
* CryptoJS namespace.
*/
var C = {};
/**
* Library namespace.
*/
var C_lib = C.lib = {};
/**
* Base object for prototypal inheritance.
*/
var Base = C_lib.Base = (function () {
function F() {}
return {
/**
* Creates a new object that inherits from this object.
*
* @param {Object} overrides Properties to copy into the new object.
*
* @return {Object} The new object.
*
* @static
*
* @example
*
* var MyType = CryptoJS.lib.Base.extend({
* field: 'value',
*
* method: function () {
* }
* });
*/
extend: function (overrides) {
// Spawn
F.prototype = this;
var subtype = new F();
// Augment
if (overrides) {
subtype.mixIn(overrides);
}
// Create default initializer
if (!subtype.hasOwnProperty('init')) {
subtype.init = function () {
subtype.$super.init.apply(this, arguments);
};
}
// Initializer's prototype is the subtype object
subtype.init.prototype = subtype;
// Reference supertype
subtype.$super = this;
return subtype;
},
/**
* Extends this object and runs the init method.
* Arguments to create() will be passed to init().
*
* @return {Object} The new object.
*
* @static
*
* @example
*
* var instance = MyType.create();
*/
create: function () {
var instance = this.extend();
instance.init.apply(instance, arguments);
return instance;
},
/**
* Initializes a newly created object.
* Override this method to add some logic when your objects are created.
*
* @example
*
* var MyType = CryptoJS.lib.Base.extend({
* init: function () {
* // ...
* }
* });
*/
init: function () {
},
/**
* Copies properties into this object.
*
* @param {Object} properties The properties to mix in.
*
* @example
*
* MyType.mixIn({
* field: 'value'
* });
*/
mixIn: function (properties) {
for (var propertyName in properties) {
if (properties.hasOwnProperty(propertyName)) {
this[propertyName] = properties[propertyName];
}
}
// IE won't copy toString using the loop above
if (properties.hasOwnProperty('toString')) {
this.toString = properties.toString;
}
},
/**
* Creates a copy of this object.
*
* @return {Object} The clone.
*
* @example
*
* var clone = instance.clone();
*/
clone: function () {
return this.init.prototype.extend(this);
}
};
}());
/**
* An array of 32-bit words.
*
* @property {Array} words The array of 32-bit words.
* @property {number} sigBytes The number of significant bytes in this word array.
*/
var WordArray = C_lib.WordArray = Base.extend({
/**
* Initializes a newly created word array.
*
* @param {Array} words (Optional) An array of 32-bit words.
* @param {number} sigBytes (Optional) The number of significant bytes in the words.
*
* @example
*
* var wordArray = CryptoJS.lib.WordArray.create();
* var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]);
* var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6);
*/
init: function (words, sigBytes) {
words = this.words = words || [];
if (sigBytes != undefined) {
this.sigBytes = sigBytes;
} else {
this.sigBytes = words.length * 4;
}
},
/**
* Converts this word array to a string.
*
* @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex
*
* @return {string} The stringified word array.
*
* @example
*
* var string = wordArray + '';
* var string = wordArray.toString();
* var string = wordArray.toString(CryptoJS.enc.Utf8);
*/
toString: function (encoder) {
return (encoder || Hex).stringify(this);
},
/**
* Concatenates a word array to this word array.
*
* @param {WordArray} wordArray The word array to append.
*
* @return {WordArray} This word array.
*
* @example
*
* wordArray1.concat(wordArray2);
*/
concat: function (wordArray) {
// Shortcuts
var thisWords = this.words;
var thatWords = wordArray.words;
var thisSigBytes = this.sigBytes;
var thatSigBytes = wordArray.sigBytes;
// Clamp excess bits
this.clamp();
// Concat
if (thisSigBytes % 4) {
// Copy one byte at a time
for (var i = 0; i < thatSigBytes; i++) {
var thatByte = (thatWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
thisWords[(thisSigBytes + i) >>> 2] |= thatByte << (24 - ((thisSigBytes + i) % 4) * 8);
}
} else if (thatWords.length > 0xffff) {
// Copy one word at a time
for (var i = 0; i < thatSigBytes; i += 4) {
thisWords[(thisSigBytes + i) >>> 2] = thatWords[i >>> 2];
}
} else {
// Copy all words at once
thisWords.push.apply(thisWords, thatWords);
}
this.sigBytes += thatSigBytes;
// Chainable
return this;
},
/**
* Removes insignificant bits.
*
* @example
*
* wordArray.clamp();
*/
clamp: function () {
// Shortcuts
var words = this.words;
var sigBytes = this.sigBytes;
// Clamp
words[sigBytes >>> 2] &= 0xffffffff << (32 - (sigBytes % 4) * 8);
words.length = Math.ceil(sigBytes / 4);
},
/**
* Creates a copy of this word array.
*
* @return {WordArray} The clone.
*
* @example
*
* var clone = wordArray.clone();
*/
clone: function () {
var clone = Base.clone.call(this);
clone.words = this.words.slice(0);
return clone;
},
/**
* Creates a word array filled with random bytes.
*
* @param {number} nBytes The number of random bytes to generate.
*
* @return {WordArray} The random word array.
*
* @static
*
* @example
*
* var wordArray = CryptoJS.lib.WordArray.random(16);
*/
random: function (nBytes) {
var words = [];
for (var i = 0; i < nBytes; i += 4) {
words.push((Math.random() * 0x100000000) | 0);
}
return new WordArray.init(words, nBytes);
}
});
/**
* Encoder namespace.
*/
var C_enc = C.enc = {};
/**
* Hex encoding strategy.
*/
var Hex = C_enc.Hex = {
/**
* Converts a word array to a hex string.
*
* @param {WordArray} wordArray The word array.
*
* @return {string} The hex string.
*
* @static
*
* @example
*
* var hexString = CryptoJS.enc.Hex.stringify(wordArray);
*/
stringify: function (wordArray) {
// Shortcuts
var words = wordArray.words;
var sigBytes = wordArray.sigBytes;
// Convert
var hexChars = [];
for (var i = 0; i < sigBytes; i++) {
var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
hexChars.push((bite >>> 4).toString(16));
hexChars.push((bite & 0x0f).toString(16));
}
return hexChars.join('');
},
/**
* Converts a hex string to a word array.
*
* @param {string} hexStr The hex string.
*
* @return {WordArray} The word array.
*
* @static
*
* @example
*
* var wordArray = CryptoJS.enc.Hex.parse(hexString);
*/
parse: function (hexStr) {
// Shortcut
var hexStrLength = hexStr.length;
// Convert
var words = [];
for (var i = 0; i < hexStrLength; i += 2) {
words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << (24 - (i % 8) * 4);
}
return new WordArray.init(words, hexStrLength / 2);
}
};
/**
* Latin1 encoding strategy.
*/
var Latin1 = C_enc.Latin1 = {
/**
* Converts a word array to a Latin1 string.
*
* @param {WordArray} wordArray The word array.
*
* @return {string} The Latin1 string.
*
* @static
*
* @example
*
* var latin1String = CryptoJS.enc.Latin1.stringify(wordArray);
*/
stringify: function (wordArray) {
// Shortcuts
var words = wordArray.words;
var sigBytes = wordArray.sigBytes;
// Convert
var latin1Chars = [];
for (var i = 0; i < sigBytes; i++) {
var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
latin1Chars.push(String.fromCharCode(bite));
}
return latin1Chars.join('');
},
/**
* Converts a Latin1 string to a word array.
*
* @param {string} latin1Str The Latin1 string.
*
* @return {WordArray} The word array.
*
* @static
*
* @example
*
* var wordArray = CryptoJS.enc.Latin1.parse(latin1String);
*/
parse: function (latin1Str) {
// Shortcut
var latin1StrLength = latin1Str.length;
// Convert
var words = [];
for (var i = 0; i < latin1StrLength; i++) {
words[i >>> 2] |= (latin1Str.charCodeAt(i) & 0xff) << (24 - (i % 4) * 8);
}
return new WordArray.init(words, latin1StrLength);
}
};
/**
* UTF-8 encoding strategy.
*/
var Utf8 = C_enc.Utf8 = {
/**
* Converts a word array to a UTF-8 string.
*
* @param {WordArray} wordArray The word array.
*
* @return {string} The UTF-8 string.
*
* @static
*
* @example
*
* var utf8String = CryptoJS.enc.Utf8.stringify(wordArray);
*/
stringify: function (wordArray) {
try {
return decodeURIComponent(escape(Latin1.stringify(wordArray)));
} catch (e) {
throw new Error('Malformed UTF-8 data');
}
},
/**
* Converts a UTF-8 string to a word array.
*
* @param {string} utf8Str The UTF-8 string.
*
* @return {WordArray} The word array.
*
* @static
*
* @example
*
* var wordArray = CryptoJS.enc.Utf8.parse(utf8String);
*/
parse: function (utf8Str) {
var ens = encodeURIComponent(utf8Str);
var es = unescape(ens);
return Latin1.parse(es);
}
};
/**
* Abstract buffered block algorithm template.
*
* The property blockSize must be implemented in a concrete subtype.
*
* @property {number} _minBufferSize The number of blocks that should be kept unprocessed in the buffer. Default: 0
*/
var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({
/**
* Resets this block algorithm's data buffer to its initial state.
*
* @example
*
* bufferedBlockAlgorithm.reset();
*/
reset: function () {
// Initial values
this._data = new WordArray.init();
this._nDataBytes = 0;
},
/**
* Adds new data to this block algorithm's buffer.
*
* @param {WordArray|string} data The data to append. Strings are converted to a WordArray using UTF-8.
*
* @example
*
* bufferedBlockAlgorithm._append('data');
* bufferedBlockAlgorithm._append(wordArray);
*/
_append: function (data) {
// Convert string to WordArray, else assume WordArray already
if (typeof data == 'string') {
data = Utf8.parse(data);
}
// Append
this._data.concat(data);
this._nDataBytes += data.sigBytes;
},
/**
* Processes available data blocks.
*
* This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype.
*
* @param {boolean} doFlush Whether all blocks and partial blocks should be processed.
*
* @return {WordArray} The processed data.
*
* @example
*
* var processedData = bufferedBlockAlgorithm._process();
* var processedData = bufferedBlockAlgorithm._process(!!'flush');
*/
_process: function (doFlush) {
// Shortcuts
var data = this._data;
var dataWords = data.words;
var dataSigBytes = data.sigBytes;
var blockSize = this.blockSize;
var blockSizeBytes = blockSize * 4;
// Count blocks ready
var nBlocksReady = dataSigBytes / blockSizeBytes;
if (doFlush) {
// Round up to include partial blocks
nBlocksReady = Math.ceil(nBlocksReady);
} else {
// Round down to include only full blocks,
// less the number of blocks that must remain in the buffer
nBlocksReady = Math.max((nBlocksReady | 0) - this._minBufferSize, 0);
}
// Count words ready
var nWordsReady = nBlocksReady * blockSize;
// Count bytes ready
var nBytesReady = Math.min(nWordsReady * 4, dataSigBytes);
// Process blocks
if (nWordsReady) {
for (var offset = 0; offset < nWordsReady; offset += blockSize) {
// Perform concrete-algorithm logic
this._doProcessBlock(dataWords, offset);
}
// Remove processed words
var processedWords = dataWords.splice(0, nWordsReady);
data.sigBytes -= nBytesReady;
}
// Return processed words
return new WordArray.init(processedWords, nBytesReady);
},
/**
* Creates a copy of this object.
*
* @return {Object} The clone.
*
* @example
*
* var clone = bufferedBlockAlgorithm.clone();
*/
clone: function () {
var clone = Base.clone.call(this);
clone._data = this._data.clone();
return clone;
},
_minBufferSize: 0
});
/**
* Abstract hasher template.
*
* @property {number} blockSize The number of 32-bit words this hasher operates on. Default: 16 (512 bits)
*/
var Hasher = C_lib.Hasher = BufferedBlockAlgorithm.extend({
/**
* Configuration options.
*/
cfg: Base.extend(),
/**
* Initializes a newly created hasher.
*
* @param {Object} cfg (Optional) The configuration options to use for this hash computation.
*
* @example
*
* var hasher = CryptoJS.algo.SHA256.create();
*/
init: function (cfg) {
// Apply config defaults
this.cfg = this.cfg.extend(cfg);
// Set initial values
this.reset();
},
/**
* Resets this hasher to its initial state.
*
* @example
*
* hasher.reset();
*/
reset: function () {
// Reset data buffer
BufferedBlockAlgorithm.reset.call(this);
// Perform concrete-hasher logic
this._doReset();
},
/**
* Updates this hasher with a message.
*
* @param {WordArray|string} messageUpdate The message to append.
*
* @return {Hasher} This hasher.
*
* @example
*
* hasher.update('message');
* hasher.update(wordArray);
*/
update: function (messageUpdate) {
// Append
this._append(messageUpdate);
// Update the hash
this._process();
// Chainable
return this;
},
/**
* Finalizes the hash computation.
* Note that the finalize operation is effectively a destructive, read-once operation.
*
* @param {WordArray|string} messageUpdate (Optional) A final message update.
*
* @return {WordArray} The hash.
*
* @example
*
* var hash = hasher.finalize();
* var hash = hasher.finalize('message');
* var hash = hasher.finalize(wordArray);
*/
finalize: function (messageUpdate) {
// Final message update
if (messageUpdate) {
this._append(messageUpdate);
}
// Perform concrete-hasher logic
var hash = this._doFinalize();
return hash;
},
blockSize: 512/32,
/**
* Creates a shortcut function to a hasher's object interface.
*
* @param {Hasher} hasher The hasher to create a helper for.
*
* @return {Function} The shortcut function.
*
* @static
*
* @example
*
* var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256);
*/
_createHelper: function (hasher) {
return function (message, cfg) {
return new hasher.init(cfg).finalize(message);
};
},
/**
* Creates a shortcut function to the HMAC's object interface.
*
* @param {Hasher} hasher The hasher to use in this HMAC helper.
*
* @return {Function} The shortcut function.
*
* @static
*
* @example
*
* var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256);
*/
_createHmacHelper: function (hasher) {
return function (message, key) {
return new C_algo.HMAC.init(hasher, key).finalize(message);
};
}
});
/**
* Algorithm namespace.
*/
var C_algo = C.algo = {};
return C;
}(Math));
function Hex() {}
Hex.encode = function (b, pos, len) {
var hexCh = new Array(len * 2);
var hexCode = new Array(
"0",
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"A",
"B",
"C",
"D",
"E",
"F"
);
for (var i = pos, j = 0; i < len + pos; i++, j++) {
hexCh[j] = hexCode[(b[i] & 0xff) >> 4];
hexCh[++j] = hexCode[b[i] & 0x0f];
}
return hexCh.join("");
};
Hex.decode = function (hex) {
if (hex == null || hex == "") {
return null;
}
if (hex.length % 2 != 0) {
return null;
}
var ascLen = hex.length / 2;
var hexCh = this.toCharCodeArray(hex);
var asc = new Array(ascLen);
for (var i = 0; i < ascLen; i++) {
if (hexCh[2 * i] >= 0x30 && hexCh[2 * i] <= 0x39) {
asc[i] = (hexCh[2 * i] - 0x30) << 4;
} else if (hexCh[2 * i] >= 0x41 && hexCh[2 * i] <= 0x46) {
//A-F : 0x41-0x46
asc[i] = (hexCh[2 * i] - 0x41 + 10) << 4;
} else if (hexCh[2 * i] >= 0x61 && hexCh[2 * i] <= 0x66) {
//a-f : 0x61-0x66
asc[i] = (hexCh[2 * i] - 0x61 + 10) << 4;
} else {
return null;
}
if (hexCh[2 * i + 1] >= 0x30 && hexCh[2 * i + 1] <= 0x39) {
asc[i] = asc[i] | (hexCh[2 * i + 1] - 0x30);
} else if (hexCh[2 * i + 1] >= 0x41 && hexCh[2 * i + 1] <= 0x46) {
asc[i] = asc[i] | (hexCh[2 * i + 1] - 0x41 + 10);
} else if (hexCh[2 * i + 1] >= 0x61 && hexCh[2 * i + 1] <= 0x66) {
asc[i] = asc[i] | (hexCh[2 * i + 1] - 0x61 + 10);
} else {
return null;
}
}
return asc;
};
Hex.utf8StrToHex = function (utf8Str) {
var ens = encodeURIComponent(utf8Str);
var es = unescape(ens);
var esLen = es.length;
// Convert
var words = [];
for (var i = 0; i < esLen; i++) {
words[i] = es.charCodeAt(i).toString(16);
}
return words.join("");
};
Hex.utf8StrToBytes = function (utf8Str) {
var ens = encodeURIComponent(utf8Str);
var es = unescape(ens);
var esLen = es.length;
// Convert
var words = [];
for (var i = 0; i < esLen; i++) {
words[i] = es.charCodeAt(i);
}
return words;
};
Hex.hexToUtf8Str = function (utf8Str) {
var utf8Byte = Hex.decode(utf8Str);
var latin1Chars = [];
for (var i = 0; i < utf8Byte.length; i++) {
latin1Chars.push(String.fromCharCode(utf8Byte[i]));
}
return decodeURIComponent(escape(latin1Chars.join("")));
};
Hex.bytesToUtf8Str = function (bytesArray) {
var utf8Byte = bytesArray;
var latin1Chars = [];
for (var i = 0; i < utf8Byte.length; i++) {
latin1Chars.push(String.fromCharCode(utf8Byte[i]));
}
return decodeURIComponent(escape(latin1Chars.join("")));
};
Hex.toCharCodeArray = function (chs) {
var chArr = new Array(chs.length);
for (var i = 0; i < chs.length; i++) {
chArr[i] = chs.charCodeAt(i);
}
return chArr;
};
/*! jQuery v3.3.1 | (c) JS Foundation and other contributors | jquery.org/license */
!function(e,t){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(e,t){"use strict";var n=[],r=e.document,i=Object.getPrototypeOf,o=n.slice,a=n.concat,s=n.push,u=n.indexOf,l={},c=l.toString,f=l.hasOwnProperty,p=f.toString,d=p.call(Object),h={},g=function e(t){return"function"==typeof t&&"number"!=typeof t.nodeType},y=function e(t){return null!=t&&t===t.window},v={type:!0,src:!0,noModule:!0};function m(e,t,n){var i,o=(t=t||r).createElement("script");if(o.text=e,n)for(i in v)n[i]&&(o[i]=n[i]);t.head.appendChild(o).parentNode.removeChild(o)}function x(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?l[c.call(e)]||"object":typeof e}var b="3.3.1",w=function(e,t){return new w.fn.init(e,t)},T=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;w.fn=w.prototype={jquery:"3.3.1",constructor:w,length:0,toArray:function(){return o.call(this)},get:function(e){return null==e?o.call(this):e<0?this[e+this.length]:this[e]},pushStack:function(e){var t=w.merge(this.constructor(),e);return t.prevObject=this,t},each:function(e){return w.each(this,e)},map:function(e){return this.pushStack(w.map(this,function(t,n){return e.call(t,n,t)}))},slice:function(){return this.pushStack(o.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(e){var t=this.length,n=+e+(e<0?t:0);return this.pushStack(n>=0&&n<t?[this[n]]:[])},end:function(){return this.prevObject||this.constructor()},push:s,sort:n.sort,splice:n.splice},w.extend=w.fn.extend=function(){var e,t,n,r,i,o,a=arguments[0]||{},s=1,u=arguments.length,l=!1;for("boolean"==typeof a&&(l=a,a=arguments[s]||{},s++),"object"==typeof a||g(a)||(a={}),s===u&&(a=this,s--);s<u;s++)if(null!=(e=arguments[s]))for(t in e)n=a[t],a!==(r=e[t])&&(l&&r&&(w.isPlainObject(r)||(i=Array.isArray(r)))?(i?(i=!1,o=n&&Array.isArray(n)?n:[]):o=n&&w.isPlainObject(n)?n:{},a[t]=w.extend(l,o,r)):void 0!==r&&(a[t]=r));return a},w.extend({expando:"jQuery"+("3.3.1"+Math.random()).replace(/\D/g,""),isReady:!0,error:function(e){throw new Error(e)},noop:function(){},isPlainObject:function(e){var t,n;return!(!e||"[object Object]"!==c.call(e))&&(!(t=i(e))||"function"==typeof(n=f.call(t,"constructor")&&t.constructor)&&p.call(n)===d)},isEmptyObject:function(e){var t;for(t in e)return!1;return!0},globalEval:function(e){m(e)},each:function(e,t){var n,r=0;if(C(e)){for(n=e.length;r<n;r++)if(!1===t.call(e[r],r,e[r]))break}else for(r in e)if(!1===t.call(e[r],r,e[r]))break;return e},trim:function(e){return null==e?"":(e+"").replace(T,"")},makeArray:function(e,t){var n=t||[];return null!=e&&(C(Object(e))?w.merge(n,"string"==typeof e?[e]:e):s.call(n,e)),n},inArray:function(e,t,n){return null==t?-1:u.call(t,e,n)},merge:function(e,t){for(var n=+t.length,r=0,i=e.length;r<n;r++)e[i++]=t[r];return e.length=i,e},grep:function(e,t,n){for(var r,i=[],o=0,a=e.length,s=!n;o<a;o++)(r=!t(e[o],o))!==s&&i.push(e[o]);return i},map:function(e,t,n){var r,i,o=0,s=[];if(C(e))for(r=e.length;o<r;o++)null!=(i=t(e[o],o,n))&&s.push(i);else for(o in e)null!=(i=t(e[o],o,n))&&s.push(i);return a.apply([],s)},guid:1,support:h}),"function"==typeof Symbol&&(w.fn[Symbol.iterator]=n[Symbol.iterator]),w.each("Boolean Number String Function Array Date RegExp Object Error Symbol".split(" "),function(e,t){l["[object "+t+"]"]=t.toLowerCase()});function C(e){var t=!!e&&"length"in e&&e.length,n=x(e);return!g(e)&&!y(e)&&("array"===n||0===t||"number"==typeof t&&t>0&&t-1 in e)}var E=function(e){var t,n,r,i,o,a,s,u,l,c,f,p,d,h,g,y,v,m,x,b="sizzle"+1*new Date,w=e.document,T=0,C=0,E=ae(),k=ae(),S=ae(),D=function(e,t){return e===t&&(f=!0),0},N={}.hasOwnProperty,A=[],j=A.pop,q=A.push,L=A.push,H=A.slice,O=function(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1},P="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",M="[\\x20\\t\\r\\n\\f]",R="(?:\\\\.|[\\w-]|[^\0-\\xa0])+",I="\\["+M+"*("+R+")(?:"+M+"*([*^$|!~]?=)"+M+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+R+"))|)"+M+"*\\]",W=":("+R+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+I+")*)|.*)\\)|)",$=new RegExp(M+"+","g"),B=new RegExp("^"+M+"+|((?:^|[^\\\\])(?:\\\\.)*)"+M+"+$","g"),F=new RegExp("^"+M+"*,"+M+"*"),_=new RegExp("^"+M+"*([>+~]|"+M+")"+M+"*"),z=new RegExp("="+M+"*([^\\]'\"]*?)"+M+"*\\]","g"),X=new RegExp(W),U=new RegExp("^"+R+"$"),V={ID:new RegExp("^#("+R+")"),CLASS:new RegExp("^\\.("+R+")"),TAG:new RegExp("^("+R+"|[*])"),ATTR:new RegExp("^"+I),PSEUDO:new RegExp("^"+W),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+M+"*(even|odd|(([+-]|)(\\d*)n|)"+M+"*(?:([+-]|)"+M+"*(\\d+)|))"+M+"*\\)|)","i"),bool:new RegExp("^(?:"+P+")$","i"),needsContext:new RegExp("^"+M+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+M+"*((?:-\\d)?\\d*)"+M+"*\\)|)(?=[^-]|$)","i")},G=/^(?:input|select|textarea|button)$/i,Y=/^h\d$/i,Q=/^[^{]+\{\s*\[native \w/,J=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,K=/[+~]/,Z=new RegExp("\\\\([\\da-f]{1,6}"+M+"?|("+M+")|.)","ig"),ee=function(e,t,n){var r="0x"+t-65536;return r!==r||n?t:r<0?String.fromCharCode(r+65536):String.fromCharCode(r>>10|55296,1023&r|56320)},te=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,ne=function(e,t){return t?"\0"===e?"\ufffd":e.slice(0,-1)+"\\"+e.charCodeAt(e.length-1).toString(16)+" ":"\\"+e},re=function(){p()},ie=me(function(e){return!0===e.disabled&&("form"in e||"label"in e)},{dir:"parentNode",next:"legend"});try{L.apply(A=H.call(w.childNodes),w.childNodes),A[w.childNodes.length].nodeType}catch(e){L={apply:A.length?function(e,t){q.apply(e,H.call(t))}:function(e,t){var n=e.length,r=0;while(e[n++]=t[r++]);e.length=n-1}}}function oe(e,t,r,i){var o,s,l,c,f,h,v,m=t&&t.ownerDocument,T=t?t.nodeType:9;if(r=r||[],"string"!=typeof e||!e||1!==T&&9!==T&&11!==T)return r;if(!i&&((t?t.ownerDocument||t:w)!==d&&p(t),t=t||d,g)){if(11!==T&&(f=J.exec(e)))if(o=f[1]){if(9===T){if(!(l=t.getElementById(o)))return r;if(l.id===o)return r.push(l),r}else if(m&&(l=m.getElementById(o))&&x(t,l)&&l.id===o)return r.push(l),r}else{if(f[2])return L.apply(r,t.getElementsByTagName(e)),r;if((o=f[3])&&n.getElementsByClassName&&t.getElementsByClassName)return L.apply(r,t.getElementsByClassName(o)),r}if(n.qsa&&!S[e+" "]&&(!y||!y.test(e))){if(1!==T)m=t,v=e;else if("object"!==t.nodeName.toLowerCase()){(c=t.getAttribute("id"))?c=c.replace(te,ne):t.setAttribute("id",c=b),s=(h=a(e)).length;while(s--)h[s]="#"+c+" "+ve(h[s]);v=h.join(","),m=K.test(e)&&ge(t.parentNode)||t}if(v)try{return L.apply(r,m.querySelectorAll(v)),r}catch(e){}finally{c===b&&t.removeAttribute("id")}}}return u(e.replace(B,"$1"),t,r,i)}function ae(){var e=[];function t(n,i){return e.push(n+" ")>r.cacheLength&&delete t[e.shift()],t[n+" "]=i}return t}function se(e){return e[b]=!0,e}function ue(e){var t=d.createElement("fieldset");try{return!!e(t)}catch(e){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function le(e,t){var n=e.split("|"),i=n.length;while(i--)r.attrHandle[n[i]]=t}function ce(e,t){var n=t&&e,r=n&&1===e.nodeType&&1===t.nodeType&&e.sourceIndex-t.sourceIndex;if(r)return r;if(n)while(n=n.nextSibling)if(n===t)return-1;return e?1:-1}function fe(e){return function(t){return"input"===t.nodeName.toLowerCase()&&t.type===e}}function pe(e){return function(t){var n=t.nodeName.toLowerCase();return("input"===n||"button"===n)&&t.type===e}}function de(e){return function(t){return"form"in t?t.parentNode&&!1===t.disabled?"label"in t?"label"in t.parentNode?t.parentNode.disabled===e:t.disabled===e:t.isDisabled===e||t.isDisabled!==!e&&ie(t)===e:t.disabled===e:"label"in t&&t.disabled===e}}function he(e){return se(function(t){return t=+t,se(function(n,r){var i,o=e([],n.length,t),a=o.length;while(a--)n[i=o[a]]&&(n[i]=!(r[i]=n[i]))})})}function ge(e){return e&&"undefined"!=typeof e.getElementsByTagName&&e}n=oe.support={},o=oe.isXML=function(e){var t=e&&(e.ownerDocument||e).documentElement;return!!t&&"HTML"!==t.nodeName},p=oe.setDocument=function(e){var t,i,a=e?e.ownerDocument||e:w;return a!==d&&9===a.nodeType&&a.documentElement?(d=a,h=d.documentElement,g=!o(d),w!==d&&(i=d.defaultView)&&i.top!==i&&(i.addEventListener?i.addEventListener("unload",re,!1):i.attachEvent&&i.attachEvent("onunload",re)),n.attributes=ue(function(e){return e.className="i",!e.getAttribute("className")}),n.getElementsByTagName=ue(function(e){return e.appendChild(d.createComment("")),!e.getElementsByTagName("*").length}),n.getElementsByClassName=Q.test(d.getElementsByClassName),n.getById=ue(function(e){return h.appendChild(e).id=b,!d.getElementsByName||!d.getElementsByName(b).length}),n.getById?(r.filter.ID=function(e){var t=e.replace(Z,ee);return function(e){return e.getAttribute("id")===t}},r.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&g){var n=t.getElementById(e);return n?[n]:[]}}):(r.filter.ID=function(e){var t=e.replace(Z,ee);return function(e){var n="undefined"!=typeof e.getAttributeNode&&e.getAttributeNode("id");return n&&n.value===t}},r.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&g){var n,r,i,o=t.getElementById(e);if(o){if((n=o.getAttributeNode("id"))&&n.value===e)return[o];i=t.getElementsByName(e),r=0;while(o=i[r++])if((n=o.getAttributeNode("id"))&&n.value===e)return[o]}return[]}}),r.find.TAG=n.getElementsByTagName?function(e,t){return"undefined"!=typeof t.getElementsByTagName?t.getElementsByTagName(e):n.qsa?t.querySelectorAll(e):void 0}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){while(n=o[i++])1===n.nodeType&&r.push(n);return r}return o},r.find.CLASS=n.getElementsByClassName&&function(e,t){if("undefined"!=typeof t.getElementsByClassName&&g)return t.getElementsByClassName(e)},v=[],y=[],(n.qsa=Q.test(d.querySelectorAll))&&(ue(function(e){h.appendChild(e).innerHTML="<a id='"+b+"'></a><select id='"+b+"-\r\\' msallowcapture=''><option selected=''></option></select>",e.querySelectorAll("[msallowcapture^='']").length&&y.push("[*^$]="+M+"*(?:''|\"\")"),e.querySelectorAll("[selected]").length||y.push("\\["+M+"*(?:value|"+P+")"),e.querySelectorAll("[id~="+b+"-]").length||y.push("~="),e.querySelectorAll(":checked").length||y.push(":checked"),e.querySelectorAll("a#"+b+"+*").length||y.push(".#.+[+~]")}),ue(function(e){e.innerHTML="<a href='' disabled='disabled'></a><select disabled='disabled'><option/></select>";var t=d.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("name","D"),e.querySelectorAll("[name=d]").length&&y.push("name"+M+"*[*^$|!~]?="),2!==e.querySelectorAll(":enabled").length&&y.push(":enabled",":disabled"),h.appendChild(e).disabled=!0,2!==e.querySelectorAll(":disabled").length&&y.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),y.push(",.*:")})),(n.matchesSelector=Q.test(m=h.matches||h.webkitMatchesSelector||h.mozMatchesSelector||h.oMatchesSelector||h.msMatchesSelector))&&ue(function(e){n.disconnectedMatch=m.call(e,"*"),m.call(e,"[s!='']:x"),v.push("!=",W)}),y=y.length&&new RegExp(y.join("|")),v=v.length&&new RegExp(v.join("|")),t=Q.test(h.compareDocumentPosition),x=t||Q.test(h.contains)?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)while(t=t.parentNode)if(t===e)return!0;return!1},D=t?function(e,t){if(e===t)return f=!0,0;var r=!e.compareDocumentPosition-!t.compareDocumentPosition;return r||(1&(r=(e.ownerDocument||e)===(t.ownerDocument||t)?e.compareDocumentPosition(t):1)||!n.sortDetached&&t.compareDocumentPosition(e)===r?e===d||e.ownerDocument===w&&x(w,e)?-1:t===d||t.ownerDocument===w&&x(w,t)?1:c?O(c,e)-O(c,t):0:4&r?-1:1)}:function(e,t){if(e===t)return f=!0,0;var n,r=0,i=e.parentNode,o=t.parentNode,a=[e],s=[t];if(!i||!o)return e===d?-1:t===d?1:i?-1:o?1:c?O(c,e)-O(c,t):0;if(i===o)return ce(e,t);n=e;while(n=n.parentNode)a.unshift(n);n=t;while(n=n.parentNode)s.unshift(n);while(a[r]===s[r])r++;return r?ce(a[r],s[r]):a[r]===w?-1:s[r]===w?1:0},d):d},oe.matches=function(e,t){return oe(e,null,null,t)},oe.matchesSelector=function(e,t){if((e.ownerDocument||e)!==d&&p(e),t=t.replace(z,"='$1']"),n.matchesSelector&&g&&!S[t+" "]&&(!v||!v.test(t))&&(!y||!y.test(t)))try{var r=m.call(e,t);if(r||n.disconnectedMatch||e.document&&11!==e.document.nodeType)return r}catch(e){}return oe(t,d,null,[e]).length>0},oe.contains=function(e,t){return(e.ownerDocument||e)!==d&&p(e),x(e,t)},oe.attr=function(e,t){(e.ownerDocument||e)!==d&&p(e);var i=r.attrHandle[t.toLowerCase()],o=i&&N.call(r.attrHandle,t.toLowerCase())?i(e,t,!g):void 0;return void 0!==o?o:n.attributes||!g?e.getAttribute(t):(o=e.getAttributeNode(t))&&o.specified?o.value:null},oe.escape=function(e){return(e+"").replace(te,ne)},oe.error=function(e){throw new Error("Syntax error, unrecognized expression: "+e)},oe.uniqueSort=function(e){var t,r=[],i=0,o=0;if(f=!n.detectDuplicates,c=!n.sortStable&&e.slice(0),e.sort(D),f){while(t=e[o++])t===e[o]&&(i=r.push(o));while(i--)e.splice(r[i],1)}return c=null,e},i=oe.getText=function(e){var t,n="",r=0,o=e.nodeType;if(o){if(1===o||9===o||11===o){if("string"==typeof e.textContent)return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)n+=i(e)}else if(3===o||4===o)return e.nodeValue}else while(t=e[r++])n+=i(t);return n},(r=oe.selectors={cacheLength:50,createPseudo:se,match:V,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(Z,ee),e[3]=(e[3]||e[4]||e[5]||"").replace(Z,ee),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||oe.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&oe.error(e[0]),e},PSEUDO:function(e){var t,n=!e[6]&&e[2];return V.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":n&&X.test(n)&&(t=a(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(Z,ee).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=E[e+" "];return t||(t=new RegExp("(^|"+M+")"+e+"("+M+"|$)"))&&E(e,function(e){return t.test("string"==typeof e.className&&e.className||"undefined"!=typeof e.getAttribute&&e.getAttribute("class")||"")})},ATTR:function(e,t,n){return function(r){var i=oe.attr(r,e);return null==i?"!="===t:!t||(i+="","="===t?i===n:"!="===t?i!==n:"^="===t?n&&0===i.indexOf(n):"*="===t?n&&i.indexOf(n)>-1:"$="===t?n&&i.slice(-n.length)===n:"~="===t?(" "+i.replace($," ")+" ").indexOf(n)>-1:"|="===t&&(i===n||i.slice(0,n.length+1)===n+"-"))}},CHILD:function(e,t,n,r,i){var o="nth"!==e.slice(0,3),a="last"!==e.slice(-4),s="of-type"===t;return 1===r&&0===i?function(e){return!!e.parentNode}:function(t,n,u){var l,c,f,p,d,h,g=o!==a?"nextSibling":"previousSibling",y=t.parentNode,v=s&&t.nodeName.toLowerCase(),m=!u&&!s,x=!1;if(y){if(o){while(g){p=t;while(p=p[g])if(s?p.nodeName.toLowerCase()===v:1===p.nodeType)return!1;h=g="only"===e&&!h&&"nextSibling"}return!0}if(h=[a?y.firstChild:y.lastChild],a&&m){x=(d=(l=(c=(f=(p=y)[b]||(p[b]={}))[p.uniqueID]||(f[p.uniqueID]={}))[e]||[])[0]===T&&l[1])&&l[2],p=d&&y.childNodes[d];while(p=++d&&p&&p[g]||(x=d=0)||h.pop())if(1===p.nodeType&&++x&&p===t){c[e]=[T,d,x];break}}else if(m&&(x=d=(l=(c=(f=(p=t)[b]||(p[b]={}))[p.uniqueID]||(f[p.uniqueID]={}))[e]||[])[0]===T&&l[1]),!1===x)while(p=++d&&p&&p[g]||(x=d=0)||h.pop())if((s?p.nodeName.toLowerCase()===v:1===p.nodeType)&&++x&&(m&&((c=(f=p[b]||(p[b]={}))[p.uniqueID]||(f[p.uniqueID]={}))[e]=[T,x]),p===t))break;return(x-=i)===r||x%r==0&&x/r>=0}}},PSEUDO:function(e,t){var n,i=r.pseudos[e]||r.setFilters[e.toLowerCase()]||oe.error("unsupported pseudo: "+e);return i[b]?i(t):i.length>1?(n=[e,e,"",t],r.setFilters.hasOwnProperty(e.toLowerCase())?se(function(e,n){var r,o=i(e,t),a=o.length;while(a--)e[r=O(e,o[a])]=!(n[r]=o[a])}):function(e){return i(e,0,n)}):i}},pseudos:{not:se(function(e){var t=[],n=[],r=s(e.replace(B,"$1"));return r[b]?se(function(e,t,n,i){var o,a=r(e,null,i,[]),s=e.length;while(s--)(o=a[s])&&(e[s]=!(t[s]=o))}):function(e,i,o){return t[0]=e,r(t,null,o,n),t[0]=null,!n.pop()}}),has:se(function(e){return function(t){return oe(e,t).length>0}}),contains:se(function(e){return e=e.replace(Z,ee),function(t){return(t.textContent||t.innerText||i(t)).indexOf(e)>-1}}),lang:se(function(e){return U.test(e||"")||oe.error("unsupported lang: "+e),e=e.replace(Z,ee).toLowerCase(),function(t){var n;do{if(n=g?t.lang:t.getAttribute("xml:lang")||t.getAttribute("lang"))return(n=n.toLowerCase())===e||0===n.indexOf(e+"-")}while((t=t.parentNode)&&1===t.nodeType);return!1}}),target:function(t){var n=e.location&&e.location.hash;return n&&n.slice(1)===t.id},root:function(e){return e===h},focus:function(e){return e===d.activeElement&&(!d.hasFocus||d.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},enabled:de(!1),disabled:de(!0),checked:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&!!e.checked||"option"===t&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,!0===e.selected},empty:function(e){for(e=e.firstChild;e;e=e.nextSibling)if(e.nodeType<6)return!1;return!0},parent:function(e){return!r.pseudos.empty(e)},header:function(e){return Y.test(e.nodeName)},input:function(e){return G.test(e.nodeName)},button:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&"button"===e.type||"button"===t},text:function(e){var t;return"input"===e.nodeName.toLowerCase()&&"text"===e.type&&(null==(t=e.getAttribute("type"))||"text"===t.toLowerCase())},first:he(function(){return[0]}),last:he(function(e,t){return[t-1]}),eq:he(function(e,t,n){return[n<0?n+t:n]}),even:he(function(e,t){for(var n=0;n<t;n+=2)e.push(n);return e}),odd:he(function(e,t){for(var n=1;n<t;n+=2)e.push(n);return e}),lt:he(function(e,t,n){for(var r=n<0?n+t:n;--r>=0;)e.push(r);return e}),gt:he(function(e,t,n){for(var r=n<0?n+t:n;++r<t;)e.push(r);return e})}}).pseudos.nth=r.pseudos.eq;for(t in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})r.pseudos[t]=fe(t);for(t in{submit:!0,reset:!0})r.pseudos[t]=pe(t);function ye(){}ye.prototype=r.filters=r.pseudos,r.setFilters=new ye,a=oe.tokenize=function(e,t){var n,i,o,a,s,u,l,c=k[e+" "];if(c)return t?0:c.slice(0);s=e,u=[],l=r.preFilter;while(s){n&&!(i=F.exec(s))||(i&&(s=s.slice(i[0].length)||s),u.push(o=[])),n=!1,(i=_.exec(s))&&(n=i.shift(),o.push({value:n,type:i[0].replace(B," ")}),s=s.slice(n.length));for(a in r.filter)!(i=V[a].exec(s))||l[a]&&!(i=l[a](i))||(n=i.shift(),o.push({value:n,type:a,matches:i}),s=s.slice(n.length));if(!n)break}return t?s.length:s?oe.error(e):k(e,u).slice(0)};function ve(e){for(var t=0,n=e.length,r="";t<n;t++)r+=e[t].value;return r}function me(e,t,n){var r=t.dir,i=t.next,o=i||r,a=n&&"parentNode"===o,s=C++;return t.first?function(t,n,i){while(t=t[r])if(1===t.nodeType||a)return e(t,n,i);return!1}:function(t,n,u){var l,c,f,p=[T,s];if(u){while(t=t[r])if((1===t.nodeType||a)&&e(t,n,u))return!0}else while(t=t[r])if(1===t.nodeType||a)if(f=t[b]||(t[b]={}),c=f[t.uniqueID]||(f[t.uniqueID]={}),i&&i===t.nodeName.toLowerCase())t=t[r]||t;else{if((l=c[o])&&l[0]===T&&l[1]===s)return p[2]=l[2];if(c[o]=p,p[2]=e(t,n,u))return!0}return!1}}function xe(e){return e.length>1?function(t,n,r){var i=e.length;while(i--)if(!e[i](t,n,r))return!1;return!0}:e[0]}function be(e,t,n){for(var r=0,i=t.length;r<i;r++)oe(e,t[r],n);return n}function we(e,t,n,r,i){for(var o,a=[],s=0,u=e.length,l=null!=t;s<u;s++)(o=e[s])&&(n&&!n(o,r,i)||(a.push(o),l&&t.push(s)));return a}function Te(e,t,n,r,i,o){return r&&!r[b]&&(r=Te(r)),i&&!i[b]&&(i=Te(i,o)),se(function(o,a,s,u){var l,c,f,p=[],d=[],h=a.length,g=o||be(t||"*",s.nodeType?[s]:s,[]),y=!e||!o&&t?g:we(g,p,e,s,u),v=n?i||(o?e:h||r)?[]:a:y;if(n&&n(y,v,s,u),r){l=we(v,d),r(l,[],s,u),c=l.length;while(c--)(f=l[c])&&(v[d[c]]=!(y[d[c]]=f))}if(o){if(i||e){if(i){l=[],c=v.length;while(c--)(f=v[c])&&l.push(y[c]=f);i(null,v=[],l,u)}c=v.length;while(c--)(f=v[c])&&(l=i?O(o,f):p[c])>-1&&(o[l]=!(a[l]=f))}}else v=we(v===a?v.splice(h,v.length):v),i?i(null,a,v,u):L.apply(a,v)})}function Ce(e){for(var t,n,i,o=e.length,a=r.relative[e[0].type],s=a||r.relative[" "],u=a?1:0,c=me(function(e){return e===t},s,!0),f=me(function(e){return O(t,e)>-1},s,!0),p=[function(e,n,r){var i=!a&&(r||n!==l)||((t=n).nodeType?c(e,n,r):f(e,n,r));return t=null,i}];u<o;u++)if(n=r.relative[e[u].type])p=[me(xe(p),n)];else{if((n=r.filter[e[u].type].apply(null,e[u].matches))[b]){for(i=++u;i<o;i++)if(r.relative[e[i].type])break;return Te(u>1&&xe(p),u>1&&ve(e.slice(0,u-1).concat({value:" "===e[u-2].type?"*":""})).replace(B,"$1"),n,u<i&&Ce(e.slice(u,i)),i<o&&Ce(e=e.slice(i)),i<o&&ve(e))}p.push(n)}return xe(p)}function Ee(e,t){var n=t.length>0,i=e.length>0,o=function(o,a,s,u,c){var f,h,y,v=0,m="0",x=o&&[],b=[],w=l,C=o||i&&r.find.TAG("*",c),E=T+=null==w?1:Math.random()||.1,k=C.length;for(c&&(l=a===d||a||c);m!==k&&null!=(f=C[m]);m++){if(i&&f){h=0,a||f.ownerDocument===d||(p(f),s=!g);while(y=e[h++])if(y(f,a||d,s)){u.push(f);break}c&&(T=E)}n&&((f=!y&&f)&&v--,o&&x.push(f))}if(v+=m,n&&m!==v){h=0;while(y=t[h++])y(x,b,a,s);if(o){if(v>0)while(m--)x[m]||b[m]||(b[m]=j.call(u));b=we(b)}L.apply(u,b),c&&!o&&b.length>0&&v+t.length>1&&oe.uniqueSort(u)}return c&&(T=E,l=w),x};return n?se(o):o}return s=oe.compile=function(e,t){var n,r=[],i=[],o=S[e+" "];if(!o){t||(t=a(e)),n=t.length;while(n--)(o=Ce(t[n]))[b]?r.push(o):i.push(o);(o=S(e,Ee(i,r))).selector=e}return o},u=oe.select=function(e,t,n,i){var o,u,l,c,f,p="function"==typeof e&&e,d=!i&&a(e=p.selector||e);if(n=n||[],1===d.length){if((u=d[0]=d[0].slice(0)).length>2&&"ID"===(l=u[0]).type&&9===t.nodeType&&g&&r.relative[u[1].type]){if(!(t=(r.find.ID(l.matches[0].replace(Z,ee),t)||[])[0]))return n;p&&(t=t.parentNode),e=e.slice(u.shift().value.length)}o=V.needsContext.test(e)?0:u.length;while(o--){if(l=u[o],r.relative[c=l.type])break;if((f=r.find[c])&&(i=f(l.matches[0].replace(Z,ee),K.test(u[0].type)&&ge(t.parentNode)||t))){if(u.splice(o,1),!(e=i.length&&ve(u)))return L.apply(n,i),n;break}}}return(p||s(e,d))(i,t,!g,n,!t||K.test(e)&&ge(t.parentNode)||t),n},n.sortStable=b.split("").sort(D).join("")===b,n.detectDuplicates=!!f,p(),n.sortDetached=ue(function(e){return 1&e.compareDocumentPosition(d.createElement("fieldset"))}),ue(function(e){return e.innerHTML="<a href='#'></a>","#"===e.firstChild.getAttribute("href")})||le("type|href|height|width",function(e,t,n){if(!n)return e.getAttribute(t,"type"===t.toLowerCase()?1:2)}),n.attributes&&ue(function(e){return e.innerHTML="<input/>",e.firstChild.setAttribute("value",""),""===e.firstChild.getAttribute("value")})||le("value",function(e,t,n){if(!n&&"input"===e.nodeName.toLowerCase())return e.defaultValue}),ue(function(e){return null==e.getAttribute("disabled")})||le(P,function(e,t,n){var r;if(!n)return!0===e[t]?t.toLowerCase():(r=e.getAttributeNode(t))&&r.specified?r.value:null}),oe}(e);w.find=E,w.expr=E.selectors,w.expr[":"]=w.expr.pseudos,w.uniqueSort=w.unique=E.uniqueSort,w.text=E.getText,w.isXMLDoc=E.isXML,w.contains=E.contains,w.escapeSelector=E.escape;var k=function(e,t,n){var r=[],i=void 0!==n;while((e=e[t])&&9!==e.nodeType)if(1===e.nodeType){if(i&&w(e).is(n))break;r.push(e)}return r},S=function(e,t){for(var n=[];e;e=e.nextSibling)1===e.nodeType&&e!==t&&n.push(e);return n},D=w.expr.match.needsContext;function N(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()}var A=/^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function j(e,t,n){return g(t)?w.grep(e,function(e,r){return!!t.call(e,r,e)!==n}):t.nodeType?w.grep(e,function(e){return e===t!==n}):"string"!=typeof t?w.grep(e,function(e){return u.call(t,e)>-1!==n}):w.filter(t,e,n)}w.filter=function(e,t,n){var r=t[0];return n&&(e=":not("+e+")"),1===t.length&&1===r.nodeType?w.find.matchesSelector(r,e)?[r]:[]:w.find.matches(e,w.grep(t,function(e){return 1===e.nodeType}))},w.fn.extend({find:function(e){var t,n,r=this.length,i=this;if("string"!=typeof e)return this.pushStack(w(e).filter(function(){for(t=0;t<r;t++)if(w.contains(i[t],this))return!0}));for(n=this.pushStack([]),t=0;t<r;t++)w.find(e,i[t],n);return r>1?w.uniqueSort(n):n},filter:function(e){return this.pushStack(j(this,e||[],!1))},not:function(e){return this.pushStack(j(this,e||[],!0))},is:function(e){return!!j(this,"string"==typeof e&&D.test(e)?w(e):e||[],!1).length}});var q,L=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/;(w.fn.init=function(e,t,n){var i,o;if(!e)return this;if(n=n||q,"string"==typeof e){if(!(i="<"===e[0]&&">"===e[e.length-1]&&e.length>=3?[null,e,null]:L.exec(e))||!i[1]&&t)return!t||t.jquery?(t||n).find(e):this.constructor(t).find(e);if(i[1]){if(t=t instanceof w?t[0]:t,w.merge(this,w.parseHTML(i[1],t&&t.nodeType?t.ownerDocument||t:r,!0)),A.test(i[1])&&w.isPlainObject(t))for(i in t)g(this[i])?this[i](t[i]):this.attr(i,t[i]);return this}return(o=r.getElementById(i[2]))&&(this[0]=o,this.length=1),this}return e.nodeType?(this[0]=e,this.length=1,this):g(e)?void 0!==n.ready?n.ready(e):e(w):w.makeArray(e,this)}).prototype=w.fn,q=w(r);var H=/^(?:parents|prev(?:Until|All))/,O={children:!0,contents:!0,next:!0,prev:!0};w.fn.extend({has:function(e){var t=w(e,this),n=t.length;return this.filter(function(){for(var e=0;e<n;e++)if(w.contains(this,t[e]))return!0})},closest:function(e,t){var n,r=0,i=this.length,o=[],a="string"!=typeof e&&w(e);if(!D.test(e))for(;r<i;r++)for(n=this[r];n&&n!==t;n=n.parentNode)if(n.nodeType<11&&(a?a.index(n)>-1:1===n.nodeType&&w.find.matchesSelector(n,e))){o.push(n);break}return this.pushStack(o.length>1?w.uniqueSort(o):o)},index:function(e){return e?"string"==typeof e?u.call(w(e),this[0]):u.call(this,e.jquery?e[0]:e):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(e,t){return this.pushStack(w.uniqueSort(w.merge(this.get(),w(e,t))))},addBack:function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}});function P(e,t){while((e=e[t])&&1!==e.nodeType);return e}w.each({parent:function(e){var t=e.parentNode;return t&&11!==t.nodeType?t:null},parents:function(e){return k(e,"parentNode")},parentsUntil:function(e,t,n){return k(e,"parentNode",n)},next:function(e){return P(e,"nextSibling")},prev:function(e){return P(e,"previousSibling")},nextAll:function(e){return k(e,"nextSibling")},prevAll:function(e){return k(e,"previousSibling")},nextUntil:function(e,t,n){return k(e,"nextSibling",n)},prevUntil:function(e,t,n){return k(e,"previousSibling",n)},siblings:function(e){return S((e.parentNode||{}).firstChild,e)},children:function(e){return S(e.firstChild)},contents:function(e){return N(e,"iframe")?e.contentDocument:(N(e,"template")&&(e=e.content||e),w.merge([],e.childNodes))}},function(e,t){w.fn[e]=function(n,r){var i=w.map(this,t,n);return"Until"!==e.slice(-5)&&(r=n),r&&"string"==typeof r&&(i=w.filter(r,i)),this.length>1&&(O[e]||w.uniqueSort(i),H.test(e)&&i.reverse()),this.pushStack(i)}});var M=/[^\x20\t\r\n\f]+/g;function R(e){var t={};return w.each(e.match(M)||[],function(e,n){t[n]=!0}),t}w.Callbacks=function(e){e="string"==typeof e?R(e):w.extend({},e);var t,n,r,i,o=[],a=[],s=-1,u=function(){for(i=i||e.once,r=t=!0;a.length;s=-1){n=a.shift();while(++s<o.length)!1===o[s].apply(n[0],n[1])&&e.stopOnFalse&&(s=o.length,n=!1)}e.memory||(n=!1),t=!1,i&&(o=n?[]:"")},l={add:function(){return o&&(n&&!t&&(s=o.length-1,a.push(n)),function t(n){w.each(n,function(n,r){g(r)?e.unique&&l.has(r)||o.push(r):r&&r.length&&"string"!==x(r)&&t(r)})}(arguments),n&&!t&&u()),this},remove:function(){return w.each(arguments,function(e,t){var n;while((n=w.inArray(t,o,n))>-1)o.splice(n,1),n<=s&&s--}),this},has:function(e){return e?w.inArray(e,o)>-1:o.length>0},empty:function(){return o&&(o=[]),this},disable:function(){return i=a=[],o=n="",this},disabled:function(){return!o},lock:function(){return i=a=[],n||t||(o=n=""),this},locked:function(){return!!i},fireWith:function(e,n){return i||(n=[e,(n=n||[]).slice?n.slice():n],a.push(n),t||u()),this},fire:function(){return l.fireWith(this,arguments),this},fired:function(){return!!r}};return l};function I(e){return e}function W(e){throw e}function $(e,t,n,r){var i;try{e&&g(i=e.promise)?i.call(e).done(t).fail(n):e&&g(i=e.then)?i.call(e,t,n):t.apply(void 0,[e].slice(r))}catch(e){n.apply(void 0,[e])}}w.extend({Deferred:function(t){var n=[["notify","progress",w.Callbacks("memory"),w.Callbacks("memory"),2],["resolve","done",w.Callbacks("once memory"),w.Callbacks("once memory"),0,"resolved"],["reject","fail",w.Callbacks("once memory"),w.Callbacks("once memory"),1,"rejected"]],r="pending",i={state:function(){return r},always:function(){return o.done(arguments).fail(arguments),this},"catch":function(e){return i.then(null,e)},pipe:function(){var e=arguments;return w.Deferred(function(t){w.each(n,function(n,r){var i=g(e[r[4]])&&e[r[4]];o[r[1]](function(){var e=i&&i.apply(this,arguments);e&&g(e.promise)?e.promise().progress(t.notify).done(t.resolve).fail(t.reject):t[r[0]+"With"](this,i?[e]:arguments)})}),e=null}).promise()},then:function(t,r,i){var o=0;function a(t,n,r,i){return function(){var s=this,u=arguments,l=function(){var e,l;if(!(t<o)){if((e=r.apply(s,u))===n.promise())throw new TypeError("Thenable self-resolution");l=e&&("object"==typeof e||"function"==typeof e)&&e.then,g(l)?i?l.call(e,a(o,n,I,i),a(o,n,W,i)):(o++,l.call(e,a(o,n,I,i),a(o,n,W,i),a(o,n,I,n.notifyWith))):(r!==I&&(s=void 0,u=[e]),(i||n.resolveWith)(s,u))}},c=i?l:function(){try{l()}catch(e){w.Deferred.exceptionHook&&w.Deferred.exceptionHook(e,c.stackTrace),t+1>=o&&(r!==W&&(s=void 0,u=[e]),n.rejectWith(s,u))}};t?c():(w.Deferred.getStackHook&&(c.stackTrace=w.Deferred.getStackHook()),e.setTimeout(c))}}return w.Deferred(function(e){n[0][3].add(a(0,e,g(i)?i:I,e.notifyWith)),n[1][3].add(a(0,e,g(t)?t:I)),n[2][3].add(a(0,e,g(r)?r:W))}).promise()},promise:function(e){return null!=e?w.extend(e,i):i}},o={};return w.each(n,function(e,t){var a=t[2],s=t[5];i[t[1]]=a.add,s&&a.add(function(){r=s},n[3-e][2].disable,n[3-e][3].disable,n[0][2].lock,n[0][3].lock),a.add(t[3].fire),o[t[0]]=function(){return o[t[0]+"With"](this===o?void 0:this,arguments),this},o[t[0]+"With"]=a.fireWith}),i.promise(o),t&&t.call(o,o),o},when:function(e){var t=arguments.length,n=t,r=Array(n),i=o.call(arguments),a=w.Deferred(),s=function(e){return function(n){r[e]=this,i[e]=arguments.length>1?o.call(arguments):n,--t||a.resolveWith(r,i)}};if(t<=1&&($(e,a.done(s(n)).resolve,a.reject,!t),"pending"===a.state()||g(i[n]&&i[n].then)))return a.then();while(n--)$(i[n],s(n),a.reject);return a.promise()}});var B=/^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;w.Deferred.exceptionHook=function(t,n){e.console&&e.console.warn&&t&&B.test(t.name)&&e.console.warn("jQuery.Deferred exception: "+t.message,t.stack,n)},w.readyException=function(t){e.setTimeout(function(){throw t})};var F=w.Deferred();w.fn.ready=function(e){return F.then(e)["catch"](function(e){w.readyException(e)}),this},w.extend({isReady:!1,readyWait:1,ready:function(e){(!0===e?--w.readyWait:w.isReady)||(w.isReady=!0,!0!==e&&--w.readyWait>0||F.resolveWith(r,[w]))}}),w.ready.then=F.then;function _(){r.removeEventListener("DOMContentLoaded",_),e.removeEventListener("load",_),w.ready()}"complete"===r.readyState||"loading"!==r.readyState&&!r.documentElement.doScroll?e.setTimeout(w.ready):(r.addEventListener("DOMContentLoaded",_),e.addEventListener("load",_));var z=function(e,t,n,r,i,o,a){var s=0,u=e.length,l=null==n;if("object"===x(n)){i=!0;for(s in n)z(e,t,s,n[s],!0,o,a)}else if(void 0!==r&&(i=!0,g(r)||(a=!0),l&&(a?(t.call(e,r),t=null):(l=t,t=function(e,t,n){return l.call(w(e),n)})),t))for(;s<u;s++)t(e[s],n,a?r:r.call(e[s],s,t(e[s],n)));return i?e:l?t.call(e):u?t(e[0],n):o},X=/^-ms-/,U=/-([a-z])/g;function V(e,t){return t.toUpperCase()}function G(e){return e.replace(X,"ms-").replace(U,V)}var Y=function(e){return 1===e.nodeType||9===e.nodeType||!+e.nodeType};function Q(){this.expando=w.expando+Q.uid++}Q.uid=1,Q.prototype={cache:function(e){var t=e[this.expando];return t||(t={},Y(e)&&(e.nodeType?e[this.expando]=t:Object.defineProperty(e,this.expando,{value:t,configurable:!0}))),t},set:function(e,t,n){var r,i=this.cache(e);if("string"==typeof t)i[G(t)]=n;else for(r in t)i[G(r)]=t[r];return i},get:function(e,t){return void 0===t?this.cache(e):e[this.expando]&&e[this.expando][G(t)]},access:function(e,t,n){return void 0===t||t&&"string"==typeof t&&void 0===n?this.get(e,t):(this.set(e,t,n),void 0!==n?n:t)},remove:function(e,t){var n,r=e[this.expando];if(void 0!==r){if(void 0!==t){n=(t=Array.isArray(t)?t.map(G):(t=G(t))in r?[t]:t.match(M)||[]).length;while(n--)delete r[t[n]]}(void 0===t||w.isEmptyObject(r))&&(e.nodeType?e[this.expando]=void 0:delete e[this.expando])}},hasData:function(e){var t=e[this.expando];return void 0!==t&&!w.isEmptyObject(t)}};var J=new Q,K=new Q,Z=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,ee=/[A-Z]/g;function te(e){return"true"===e||"false"!==e&&("null"===e?null:e===+e+""?+e:Z.test(e)?JSON.parse(e):e)}function ne(e,t,n){var r;if(void 0===n&&1===e.nodeType)if(r="data-"+t.replace(ee,"-$&").toLowerCase(),"string"==typeof(n=e.getAttribute(r))){try{n=te(n)}catch(e){}K.set(e,t,n)}else n=void 0;return n}w.extend({hasData:function(e){return K.hasData(e)||J.hasData(e)},data:function(e,t,n){return K.access(e,t,n)},removeData:function(e,t){K.remove(e,t)},_data:function(e,t,n){return J.access(e,t,n)},_removeData:function(e,t){J.remove(e,t)}}),w.fn.extend({data:function(e,t){var n,r,i,o=this[0],a=o&&o.attributes;if(void 0===e){if(this.length&&(i=K.get(o),1===o.nodeType&&!J.get(o,"hasDataAttrs"))){n=a.length;while(n--)a[n]&&0===(r=a[n].name).indexOf("data-")&&(r=G(r.slice(5)),ne(o,r,i[r]));J.set(o,"hasDataAttrs",!0)}return i}return"object"==typeof e?this.each(function(){K.set(this,e)}):z(this,function(t){var n;if(o&&void 0===t){if(void 0!==(n=K.get(o,e)))return n;if(void 0!==(n=ne(o,e)))return n}else this.each(function(){K.set(this,e,t)})},null,t,arguments.length>1,null,!0)},removeData:function(e){return this.each(function(){K.remove(this,e)})}}),w.extend({queue:function(e,t,n){var r;if(e)return t=(t||"fx")+"queue",r=J.get(e,t),n&&(!r||Array.isArray(n)?r=J.access(e,t,w.makeArray(n)):r.push(n)),r||[]},dequeue:function(e,t){t=t||"fx";var n=w.queue(e,t),r=n.length,i=n.shift(),o=w._queueHooks(e,t),a=function(){w.dequeue(e,t)};"inprogress"===i&&(i=n.shift(),r--),i&&("fx"===t&&n.unshift("inprogress"),delete o.stop,i.call(e,a,o)),!r&&o&&o.empty.fire()},_queueHooks:function(e,t){var n=t+"queueHooks";return J.get(e,n)||J.access(e,n,{empty:w.Callbacks("once memory").add(function(){J.remove(e,[t+"queue",n])})})}}),w.fn.extend({queue:function(e,t){var n=2;return"string"!=typeof e&&(t=e,e="fx",n--),arguments.length<n?w.queue(this[0],e):void 0===t?this:this.each(function(){var n=w.queue(this,e,t);w._queueHooks(this,e),"fx"===e&&"inprogress"!==n[0]&&w.dequeue(this,e)})},dequeue:function(e){return this.each(function(){w.dequeue(this,e)})},clearQueue:function(e){return this.queue(e||"fx",[])},promise:function(e,t){var n,r=1,i=w.Deferred(),o=this,a=this.length,s=function(){--r||i.resolveWith(o,[o])};"string"!=typeof e&&(t=e,e=void 0),e=e||"fx";while(a--)(n=J.get(o[a],e+"queueHooks"))&&n.empty&&(r++,n.empty.add(s));return s(),i.promise(t)}});var re=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,ie=new RegExp("^(?:([+-])=|)("+re+")([a-z%]*)$","i"),oe=["Top","Right","Bottom","Left"],ae=function(e,t){return"none"===(e=t||e).style.display||""===e.style.display&&w.contains(e.ownerDocument,e)&&"none"===w.css(e,"display")},se=function(e,t,n,r){var i,o,a={};for(o in t)a[o]=e.style[o],e.style[o]=t[o];i=n.apply(e,r||[]);for(o in t)e.style[o]=a[o];return i};function ue(e,t,n,r){var i,o,a=20,s=r?function(){return r.cur()}:function(){return w.css(e,t,"")},u=s(),l=n&&n[3]||(w.cssNumber[t]?"":"px"),c=(w.cssNumber[t]||"px"!==l&&+u)&&ie.exec(w.css(e,t));if(c&&c[3]!==l){u/=2,l=l||c[3],c=+u||1;while(a--)w.style(e,t,c+l),(1-o)*(1-(o=s()/u||.5))<=0&&(a=0),c/=o;c*=2,w.style(e,t,c+l),n=n||[]}return n&&(c=+c||+u||0,i=n[1]?c+(n[1]+1)*n[2]:+n[2],r&&(r.unit=l,r.start=c,r.end=i)),i}var le={};function ce(e){var t,n=e.ownerDocument,r=e.nodeName,i=le[r];return i||(t=n.body.appendChild(n.createElement(r)),i=w.css(t,"display"),t.parentNode.removeChild(t),"none"===i&&(i="block"),le[r]=i,i)}function fe(e,t){for(var n,r,i=[],o=0,a=e.length;o<a;o++)(r=e[o]).style&&(n=r.style.display,t?("none"===n&&(i[o]=J.get(r,"display")||null,i[o]||(r.style.display="")),""===r.style.display&&ae(r)&&(i[o]=ce(r))):"none"!==n&&(i[o]="none",J.set(r,"display",n)));for(o=0;o<a;o++)null!=i[o]&&(e[o].style.display=i[o]);return e}w.fn.extend({show:function(){return fe(this,!0)},hide:function(){return fe(this)},toggle:function(e){return"boolean"==typeof e?e?this.show():this.hide():this.each(function(){ae(this)?w(this).show():w(this).hide()})}});var pe=/^(?:checkbox|radio)$/i,de=/<([a-z][^\/\0>\x20\t\r\n\f]+)/i,he=/^$|^module$|\/(?:java|ecma)script/i,ge={option:[1,"<select multiple='multiple'>","</select>"],thead:[1,"<table>","</table>"],col:[2,"<table><colgroup>","</colgroup></table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],_default:[0,"",""]};ge.optgroup=ge.option,ge.tbody=ge.tfoot=ge.colgroup=ge.caption=ge.thead,ge.th=ge.td;function ye(e,t){var n;return n="undefined"!=typeof e.getElementsByTagName?e.getElementsByTagName(t||"*"):"undefined"!=typeof e.querySelectorAll?e.querySelectorAll(t||"*"):[],void 0===t||t&&N(e,t)?w.merge([e],n):n}function ve(e,t){for(var n=0,r=e.length;n<r;n++)J.set(e[n],"globalEval",!t||J.get(t[n],"globalEval"))}var me=/<|&#?\w+;/;function xe(e,t,n,r,i){for(var o,a,s,u,l,c,f=t.createDocumentFragment(),p=[],d=0,h=e.length;d<h;d++)if((o=e[d])||0===o)if("object"===x(o))w.merge(p,o.nodeType?[o]:o);else if(me.test(o)){a=a||f.appendChild(t.createElement("div")),s=(de.exec(o)||["",""])[1].toLowerCase(),u=ge[s]||ge._default,a.innerHTML=u[1]+w.htmlPrefilter(o)+u[2],c=u[0];while(c--)a=a.lastChild;w.merge(p,a.childNodes),(a=f.firstChild).textContent=""}else p.push(t.createTextNode(o));f.textContent="",d=0;while(o=p[d++])if(r&&w.inArray(o,r)>-1)i&&i.push(o);else if(l=w.contains(o.ownerDocument,o),a=ye(f.appendChild(o),"script"),l&&ve(a),n){c=0;while(o=a[c++])he.test(o.type||"")&&n.push(o)}return f}!function(){var e=r.createDocumentFragment().appendChild(r.createElement("div")),t=r.createElement("input");t.setAttribute("type","radio"),t.setAttribute("checked","checked"),t.setAttribute("name","t"),e.appendChild(t),h.checkClone=e.cloneNode(!0).cloneNode(!0).lastChild.checked,e.innerHTML="<textarea>x</textarea>",h.noCloneChecked=!!e.cloneNode(!0).lastChild.defaultValue}();var be=r.documentElement,we=/^key/,Te=/^(?:mouse|pointer|contextmenu|drag|drop)|click/,Ce=/^([^.]*)(?:\.(.+)|)/;function Ee(){return!0}function ke(){return!1}function Se(){try{return r.activeElement}catch(e){}}function De(e,t,n,r,i,o){var a,s;if("object"==typeof t){"string"!=typeof n&&(r=r||n,n=void 0);for(s in t)De(e,s,n,r,t[s],o);return e}if(null==r&&null==i?(i=n,r=n=void 0):null==i&&("string"==typeof n?(i=r,r=void 0):(i=r,r=n,n=void 0)),!1===i)i=ke;else if(!i)return e;return 1===o&&(a=i,(i=function(e){return w().off(e),a.apply(this,arguments)}).guid=a.guid||(a.guid=w.guid++)),e.each(function(){w.event.add(this,t,i,r,n)})}w.event={global:{},add:function(e,t,n,r,i){var o,a,s,u,l,c,f,p,d,h,g,y=J.get(e);if(y){n.handler&&(n=(o=n).handler,i=o.selector),i&&w.find.matchesSelector(be,i),n.guid||(n.guid=w.guid++),(u=y.events)||(u=y.events={}),(a=y.handle)||(a=y.handle=function(t){return"undefined"!=typeof w&&w.event.triggered!==t.type?w.event.dispatch.apply(e,arguments):void 0}),l=(t=(t||"").match(M)||[""]).length;while(l--)d=g=(s=Ce.exec(t[l])||[])[1],h=(s[2]||"").split(".").sort(),d&&(f=w.event.special[d]||{},d=(i?f.delegateType:f.bindType)||d,f=w.event.special[d]||{},c=w.extend({type:d,origType:g,data:r,handler:n,guid:n.guid,selector:i,needsContext:i&&w.expr.match.needsContext.test(i),namespace:h.join(".")},o),(p=u[d])||((p=u[d]=[]).delegateCount=0,f.setup&&!1!==f.setup.call(e,r,h,a)||e.addEventListener&&e.addEventListener(d,a)),f.add&&(f.add.call(e,c),c.handler.guid||(c.handler.guid=n.guid)),i?p.splice(p.delegateCount++,0,c):p.push(c),w.event.global[d]=!0)}},remove:function(e,t,n,r,i){var o,a,s,u,l,c,f,p,d,h,g,y=J.hasData(e)&&J.get(e);if(y&&(u=y.events)){l=(t=(t||"").match(M)||[""]).length;while(l--)if(s=Ce.exec(t[l])||[],d=g=s[1],h=(s[2]||"").split(".").sort(),d){f=w.event.special[d]||{},p=u[d=(r?f.delegateType:f.bindType)||d]||[],s=s[2]&&new RegExp("(^|\\.)"+h.join("\\.(?:.*\\.|)")+"(\\.|$)"),a=o=p.length;while(o--)c=p[o],!i&&g!==c.origType||n&&n.guid!==c.guid||s&&!s.test(c.namespace)||r&&r!==c.selector&&("**"!==r||!c.selector)||(p.splice(o,1),c.selector&&p.delegateCount--,f.remove&&f.remove.call(e,c));a&&!p.length&&(f.teardown&&!1!==f.teardown.call(e,h,y.handle)||w.removeEvent(e,d,y.handle),delete u[d])}else for(d in u)w.event.remove(e,d+t[l],n,r,!0);w.isEmptyObject(u)&&J.remove(e,"handle events")}},dispatch:function(e){var t=w.event.fix(e),n,r,i,o,a,s,u=new Array(arguments.length),l=(J.get(this,"events")||{})[t.type]||[],c=w.event.special[t.type]||{};for(u[0]=t,n=1;n<arguments.length;n++)u[n]=arguments[n];if(t.delegateTarget=this,!c.preDispatch||!1!==c.preDispatch.call(this,t)){s=w.event.handlers.call(this,t,l),n=0;while((o=s[n++])&&!t.isPropagationStopped()){t.currentTarget=o.elem,r=0;while((a=o.handlers[r++])&&!t.isImmediatePropagationStopped())t.rnamespace&&!t.rnamespace.test(a.namespace)||(t.handleObj=a,t.data=a.data,void 0!==(i=((w.event.special[a.origType]||{}).handle||a.handler).apply(o.elem,u))&&!1===(t.result=i)&&(t.preventDefault(),t.stopPropagation()))}return c.postDispatch&&c.postDispatch.call(this,t),t.result}},handlers:function(e,t){var n,r,i,o,a,s=[],u=t.delegateCount,l=e.target;if(u&&l.nodeType&&!("click"===e.type&&e.button>=1))for(;l!==this;l=l.parentNode||this)if(1===l.nodeType&&("click"!==e.type||!0!==l.disabled)){for(o=[],a={},n=0;n<u;n++)void 0===a[i=(r=t[n]).selector+" "]&&(a[i]=r.needsContext?w(i,this).index(l)>-1:w.find(i,this,null,[l]).length),a[i]&&o.push(r);o.length&&s.push({elem:l,handlers:o})}return l=this,u<t.length&&s.push({elem:l,handlers:t.slice(u)}),s},addProp:function(e,t){Object.defineProperty(w.Event.prototype,e,{enumerable:!0,configurable:!0,get:g(t)?function(){if(this.originalEvent)return t(this.originalEvent)}:function(){if(this.originalEvent)return this.originalEvent[e]},set:function(t){Object.defineProperty(this,e,{enumerable:!0,configurable:!0,writable:!0,value:t})}})},fix:function(e){return e[w.expando]?e:new w.Event(e)},special:{load:{noBubble:!0},focus:{trigger:function(){if(this!==Se()&&this.focus)return this.focus(),!1},delegateType:"focusin"},blur:{trigger:function(){if(this===Se()&&this.blur)return this.blur(),!1},delegateType:"focusout"},click:{trigger:function(){if("checkbox"===this.type&&this.click&&N(this,"input"))return this.click(),!1},_default:function(e){return N(e.target,"a")}},beforeunload:{postDispatch:function(e){void 0!==e.result&&e.originalEvent&&(e.originalEvent.returnValue=e.result)}}}},w.removeEvent=function(e,t,n){e.removeEventListener&&e.removeEventListener(t,n)},w.Event=function(e,t){if(!(this instanceof w.Event))return new w.Event(e,t);e&&e.type?(this.originalEvent=e,this.type=e.type,this.isDefaultPrevented=e.defaultPrevented||void 0===e.defaultPrevented&&!1===e.returnValue?Ee:ke,this.target=e.target&&3===e.target.nodeType?e.target.parentNode:e.target,this.currentTarget=e.currentTarget,this.relatedTarget=e.relatedTarget):this.type=e,t&&w.extend(this,t),this.timeStamp=e&&e.timeStamp||Date.now(),this[w.expando]=!0},w.Event.prototype={constructor:w.Event,isDefaultPrevented:ke,isPropagationStopped:ke,isImmediatePropagationStopped:ke,isSimulated:!1,preventDefault:function(){var e=this.originalEvent;this.isDefaultPrevented=Ee,e&&!this.isSimulated&&e.preventDefault()},stopPropagation:function(){var e=this.originalEvent;this.isPropagationStopped=Ee,e&&!this.isSimulated&&e.stopPropagation()},stopImmediatePropagation:function(){var e=this.originalEvent;this.isImmediatePropagationStopped=Ee,e&&!this.isSimulated&&e.stopImmediatePropagation(),this.stopPropagation()}},w.each({altKey:!0,bubbles:!0,cancelable:!0,changedTouches:!0,ctrlKey:!0,detail:!0,eventPhase:!0,metaKey:!0,pageX:!0,pageY:!0,shiftKey:!0,view:!0,"char":!0,charCode:!0,key:!0,keyCode:!0,button:!0,buttons:!0,clientX:!0,clientY:!0,offsetX:!0,offsetY:!0,pointerId:!0,pointerType:!0,screenX:!0,screenY:!0,targetTouches:!0,toElement:!0,touches:!0,which:function(e){var t=e.button;return null==e.which&&we.test(e.type)?null!=e.charCode?e.charCode:e.keyCode:!e.which&&void 0!==t&&Te.test(e.type)?1&t?1:2&t?3:4&t?2:0:e.which}},w.event.addProp),w.each({mouseenter:"mouseover",mouseleave:"mouseout",pointerenter:"pointerover",pointerleave:"pointerout"},function(e,t){w.event.special[e]={delegateType:t,bindType:t,handle:function(e){var n,r=this,i=e.relatedTarget,o=e.handleObj;return i&&(i===r||w.contains(r,i))||(e.type=o.origType,n=o.handler.apply(this,arguments),e.type=t),n}}}),w.fn.extend({on:function(e,t,n,r){return De(this,e,t,n,r)},one:function(e,t,n,r){return De(this,e,t,n,r,1)},off:function(e,t,n){var r,i;if(e&&e.preventDefault&&e.handleObj)return r=e.handleObj,w(e.delegateTarget).off(r.namespace?r.origType+"."+r.namespace:r.origType,r.selector,r.handler),this;if("object"==typeof e){for(i in e)this.off(i,t,e[i]);return this}return!1!==t&&"function"!=typeof t||(n=t,t=void 0),!1===n&&(n=ke),this.each(function(){w.event.remove(this,e,n,t)})}});var Ne=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi,Ae=/<script|<style|<link/i,je=/checked\s*(?:[^=]|=\s*.checked.)/i,qe=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g;function Le(e,t){return N(e,"table")&&N(11!==t.nodeType?t:t.firstChild,"tr")?w(e).children("tbody")[0]||e:e}function He(e){return e.type=(null!==e.getAttribute("type"))+"/"+e.type,e}function Oe(e){return"true/"===(e.type||"").slice(0,5)?e.type=e.type.slice(5):e.removeAttribute("type"),e}function Pe(e,t){var n,r,i,o,a,s,u,l;if(1===t.nodeType){if(J.hasData(e)&&(o=J.access(e),a=J.set(t,o),l=o.events)){delete a.handle,a.events={};for(i in l)for(n=0,r=l[i].length;n<r;n++)w.event.add(t,i,l[i][n])}K.hasData(e)&&(s=K.access(e),u=w.extend({},s),K.set(t,u))}}function Me(e,t){var n=t.nodeName.toLowerCase();"input"===n&&pe.test(e.type)?t.checked=e.checked:"input"!==n&&"textarea"!==n||(t.defaultValue=e.defaultValue)}function Re(e,t,n,r){t=a.apply([],t);var i,o,s,u,l,c,f=0,p=e.length,d=p-1,y=t[0],v=g(y);if(v||p>1&&"string"==typeof y&&!h.checkClone&&je.test(y))return e.each(function(i){var o=e.eq(i);v&&(t[0]=y.call(this,i,o.html())),Re(o,t,n,r)});if(p&&(i=xe(t,e[0].ownerDocument,!1,e,r),o=i.firstChild,1===i.childNodes.length&&(i=o),o||r)){for(u=(s=w.map(ye(i,"script"),He)).length;f<p;f++)l=i,f!==d&&(l=w.clone(l,!0,!0),u&&w.merge(s,ye(l,"script"))),n.call(e[f],l,f);if(u)for(c=s[s.length-1].ownerDocument,w.map(s,Oe),f=0;f<u;f++)l=s[f],he.test(l.type||"")&&!J.access(l,"globalEval")&&w.contains(c,l)&&(l.src&&"module"!==(l.type||"").toLowerCase()?w._evalUrl&&w._evalUrl(l.src):m(l.textContent.replace(qe,""),c,l))}return e}function Ie(e,t,n){for(var r,i=t?w.filter(t,e):e,o=0;null!=(r=i[o]);o++)n||1!==r.nodeType||w.cleanData(ye(r)),r.parentNode&&(n&&w.contains(r.ownerDocument,r)&&ve(ye(r,"script")),r.parentNode.removeChild(r));return e}w.extend({htmlPrefilter:function(e){return e.replace(Ne,"<$1></$2>")},clone:function(e,t,n){var r,i,o,a,s=e.cloneNode(!0),u=w.contains(e.ownerDocument,e);if(!(h.noCloneChecked||1!==e.nodeType&&11!==e.nodeType||w.isXMLDoc(e)))for(a=ye(s),r=0,i=(o=ye(e)).length;r<i;r++)Me(o[r],a[r]);if(t)if(n)for(o=o||ye(e),a=a||ye(s),r=0,i=o.length;r<i;r++)Pe(o[r],a[r]);else Pe(e,s);return(a=ye(s,"script")).length>0&&ve(a,!u&&ye(e,"script")),s},cleanData:function(e){for(var t,n,r,i=w.event.special,o=0;void 0!==(n=e[o]);o++)if(Y(n)){if(t=n[J.expando]){if(t.events)for(r in t.events)i[r]?w.event.remove(n,r):w.removeEvent(n,r,t.handle);n[J.expando]=void 0}n[K.expando]&&(n[K.expando]=void 0)}}}),w.fn.extend({detach:function(e){return Ie(this,e,!0)},remove:function(e){return Ie(this,e)},text:function(e){return z(this,function(e){return void 0===e?w.text(this):this.empty().each(function(){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||(this.textContent=e)})},null,e,arguments.length)},append:function(){return Re(this,arguments,function(e){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||Le(this,e).appendChild(e)})},prepend:function(){return Re(this,arguments,function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=Le(this,e);t.insertBefore(e,t.firstChild)}})},before:function(){return Re(this,arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this)})},after:function(){return Re(this,arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)})},empty:function(){for(var e,t=0;null!=(e=this[t]);t++)1===e.nodeType&&(w.cleanData(ye(e,!1)),e.textContent="");return this},clone:function(e,t){return e=null!=e&&e,t=null==t?e:t,this.map(function(){return w.clone(this,e,t)})},html:function(e){return z(this,function(e){var t=this[0]||{},n=0,r=this.length;if(void 0===e&&1===t.nodeType)return t.innerHTML;if("string"==typeof e&&!Ae.test(e)&&!ge[(de.exec(e)||["",""])[1].toLowerCase()]){e=w.htmlPrefilter(e);try{for(;n<r;n++)1===(t=this[n]||{}).nodeType&&(w.cleanData(ye(t,!1)),t.innerHTML=e);t=0}catch(e){}}t&&this.empty().append(e)},null,e,arguments.length)},replaceWith:function(){var e=[];return Re(this,arguments,function(t){var n=this.parentNode;w.inArray(this,e)<0&&(w.cleanData(ye(this)),n&&n.replaceChild(t,this))},e)}}),w.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(e,t){w.fn[e]=function(e){for(var n,r=[],i=w(e),o=i.length-1,a=0;a<=o;a++)n=a===o?this:this.clone(!0),w(i[a])[t](n),s.apply(r,n.get());return this.pushStack(r)}});var We=new RegExp("^("+re+")(?!px)[a-z%]+$","i"),$e=function(t){var n=t.ownerDocument.defaultView;return n&&n.opener||(n=e),n.getComputedStyle(t)},Be=new RegExp(oe.join("|"),"i");!function(){function t(){if(c){l.style.cssText="position:absolute;left:-11111px;width:60px;margin-top:1px;padding:0;border:0",c.style.cssText="position:relative;display:block;box-sizing:border-box;overflow:scroll;margin:auto;border:1px;padding:1px;width:60%;top:1%",be.appendChild(l).appendChild(c);var t=e.getComputedStyle(c);i="1%"!==t.top,u=12===n(t.marginLeft),c.style.right="60%",s=36===n(t.right),o=36===n(t.width),c.style.position="absolute",a=36===c.offsetWidth||"absolute",be.removeChild(l),c=null}}function n(e){return Math.round(parseFloat(e))}var i,o,a,s,u,l=r.createElement("div"),c=r.createElement("div");c.style&&(c.style.backgroundClip="content-box",c.cloneNode(!0).style.backgroundClip="",h.clearCloneStyle="content-box"===c.style.backgroundClip,w.extend(h,{boxSizingReliable:function(){return t(),o},pixelBoxStyles:function(){return t(),s},pixelPosition:function(){return t(),i},reliableMarginLeft:function(){return t(),u},scrollboxSize:function(){return t(),a}}))}();function Fe(e,t,n){var r,i,o,a,s=e.style;return(n=n||$e(e))&&(""!==(a=n.getPropertyValue(t)||n[t])||w.contains(e.ownerDocument,e)||(a=w.style(e,t)),!h.pixelBoxStyles()&&We.test(a)&&Be.test(t)&&(r=s.width,i=s.minWidth,o=s.maxWidth,s.minWidth=s.maxWidth=s.width=a,a=n.width,s.width=r,s.minWidth=i,s.maxWidth=o)),void 0!==a?a+"":a}function _e(e,t){return{get:function(){if(!e())return(this.get=t).apply(this,arguments);delete this.get}}}var ze=/^(none|table(?!-c[ea]).+)/,Xe=/^--/,Ue={position:"absolute",visibility:"hidden",display:"block"},Ve={letterSpacing:"0",fontWeight:"400"},Ge=["Webkit","Moz","ms"],Ye=r.createElement("div").style;function Qe(e){if(e in Ye)return e;var t=e[0].toUpperCase()+e.slice(1),n=Ge.length;while(n--)if((e=Ge[n]+t)in Ye)return e}function Je(e){var t=w.cssProps[e];return t||(t=w.cssProps[e]=Qe(e)||e),t}function Ke(e,t,n){var r=ie.exec(t);return r?Math.max(0,r[2]-(n||0))+(r[3]||"px"):t}function Ze(e,t,n,r,i,o){var a="width"===t?1:0,s=0,u=0;if(n===(r?"border":"content"))return 0;for(;a<4;a+=2)"margin"===n&&(u+=w.css(e,n+oe[a],!0,i)),r?("content"===n&&(u-=w.css(e,"padding"+oe[a],!0,i)),"margin"!==n&&(u-=w.css(e,"border"+oe[a]+"Width",!0,i))):(u+=w.css(e,"padding"+oe[a],!0,i),"padding"!==n?u+=w.css(e,"border"+oe[a]+"Width",!0,i):s+=w.css(e,"border"+oe[a]+"Width",!0,i));return!r&&o>=0&&(u+=Math.max(0,Math.ceil(e["offset"+t[0].toUpperCase()+t.slice(1)]-o-u-s-.5))),u}function et(e,t,n){var r=$e(e),i=Fe(e,t,r),o="border-box"===w.css(e,"boxSizing",!1,r),a=o;if(We.test(i)){if(!n)return i;i="auto"}return a=a&&(h.boxSizingReliable()||i===e.style[t]),("auto"===i||!parseFloat(i)&&"inline"===w.css(e,"display",!1,r))&&(i=e["offset"+t[0].toUpperCase()+t.slice(1)],a=!0),(i=parseFloat(i)||0)+Ze(e,t,n||(o?"border":"content"),a,r,i)+"px"}w.extend({cssHooks:{opacity:{get:function(e,t){if(t){var n=Fe(e,"opacity");return""===n?"1":n}}}},cssNumber:{animationIterationCount:!0,columnCount:!0,fillOpacity:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{},style:function(e,t,n,r){if(e&&3!==e.nodeType&&8!==e.nodeType&&e.style){var i,o,a,s=G(t),u=Xe.test(t),l=e.style;if(u||(t=Je(s)),a=w.cssHooks[t]||w.cssHooks[s],void 0===n)return a&&"get"in a&&void 0!==(i=a.get(e,!1,r))?i:l[t];"string"==(o=typeof n)&&(i=ie.exec(n))&&i[1]&&(n=ue(e,t,i),o="number"),null!=n&&n===n&&("number"===o&&(n+=i&&i[3]||(w.cssNumber[s]?"":"px")),h.clearCloneStyle||""!==n||0!==t.indexOf("background")||(l[t]="inherit"),a&&"set"in a&&void 0===(n=a.set(e,n,r))||(u?l.setProperty(t,n):l[t]=n))}},css:function(e,t,n,r){var i,o,a,s=G(t);return Xe.test(t)||(t=Je(s)),(a=w.cssHooks[t]||w.cssHooks[s])&&"get"in a&&(i=a.get(e,!0,n)),void 0===i&&(i=Fe(e,t,r)),"normal"===i&&t in Ve&&(i=Ve[t]),""===n||n?(o=parseFloat(i),!0===n||isFinite(o)?o||0:i):i}}),w.each(["height","width"],function(e,t){w.cssHooks[t]={get:function(e,n,r){if(n)return!ze.test(w.css(e,"display"))||e.getClientRects().length&&e.getBoundingClientRect().width?et(e,t,r):se(e,Ue,function(){return et(e,t,r)})},set:function(e,n,r){var i,o=$e(e),a="border-box"===w.css(e,"boxSizing",!1,o),s=r&&Ze(e,t,r,a,o);return a&&h.scrollboxSize()===o.position&&(s-=Math.ceil(e["offset"+t[0].toUpperCase()+t.slice(1)]-parseFloat(o[t])-Ze(e,t,"border",!1,o)-.5)),s&&(i=ie.exec(n))&&"px"!==(i[3]||"px")&&(e.style[t]=n,n=w.css(e,t)),Ke(e,n,s)}}}),w.cssHooks.marginLeft=_e(h.reliableMarginLeft,function(e,t){if(t)return(parseFloat(Fe(e,"marginLeft"))||e.getBoundingClientRect().left-se(e,{marginLeft:0},function(){return e.getBoundingClientRect().left}))+"px"}),w.each({margin:"",padding:"",border:"Width"},function(e,t){w.cssHooks[e+t]={expand:function(n){for(var r=0,i={},o="string"==typeof n?n.split(" "):[n];r<4;r++)i[e+oe[r]+t]=o[r]||o[r-2]||o[0];return i}},"margin"!==e&&(w.cssHooks[e+t].set=Ke)}),w.fn.extend({css:function(e,t){return z(this,function(e,t,n){var r,i,o={},a=0;if(Array.isArray(t)){for(r=$e(e),i=t.length;a<i;a++)o[t[a]]=w.css(e,t[a],!1,r);return o}return void 0!==n?w.style(e,t,n):w.css(e,t)},e,t,arguments.length>1)}});function tt(e,t,n,r,i){return new tt.prototype.init(e,t,n,r,i)}w.Tween=tt,tt.prototype={constructor:tt,init:function(e,t,n,r,i,o){this.elem=e,this.prop=n,this.easing=i||w.easing._default,this.options=t,this.start=this.now=this.cur(),this.end=r,this.unit=o||(w.cssNumber[n]?"":"px")},cur:function(){var e=tt.propHooks[this.prop];return e&&e.get?e.get(this):tt.propHooks._default.get(this)},run:function(e){var t,n=tt.propHooks[this.prop];return this.options.duration?this.pos=t=w.easing[this.easing](e,this.options.duration*e,0,1,this.options.duration):this.pos=t=e,this.now=(this.end-this.start)*t+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),n&&n.set?n.set(this):tt.propHooks._default.set(this),this}},tt.prototype.init.prototype=tt.prototype,tt.propHooks={_default:{get:function(e){var t;return 1!==e.elem.nodeType||null!=e.elem[e.prop]&&null==e.elem.style[e.prop]?e.elem[e.prop]:(t=w.css(e.elem,e.prop,""))&&"auto"!==t?t:0},set:function(e){w.fx.step[e.prop]?w.fx.step[e.prop](e):1!==e.elem.nodeType||null==e.elem.style[w.cssProps[e.prop]]&&!w.cssHooks[e.prop]?e.elem[e.prop]=e.now:w.style(e.elem,e.prop,e.now+e.unit)}}},tt.propHooks.scrollTop=tt.propHooks.scrollLeft={set:function(e){e.elem.nodeType&&e.elem.parentNode&&(e.elem[e.prop]=e.now)}},w.easing={linear:function(e){return e},swing:function(e){return.5-Math.cos(e*Math.PI)/2},_default:"swing"},w.fx=tt.prototype.init,w.fx.step={};var nt,rt,it=/^(?:toggle|show|hide)$/,ot=/queueHooks$/;function at(){rt&&(!1===r.hidden&&e.requestAnimationFrame?e.requestAnimationFrame(at):e.setTimeout(at,w.fx.interval),w.fx.tick())}function st(){return e.setTimeout(function(){nt=void 0}),nt=Date.now()}function ut(e,t){var n,r=0,i={height:e};for(t=t?1:0;r<4;r+=2-t)i["margin"+(n=oe[r])]=i["padding"+n]=e;return t&&(i.opacity=i.width=e),i}function lt(e,t,n){for(var r,i=(pt.tweeners[t]||[]).concat(pt.tweeners["*"]),o=0,a=i.length;o<a;o++)if(r=i[o].call(n,t,e))return r}function ct(e,t,n){var r,i,o,a,s,u,l,c,f="width"in t||"height"in t,p=this,d={},h=e.style,g=e.nodeType&&ae(e),y=J.get(e,"fxshow");n.queue||(null==(a=w._queueHooks(e,"fx")).unqueued&&(a.unqueued=0,s=a.empty.fire,a.empty.fire=function(){a.unqueued||s()}),a.unqueued++,p.always(function(){p.always(function(){a.unqueued--,w.queue(e,"fx").length||a.empty.fire()})}));for(r in t)if(i=t[r],it.test(i)){if(delete t[r],o=o||"toggle"===i,i===(g?"hide":"show")){if("show"!==i||!y||void 0===y[r])continue;g=!0}d[r]=y&&y[r]||w.style(e,r)}if((u=!w.isEmptyObject(t))||!w.isEmptyObject(d)){f&&1===e.nodeType&&(n.overflow=[h.overflow,h.overflowX,h.overflowY],null==(l=y&&y.display)&&(l=J.get(e,"display")),"none"===(c=w.css(e,"display"))&&(l?c=l:(fe([e],!0),l=e.style.display||l,c=w.css(e,"display"),fe([e]))),("inline"===c||"inline-block"===c&&null!=l)&&"none"===w.css(e,"float")&&(u||(p.done(function(){h.display=l}),null==l&&(c=h.display,l="none"===c?"":c)),h.display="inline-block")),n.overflow&&(h.overflow="hidden",p.always(function(){h.overflow=n.overflow[0],h.overflowX=n.overflow[1],h.overflowY=n.overflow[2]})),u=!1;for(r in d)u||(y?"hidden"in y&&(g=y.hidden):y=J.access(e,"fxshow",{display:l}),o&&(y.hidden=!g),g&&fe([e],!0),p.done(function(){g||fe([e]),J.remove(e,"fxshow");for(r in d)w.style(e,r,d[r])})),u=lt(g?y[r]:0,r,p),r in y||(y[r]=u.start,g&&(u.end=u.start,u.start=0))}}function ft(e,t){var n,r,i,o,a;for(n in e)if(r=G(n),i=t[r],o=e[n],Array.isArray(o)&&(i=o[1],o=e[n]=o[0]),n!==r&&(e[r]=o,delete e[n]),(a=w.cssHooks[r])&&"expand"in a){o=a.expand(o),delete e[r];for(n in o)n in e||(e[n]=o[n],t[n]=i)}else t[r]=i}function pt(e,t,n){var r,i,o=0,a=pt.prefilters.length,s=w.Deferred().always(function(){delete u.elem}),u=function(){if(i)return!1;for(var t=nt||st(),n=Math.max(0,l.startTime+l.duration-t),r=1-(n/l.duration||0),o=0,a=l.tweens.length;o<a;o++)l.tweens[o].run(r);return s.notifyWith(e,[l,r,n]),r<1&&a?n:(a||s.notifyWith(e,[l,1,0]),s.resolveWith(e,[l]),!1)},l=s.promise({elem:e,props:w.extend({},t),opts:w.extend(!0,{specialEasing:{},easing:w.easing._default},n),originalProperties:t,originalOptions:n,startTime:nt||st(),duration:n.duration,tweens:[],createTween:function(t,n){var r=w.Tween(e,l.opts,t,n,l.opts.specialEasing[t]||l.opts.easing);return l.tweens.push(r),r},stop:function(t){var n=0,r=t?l.tweens.length:0;if(i)return this;for(i=!0;n<r;n++)l.tweens[n].run(1);return t?(s.notifyWith(e,[l,1,0]),s.resolveWith(e,[l,t])):s.rejectWith(e,[l,t]),this}}),c=l.props;for(ft(c,l.opts.specialEasing);o<a;o++)if(r=pt.prefilters[o].call(l,e,c,l.opts))return g(r.stop)&&(w._queueHooks(l.elem,l.opts.queue).stop=r.stop.bind(r)),r;return w.map(c,lt,l),g(l.opts.start)&&l.opts.start.call(e,l),l.progress(l.opts.progress).done(l.opts.done,l.opts.complete).fail(l.opts.fail).always(l.opts.always),w.fx.timer(w.extend(u,{elem:e,anim:l,queue:l.opts.queue})),l}w.Animation=w.extend(pt,{tweeners:{"*":[function(e,t){var n=this.createTween(e,t);return ue(n.elem,e,ie.exec(t),n),n}]},tweener:function(e,t){g(e)?(t=e,e=["*"]):e=e.match(M);for(var n,r=0,i=e.length;r<i;r++)n=e[r],pt.tweeners[n]=pt.tweeners[n]||[],pt.tweeners[n].unshift(t)},prefilters:[ct],prefilter:function(e,t){t?pt.prefilters.unshift(e):pt.prefilters.push(e)}}),w.speed=function(e,t,n){var r=e&&"object"==typeof e?w.extend({},e):{complete:n||!n&&t||g(e)&&e,duration:e,easing:n&&t||t&&!g(t)&&t};return w.fx.off?r.duration=0:"number"!=typeof r.duration&&(r.duration in w.fx.speeds?r.duration=w.fx.speeds[r.duration]:r.duration=w.fx.speeds._default),null!=r.queue&&!0!==r.queue||(r.queue="fx"),r.old=r.complete,r.complete=function(){g(r.old)&&r.old.call(this),r.queue&&w.dequeue(this,r.queue)},r},w.fn.extend({fadeTo:function(e,t,n,r){return this.filter(ae).css("opacity",0).show().end().animate({opacity:t},e,n,r)},animate:function(e,t,n,r){var i=w.isEmptyObject(e),o=w.speed(t,n,r),a=function(){var t=pt(this,w.extend({},e),o);(i||J.get(this,"finish"))&&t.stop(!0)};return a.finish=a,i||!1===o.queue?this.each(a):this.queue(o.queue,a)},stop:function(e,t,n){var r=function(e){var t=e.stop;delete e.stop,t(n)};return"string"!=typeof e&&(n=t,t=e,e=void 0),t&&!1!==e&&this.queue(e||"fx",[]),this.each(function(){var t=!0,i=null!=e&&e+"queueHooks",o=w.timers,a=J.get(this);if(i)a[i]&&a[i].stop&&r(a[i]);else for(i in a)a[i]&&a[i].stop&&ot.test(i)&&r(a[i]);for(i=o.length;i--;)o[i].elem!==this||null!=e&&o[i].queue!==e||(o[i].anim.stop(n),t=!1,o.splice(i,1));!t&&n||w.dequeue(this,e)})},finish:function(e){return!1!==e&&(e=e||"fx"),this.each(function(){var t,n=J.get(this),r=n[e+"queue"],i=n[e+"queueHooks"],o=w.timers,a=r?r.length:0;for(n.finish=!0,w.queue(this,e,[]),i&&i.stop&&i.stop.call(this,!0),t=o.length;t--;)o[t].elem===this&&o[t].queue===e&&(o[t].anim.stop(!0),o.splice(t,1));for(t=0;t<a;t++)r[t]&&r[t].finish&&r[t].finish.call(this);delete n.finish})}}),w.each(["toggle","show","hide"],function(e,t){var n=w.fn[t];w.fn[t]=function(e,r,i){return null==e||"boolean"==typeof e?n.apply(this,arguments):this.animate(ut(t,!0),e,r,i)}}),w.each({slideDown:ut("show"),slideUp:ut("hide"),slideToggle:ut("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(e,t){w.fn[e]=function(e,n,r){return this.animate(t,e,n,r)}}),w.timers=[],w.fx.tick=function(){var e,t=0,n=w.timers;for(nt=Date.now();t<n.length;t++)(e=n[t])()||n[t]!==e||n.splice(t--,1);n.length||w.fx.stop(),nt=void 0},w.fx.timer=function(e){w.timers.push(e),w.fx.start()},w.fx.interval=13,w.fx.start=function(){rt||(rt=!0,at())},w.fx.stop=function(){rt=null},w.fx.speeds={slow:600,fast:200,_default:400},w.fn.delay=function(t,n){return t=w.fx?w.fx.speeds[t]||t:t,n=n||"fx",this.queue(n,function(n,r){var i=e.setTimeout(n,t);r.stop=function(){e.clearTimeout(i)}})},function(){var e=r.createElement("input"),t=r.createElement("select").appendChild(r.createElement("option"));e.type="checkbox",h.checkOn=""!==e.value,h.optSelected=t.selected,(e=r.createElement("input")).value="t",e.type="radio",h.radioValue="t"===e.value}();var dt,ht=w.expr.attrHandle;w.fn.extend({attr:function(e,t){return z(this,w.attr,e,t,arguments.length>1)},removeAttr:function(e){return this.each(function(){w.removeAttr(this,e)})}}),w.extend({attr:function(e,t,n){var r,i,o=e.nodeType;if(3!==o&&8!==o&&2!==o)return"undefined"==typeof e.getAttribute?w.prop(e,t,n):(1===o&&w.isXMLDoc(e)||(i=w.attrHooks[t.toLowerCase()]||(w.expr.match.bool.test(t)?dt:void 0)),void 0!==n?null===n?void w.removeAttr(e,t):i&&"set"in i&&void 0!==(r=i.set(e,n,t))?r:(e.setAttribute(t,n+""),n):i&&"get"in i&&null!==(r=i.get(e,t))?r:null==(r=w.find.attr(e,t))?void 0:r)},attrHooks:{type:{set:function(e,t){if(!h.radioValue&&"radio"===t&&N(e,"input")){var n=e.value;return e.setAttribute("type",t),n&&(e.value=n),t}}}},removeAttr:function(e,t){var n,r=0,i=t&&t.match(M);if(i&&1===e.nodeType)while(n=i[r++])e.removeAttribute(n)}}),dt={set:function(e,t,n){return!1===t?w.removeAttr(e,n):e.setAttribute(n,n),n}},w.each(w.expr.match.bool.source.match(/\w+/g),function(e,t){var n=ht[t]||w.find.attr;ht[t]=function(e,t,r){var i,o,a=t.toLowerCase();return r||(o=ht[a],ht[a]=i,i=null!=n(e,t,r)?a:null,ht[a]=o),i}});var gt=/^(?:input|select|textarea|button)$/i,yt=/^(?:a|area)$/i;w.fn.extend({prop:function(e,t){return z(this,w.prop,e,t,arguments.length>1)},removeProp:function(e){return this.each(function(){delete this[w.propFix[e]||e]})}}),w.extend({prop:function(e,t,n){var r,i,o=e.nodeType;if(3!==o&&8!==o&&2!==o)return 1===o&&w.isXMLDoc(e)||(t=w.propFix[t]||t,i=w.propHooks[t]),void 0!==n?i&&"set"in i&&void 0!==(r=i.set(e,n,t))?r:e[t]=n:i&&"get"in i&&null!==(r=i.get(e,t))?r:e[t]},propHooks:{tabIndex:{get:function(e){var t=w.find.attr(e,"tabindex");return t?parseInt(t,10):gt.test(e.nodeName)||yt.test(e.nodeName)&&e.href?0:-1}}},propFix:{"for":"htmlFor","class":"className"}}),h.optSelected||(w.propHooks.selected={get:function(e){var t=e.parentNode;return t&&t.parentNode&&t.parentNode.selectedIndex,null},set:function(e){var t=e.parentNode;t&&(t.selectedIndex,t.parentNode&&t.parentNode.selectedIndex)}}),w.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){w.propFix[this.toLowerCase()]=this});function vt(e){return(e.match(M)||[]).join(" ")}function mt(e){return e.getAttribute&&e.getAttribute("class")||""}function xt(e){return Array.isArray(e)?e:"string"==typeof e?e.match(M)||[]:[]}w.fn.extend({addClass:function(e){var t,n,r,i,o,a,s,u=0;if(g(e))return this.each(function(t){w(this).addClass(e.call(this,t,mt(this)))});if((t=xt(e)).length)while(n=this[u++])if(i=mt(n),r=1===n.nodeType&&" "+vt(i)+" "){a=0;while(o=t[a++])r.indexOf(" "+o+" ")<0&&(r+=o+" ");i!==(s=vt(r))&&n.setAttribute("class",s)}return this},removeClass:function(e){var t,n,r,i,o,a,s,u=0;if(g(e))return this.each(function(t){w(this).removeClass(e.call(this,t,mt(this)))});if(!arguments.length)return this.attr("class","");if((t=xt(e)).length)while(n=this[u++])if(i=mt(n),r=1===n.nodeType&&" "+vt(i)+" "){a=0;while(o=t[a++])while(r.indexOf(" "+o+" ")>-1)r=r.replace(" "+o+" "," ");i!==(s=vt(r))&&n.setAttribute("class",s)}return this},toggleClass:function(e,t){var n=typeof e,r="string"===n||Array.isArray(e);return"boolean"==typeof t&&r?t?this.addClass(e):this.removeClass(e):g(e)?this.each(function(n){w(this).toggleClass(e.call(this,n,mt(this),t),t)}):this.each(function(){var t,i,o,a;if(r){i=0,o=w(this),a=xt(e);while(t=a[i++])o.hasClass(t)?o.removeClass(t):o.addClass(t)}else void 0!==e&&"boolean"!==n||((t=mt(this))&&J.set(this,"__className__",t),this.setAttribute&&this.setAttribute("class",t||!1===e?"":J.get(this,"__className__")||""))})},hasClass:function(e){var t,n,r=0;t=" "+e+" ";while(n=this[r++])if(1===n.nodeType&&(" "+vt(mt(n))+" ").indexOf(t)>-1)return!0;return!1}});var bt=/\r/g;w.fn.extend({val:function(e){var t,n,r,i=this[0];{if(arguments.length)return r=g(e),this.each(function(n){var i;1===this.nodeType&&(null==(i=r?e.call(this,n,w(this).val()):e)?i="":"number"==typeof i?i+="":Array.isArray(i)&&(i=w.map(i,function(e){return null==e?"":e+""})),(t=w.valHooks[this.type]||w.valHooks[this.nodeName.toLowerCase()])&&"set"in t&&void 0!==t.set(this,i,"value")||(this.value=i))});if(i)return(t=w.valHooks[i.type]||w.valHooks[i.nodeName.toLowerCase()])&&"get"in t&&void 0!==(n=t.get(i,"value"))?n:"string"==typeof(n=i.value)?n.replace(bt,""):null==n?"":n}}}),w.extend({valHooks:{option:{get:function(e){var t=w.find.attr(e,"value");return null!=t?t:vt(w.text(e))}},select:{get:function(e){var t,n,r,i=e.options,o=e.selectedIndex,a="select-one"===e.type,s=a?null:[],u=a?o+1:i.length;for(r=o<0?u:a?o:0;r<u;r++)if(((n=i[r]).selected||r===o)&&!n.disabled&&(!n.parentNode.disabled||!N(n.parentNode,"optgroup"))){if(t=w(n).val(),a)return t;s.push(t)}return s},set:function(e,t){var n,r,i=e.options,o=w.makeArray(t),a=i.length;while(a--)((r=i[a]).selected=w.inArray(w.valHooks.option.get(r),o)>-1)&&(n=!0);return n||(e.selectedIndex=-1),o}}}}),w.each(["radio","checkbox"],function(){w.valHooks[this]={set:function(e,t){if(Array.isArray(t))return e.checked=w.inArray(w(e).val(),t)>-1}},h.checkOn||(w.valHooks[this].get=function(e){return null===e.getAttribute("value")?"on":e.value})}),h.focusin="onfocusin"in e;var wt=/^(?:focusinfocus|focusoutblur)$/,Tt=function(e){e.stopPropagation()};w.extend(w.event,{trigger:function(t,n,i,o){var a,s,u,l,c,p,d,h,v=[i||r],m=f.call(t,"type")?t.type:t,x=f.call(t,"namespace")?t.namespace.split("."):[];if(s=h=u=i=i||r,3!==i.nodeType&&8!==i.nodeType&&!wt.test(m+w.event.triggered)&&(m.indexOf(".")>-1&&(m=(x=m.split(".")).shift(),x.sort()),c=m.indexOf(":")<0&&"on"+m,t=t[w.expando]?t:new w.Event(m,"object"==typeof t&&t),t.isTrigger=o?2:3,t.namespace=x.join("."),t.rnamespace=t.namespace?new RegExp("(^|\\.)"+x.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,t.result=void 0,t.target||(t.target=i),n=null==n?[t]:w.makeArray(n,[t]),d=w.event.special[m]||{},o||!d.trigger||!1!==d.trigger.apply(i,n))){if(!o&&!d.noBubble&&!y(i)){for(l=d.delegateType||m,wt.test(l+m)||(s=s.parentNode);s;s=s.parentNode)v.push(s),u=s;u===(i.ownerDocument||r)&&v.push(u.defaultView||u.parentWindow||e)}a=0;while((s=v[a++])&&!t.isPropagationStopped())h=s,t.type=a>1?l:d.bindType||m,(p=(J.get(s,"events")||{})[t.type]&&J.get(s,"handle"))&&p.apply(s,n),(p=c&&s[c])&&p.apply&&Y(s)&&(t.result=p.apply(s,n),!1===t.result&&t.preventDefault());return t.type=m,o||t.isDefaultPrevented()||d._default&&!1!==d._default.apply(v.pop(),n)||!Y(i)||c&&g(i[m])&&!y(i)&&((u=i[c])&&(i[c]=null),w.event.triggered=m,t.isPropagationStopped()&&h.addEventListener(m,Tt),i[m](),t.isPropagationStopped()&&h.removeEventListener(m,Tt),w.event.triggered=void 0,u&&(i[c]=u)),t.result}},simulate:function(e,t,n){var r=w.extend(new w.Event,n,{type:e,isSimulated:!0});w.event.trigger(r,null,t)}}),w.fn.extend({trigger:function(e,t){return this.each(function(){w.event.trigger(e,t,this)})},triggerHandler:function(e,t){var n=this[0];if(n)return w.event.trigger(e,t,n,!0)}}),h.focusin||w.each({focus:"focusin",blur:"focusout"},function(e,t){var n=function(e){w.event.simulate(t,e.target,w.event.fix(e))};w.event.special[t]={setup:function(){var r=this.ownerDocument||this,i=J.access(r,t);i||r.addEventListener(e,n,!0),J.access(r,t,(i||0)+1)},teardown:function(){var r=this.ownerDocument||this,i=J.access(r,t)-1;i?J.access(r,t,i):(r.removeEventListener(e,n,!0),J.remove(r,t))}}});var Ct=e.location,Et=Date.now(),kt=/\?/;w.parseXML=function(t){var n;if(!t||"string"!=typeof t)return null;try{n=(new e.DOMParser).parseFromString(t,"text/xml")}catch(e){n=void 0}return n&&!n.getElementsByTagName("parsererror").length||w.error("Invalid XML: "+t),n};var St=/\[\]$/,Dt=/\r?\n/g,Nt=/^(?:submit|button|image|reset|file)$/i,At=/^(?:input|select|textarea|keygen)/i;function jt(e,t,n,r){var i;if(Array.isArray(t))w.each(t,function(t,i){n||St.test(e)?r(e,i):jt(e+"["+("object"==typeof i&&null!=i?t:"")+"]",i,n,r)});else if(n||"object"!==x(t))r(e,t);else for(i in t)jt(e+"["+i+"]",t[i],n,r)}w.param=function(e,t){var n,r=[],i=function(e,t){var n=g(t)?t():t;r[r.length]=encodeURIComponent(e)+"="+encodeURIComponent(null==n?"":n)};if(Array.isArray(e)||e.jquery&&!w.isPlainObject(e))w.each(e,function(){i(this.name,this.value)});else for(n in e)jt(n,e[n],t,i);return r.join("&")},w.fn.extend({serialize:function(){return w.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var e=w.prop(this,"elements");return e?w.makeArray(e):this}).filter(function(){var e=this.type;return this.name&&!w(this).is(":disabled")&&At.test(this.nodeName)&&!Nt.test(e)&&(this.checked||!pe.test(e))}).map(function(e,t){var n=w(this).val();return null==n?null:Array.isArray(n)?w.map(n,function(e){return{name:t.name,value:e.replace(Dt,"\r\n")}}):{name:t.name,value:n.replace(Dt,"\r\n")}}).get()}});var qt=/%20/g,Lt=/#.*$/,Ht=/([?&])_=[^&]*/,Ot=/^(.*?):[ \t]*([^\r\n]*)$/gm,Pt=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,Mt=/^(?:GET|HEAD)$/,Rt=/^\/\//,It={},Wt={},$t="*/".concat("*"),Bt=r.createElement("a");Bt.href=Ct.href;function Ft(e){return function(t,n){"string"!=typeof t&&(n=t,t="*");var r,i=0,o=t.toLowerCase().match(M)||[];if(g(n))while(r=o[i++])"+"===r[0]?(r=r.slice(1)||"*",(e[r]=e[r]||[]).unshift(n)):(e[r]=e[r]||[]).push(n)}}function _t(e,t,n,r){var i={},o=e===Wt;function a(s){var u;return i[s]=!0,w.each(e[s]||[],function(e,s){var l=s(t,n,r);return"string"!=typeof l||o||i[l]?o?!(u=l):void 0:(t.dataTypes.unshift(l),a(l),!1)}),u}return a(t.dataTypes[0])||!i["*"]&&a("*")}function zt(e,t){var n,r,i=w.ajaxSettings.flatOptions||{};for(n in t)void 0!==t[n]&&((i[n]?e:r||(r={}))[n]=t[n]);return r&&w.extend(!0,e,r),e}function Xt(e,t,n){var r,i,o,a,s=e.contents,u=e.dataTypes;while("*"===u[0])u.shift(),void 0===r&&(r=e.mimeType||t.getResponseHeader("Content-Type"));if(r)for(i in s)if(s[i]&&s[i].test(r)){u.unshift(i);break}if(u[0]in n)o=u[0];else{for(i in n){if(!u[0]||e.converters[i+" "+u[0]]){o=i;break}a||(a=i)}o=o||a}if(o)return o!==u[0]&&u.unshift(o),n[o]}function Ut(e,t,n,r){var i,o,a,s,u,l={},c=e.dataTypes.slice();if(c[1])for(a in e.converters)l[a.toLowerCase()]=e.converters[a];o=c.shift();while(o)if(e.responseFields[o]&&(n[e.responseFields[o]]=t),!u&&r&&e.dataFilter&&(t=e.dataFilter(t,e.dataType)),u=o,o=c.shift())if("*"===o)o=u;else if("*"!==u&&u!==o){if(!(a=l[u+" "+o]||l["* "+o]))for(i in l)if((s=i.split(" "))[1]===o&&(a=l[u+" "+s[0]]||l["* "+s[0]])){!0===a?a=l[i]:!0!==l[i]&&(o=s[0],c.unshift(s[1]));break}if(!0!==a)if(a&&e["throws"])t=a(t);else try{t=a(t)}catch(e){return{state:"parsererror",error:a?e:"No conversion from "+u+" to "+o}}}return{state:"success",data:t}}w.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:Ct.href,type:"GET",isLocal:Pt.test(Ct.protocol),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":$t,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/\bxml\b/,html:/\bhtml/,json:/\bjson\b/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":JSON.parse,"text xml":w.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(e,t){return t?zt(zt(e,w.ajaxSettings),t):zt(w.ajaxSettings,e)},ajaxPrefilter:Ft(It),ajaxTransport:Ft(Wt),ajax:function(t,n){"object"==typeof t&&(n=t,t=void 0),n=n||{};var i,o,a,s,u,l,c,f,p,d,h=w.ajaxSetup({},n),g=h.context||h,y=h.context&&(g.nodeType||g.jquery)?w(g):w.event,v=w.Deferred(),m=w.Callbacks("once memory"),x=h.statusCode||{},b={},T={},C="canceled",E={readyState:0,getResponseHeader:function(e){var t;if(c){if(!s){s={};while(t=Ot.exec(a))s[t[1].toLowerCase()]=t[2]}t=s[e.toLowerCase()]}return null==t?null:t},getAllResponseHeaders:function(){return c?a:null},setRequestHeader:function(e,t){return null==c&&(e=T[e.toLowerCase()]=T[e.toLowerCase()]||e,b[e]=t),this},overrideMimeType:function(e){return null==c&&(h.mimeType=e),this},statusCode:function(e){var t;if(e)if(c)E.always(e[E.status]);else for(t in e)x[t]=[x[t],e[t]];return this},abort:function(e){var t=e||C;return i&&i.abort(t),k(0,t),this}};if(v.promise(E),h.url=((t||h.url||Ct.href)+"").replace(Rt,Ct.protocol+"//"),h.type=n.method||n.type||h.method||h.type,h.dataTypes=(h.dataType||"*").toLowerCase().match(M)||[""],null==h.crossDomain){l=r.createElement("a");try{l.href=h.url,l.href=l.href,h.crossDomain=Bt.protocol+"//"+Bt.host!=l.protocol+"//"+l.host}catch(e){h.crossDomain=!0}}if(h.data&&h.processData&&"string"!=typeof h.data&&(h.data=w.param(h.data,h.traditional)),_t(It,h,n,E),c)return E;(f=w.event&&h.global)&&0==w.active++&&w.event.trigger("ajaxStart"),h.type=h.type.toUpperCase(),h.hasContent=!Mt.test(h.type),o=h.url.replace(Lt,""),h.hasContent?h.data&&h.processData&&0===(h.contentType||"").indexOf("application/x-www-form-urlencoded")&&(h.data=h.data.replace(qt,"+")):(d=h.url.slice(o.length),h.data&&(h.processData||"string"==typeof h.data)&&(o+=(kt.test(o)?"&":"?")+h.data,delete h.data),!1===h.cache&&(o=o.replace(Ht,"$1"),d=(kt.test(o)?"&":"?")+"_="+Et+++d),h.url=o+d),h.ifModified&&(w.lastModified[o]&&E.setRequestHeader("If-Modified-Since",w.lastModified[o]),w.etag[o]&&E.setRequestHeader("If-None-Match",w.etag[o])),(h.data&&h.hasContent&&!1!==h.contentType||n.contentType)&&E.setRequestHeader("Content-Type",h.contentType),E.setRequestHeader("Accept",h.dataTypes[0]&&h.accepts[h.dataTypes[0]]?h.accepts[h.dataTypes[0]]+("*"!==h.dataTypes[0]?", "+$t+"; q=0.01":""):h.accepts["*"]);for(p in h.headers)E.setRequestHeader(p,h.headers[p]);if(h.beforeSend&&(!1===h.beforeSend.call(g,E,h)||c))return E.abort();if(C="abort",m.add(h.complete),E.done(h.success),E.fail(h.error),i=_t(Wt,h,n,E)){if(E.readyState=1,f&&y.trigger("ajaxSend",[E,h]),c)return E;h.async&&h.timeout>0&&(u=e.setTimeout(function(){E.abort("timeout")},h.timeout));try{c=!1,i.send(b,k)}catch(e){if(c)throw e;k(-1,e)}}else k(-1,"No Transport");function k(t,n,r,s){var l,p,d,b,T,C=n;c||(c=!0,u&&e.clearTimeout(u),i=void 0,a=s||"",E.readyState=t>0?4:0,l=t>=200&&t<300||304===t,r&&(b=Xt(h,E,r)),b=Ut(h,b,E,l),l?(h.ifModified&&((T=E.getResponseHeader("Last-Modified"))&&(w.lastModified[o]=T),(T=E.getResponseHeader("etag"))&&(w.etag[o]=T)),204===t||"HEAD"===h.type?C="nocontent":304===t?C="notmodified":(C=b.state,p=b.data,l=!(d=b.error))):(d=C,!t&&C||(C="error",t<0&&(t=0))),E.status=t,E.statusText=(n||C)+"",l?v.resolveWith(g,[p,C,E]):v.rejectWith(g,[E,C,d]),E.statusCode(x),x=void 0,f&&y.trigger(l?"ajaxSuccess":"ajaxError",[E,h,l?p:d]),m.fireWith(g,[E,C]),f&&(y.trigger("ajaxComplete",[E,h]),--w.active||w.event.trigger("ajaxStop")))}return E},getJSON:function(e,t,n){return w.get(e,t,n,"json")},getScript:function(e,t){return w.get(e,void 0,t,"script")}}),w.each(["get","post"],function(e,t){w[t]=function(e,n,r,i){return g(n)&&(i=i||r,r=n,n=void 0),w.ajax(w.extend({url:e,type:t,dataType:i,data:n,success:r},w.isPlainObject(e)&&e))}}),w._evalUrl=function(e){return w.ajax({url:e,type:"GET",dataType:"script",cache:!0,async:!1,global:!1,"throws":!0})},w.fn.extend({wrapAll:function(e){var t;return this[0]&&(g(e)&&(e=e.call(this[0])),t=w(e,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&t.insertBefore(this[0]),t.map(function(){var e=this;while(e.firstElementChild)e=e.firstElementChild;return e}).append(this)),this},wrapInner:function(e){return g(e)?this.each(function(t){w(this).wrapInner(e.call(this,t))}):this.each(function(){var t=w(this),n=t.contents();n.length?n.wrapAll(e):t.append(e)})},wrap:function(e){var t=g(e);return this.each(function(n){w(this).wrapAll(t?e.call(this,n):e)})},unwrap:function(e){return this.parent(e).not("body").each(function(){w(this).replaceWith(this.childNodes)}),this}}),w.expr.pseudos.hidden=function(e){return!w.expr.pseudos.visible(e)},w.expr.pseudos.visible=function(e){return!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)},w.ajaxSettings.xhr=function(){try{return new e.XMLHttpRequest}catch(e){}};var Vt={0:200,1223:204},Gt=w.ajaxSettings.xhr();h.cors=!!Gt&&"withCredentials"in Gt,h.ajax=Gt=!!Gt,w.ajaxTransport(function(t){var n,r;if(h.cors||Gt&&!t.crossDomain)return{send:function(i,o){var a,s=t.xhr();if(s.open(t.type,t.url,t.async,t.username,t.password),t.xhrFields)for(a in t.xhrFields)s[a]=t.xhrFields[a];t.mimeType&&s.overrideMimeType&&s.overrideMimeType(t.mimeType),t.crossDomain||i["X-Requested-With"]||(i["X-Requested-With"]="XMLHttpRequest");for(a in i)s.setRequestHeader(a,i[a]);n=function(e){return function(){n&&(n=r=s.onload=s.onerror=s.onabort=s.ontimeout=s.onreadystatechange=null,"abort"===e?s.abort():"error"===e?"number"!=typeof s.status?o(0,"error"):o(s.status,s.statusText):o(Vt[s.status]||s.status,s.statusText,"text"!==(s.responseType||"text")||"string"!=typeof s.responseText?{binary:s.response}:{text:s.responseText},s.getAllResponseHeaders()))}},s.onload=n(),r=s.onerror=s.ontimeout=n("error"),void 0!==s.onabort?s.onabort=r:s.onreadystatechange=function(){4===s.readyState&&e.setTimeout(function(){n&&r()})},n=n("abort");try{s.send(t.hasContent&&t.data||null)}catch(e){if(n)throw e}},abort:function(){n&&n()}}}),w.ajaxPrefilter(function(e){e.crossDomain&&(e.contents.script=!1)}),w.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/\b(?:java|ecma)script\b/},converters:{"text script":function(e){return w.globalEval(e),e}}}),w.ajaxPrefilter("script",function(e){void 0===e.cache&&(e.cache=!1),e.crossDomain&&(e.type="GET")}),w.ajaxTransport("script",function(e){if(e.crossDomain){var t,n;return{send:function(i,o){t=w("<script>").prop({charset:e.scriptCharset,src:e.url}).on("load error",n=function(e){t.remove(),n=null,e&&o("error"===e.type?404:200,e.type)}),r.head.appendChild(t[0])},abort:function(){n&&n()}}}});var Yt=[],Qt=/(=)\?(?=&|$)|\?\?/;w.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=Yt.pop()||w.expando+"_"+Et++;return this[e]=!0,e}}),w.ajaxPrefilter("json jsonp",function(t,n,r){var i,o,a,s=!1!==t.jsonp&&(Qt.test(t.url)?"url":"string"==typeof t.data&&0===(t.contentType||"").indexOf("application/x-www-form-urlencoded")&&Qt.test(t.data)&&"data");if(s||"jsonp"===t.dataTypes[0])return i=t.jsonpCallback=g(t.jsonpCallback)?t.jsonpCallback():t.jsonpCallback,s?t[s]=t[s].replace(Qt,"$1"+i):!1!==t.jsonp&&(t.url+=(kt.test(t.url)?"&":"?")+t.jsonp+"="+i),t.converters["script json"]=function(){return a||w.error(i+" was not called"),a[0]},t.dataTypes[0]="json",o=e[i],e[i]=function(){a=arguments},r.always(function(){void 0===o?w(e).removeProp(i):e[i]=o,t[i]&&(t.jsonpCallback=n.jsonpCallback,Yt.push(i)),a&&g(o)&&o(a[0]),a=o=void 0}),"script"}),h.createHTMLDocument=function(){var e=r.implementation.createHTMLDocument("").body;return e.innerHTML="<form></form><form></form>",2===e.childNodes.length}(),w.parseHTML=function(e,t,n){if("string"!=typeof e)return[];"boolean"==typeof t&&(n=t,t=!1);var i,o,a;return t||(h.createHTMLDocument?((i=(t=r.implementation.createHTMLDocument("")).createElement("base")).href=r.location.href,t.head.appendChild(i)):t=r),o=A.exec(e),a=!n&&[],o?[t.createElement(o[1])]:(o=xe([e],t,a),a&&a.length&&w(a).remove(),w.merge([],o.childNodes))},w.fn.load=function(e,t,n){var r,i,o,a=this,s=e.indexOf(" ");return s>-1&&(r=vt(e.slice(s)),e=e.slice(0,s)),g(t)?(n=t,t=void 0):t&&"object"==typeof t&&(i="POST"),a.length>0&&w.ajax({url:e,type:i||"GET",dataType:"html",data:t}).done(function(e){o=arguments,a.html(r?w("<div>").append(w.parseHTML(e)).find(r):e)}).always(n&&function(e,t){a.each(function(){n.apply(this,o||[e.responseText,t,e])})}),this},w.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){w.fn[t]=function(e){return this.on(t,e)}}),w.expr.pseudos.animated=function(e){return w.grep(w.timers,function(t){return e===t.elem}).length},w.offset={setOffset:function(e,t,n){var r,i,o,a,s,u,l,c=w.css(e,"position"),f=w(e),p={};"static"===c&&(e.style.position="relative"),s=f.offset(),o=w.css(e,"top"),u=w.css(e,"left"),(l=("absolute"===c||"fixed"===c)&&(o+u).indexOf("auto")>-1)?(a=(r=f.position()).top,i=r.left):(a=parseFloat(o)||0,i=parseFloat(u)||0),g(t)&&(t=t.call(e,n,w.extend({},s))),null!=t.top&&(p.top=t.top-s.top+a),null!=t.left&&(p.left=t.left-s.left+i),"using"in t?t.using.call(e,p):f.css(p)}},w.fn.extend({offset:function(e){if(arguments.length)return void 0===e?this:this.each(function(t){w.offset.setOffset(this,e,t)});var t,n,r=this[0];if(r)return r.getClientRects().length?(t=r.getBoundingClientRect(),n=r.ownerDocument.defaultView,{top:t.top+n.pageYOffset,left:t.left+n.pageXOffset}):{top:0,left:0}},position:function(){if(this[0]){var e,t,n,r=this[0],i={top:0,left:0};if("fixed"===w.css(r,"position"))t=r.getBoundingClientRect();else{t=this.offset(),n=r.ownerDocument,e=r.offsetParent||n.documentElement;while(e&&(e===n.body||e===n.documentElement)&&"static"===w.css(e,"position"))e=e.parentNode;e&&e!==r&&1===e.nodeType&&((i=w(e).offset()).top+=w.css(e,"borderTopWidth",!0),i.left+=w.css(e,"borderLeftWidth",!0))}return{top:t.top-i.top-w.css(r,"marginTop",!0),left:t.left-i.left-w.css(r,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var e=this.offsetParent;while(e&&"static"===w.css(e,"position"))e=e.offsetParent;return e||be})}}),w.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(e,t){var n="pageYOffset"===t;w.fn[e]=function(r){return z(this,function(e,r,i){var o;if(y(e)?o=e:9===e.nodeType&&(o=e.defaultView),void 0===i)return o?o[t]:e[r];o?o.scrollTo(n?o.pageXOffset:i,n?i:o.pageYOffset):e[r]=i},e,r,arguments.length)}}),w.each(["top","left"],function(e,t){w.cssHooks[t]=_e(h.pixelPosition,function(e,n){if(n)return n=Fe(e,t),We.test(n)?w(e).position()[t]+"px":n})}),w.each({Height:"height",Width:"width"},function(e,t){w.each({padding:"inner"+e,content:t,"":"outer"+e},function(n,r){w.fn[r]=function(i,o){var a=arguments.length&&(n||"boolean"!=typeof i),s=n||(!0===i||!0===o?"margin":"border");return z(this,function(t,n,i){var o;return y(t)?0===r.indexOf("outer")?t["inner"+e]:t.document.documentElement["client"+e]:9===t.nodeType?(o=t.documentElement,Math.max(t.body["scroll"+e],o["scroll"+e],t.body["offset"+e],o["offset"+e],o["client"+e])):void 0===i?w.css(t,n,s):w.style(t,n,i,s)},t,a?i:void 0,a)}})}),w.each("blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu".split(" "),function(e,t){w.fn[t]=function(e,n){return arguments.length>0?this.on(t,null,e,n):this.trigger(t)}}),w.fn.extend({hover:function(e,t){return this.mouseenter(e).mouseleave(t||e)}}),w.fn.extend({bind:function(e,t,n){return this.on(e,null,t,n)},unbind:function(e,t){return this.off(e,null,t)},delegate:function(e,t,n,r){return this.on(t,e,n,r)},undelegate:function(e,t,n){return 1===arguments.length?this.off(e,"**"):this.off(t,e||"**",n)}}),w.proxy=function(e,t){var n,r,i;if("string"==typeof t&&(n=e[t],t=e,e=n),g(e))return r=o.call(arguments,2),i=function(){return e.apply(t||this,r.concat(o.call(arguments)))},i.guid=e.guid=e.guid||w.guid++,i},w.holdReady=function(e){e?w.readyWait++:w.ready(!0)},w.isArray=Array.isArray,w.parseJSON=JSON.parse,w.nodeName=N,w.isFunction=g,w.isWindow=y,w.camelCase=G,w.type=x,w.now=Date.now,w.isNumeric=function(e){var t=w.type(e);return("number"===t||"string"===t)&&!isNaN(e-parseFloat(e))},"function"==typeof define&&define.amd&&define("jquery",[],function(){return w});var Jt=e.jQuery,Kt=e.$;return w.noConflict=function(t){return e.$===w&&(e.$=Kt),t&&e.jQuery===w&&(e.jQuery=Jt),w},t||(e.jQuery=e.$=w),w});
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>sm2</title>
<!-- <script src="js/utils/hex.js"></script>
<script src="js/utils/byteUtil.js"></script>
<script src="js/crypto/sm3.js"></script>
<script src="js/ext/jsbn.js"></script>
<script src="js/ext/jsbn2.js"></script>
<script src="js/ext/ec.js"></script>
<script src="js/ext/ec-patch.js"></script>
<script src="js/ext/prng4.js"></script>
<script src="js/ext/rng.js"></script>
<script src="js/crypto/sm2.js"></script> -->
<script src="build/jquery-3.3.1.min.js"></script>
<!-- <script src="js/utils/hex.js"></script> -->
<script src="build/SM.js"></script>
<style>
body {
text-align: center;
}
.div {
margin: 0 auto;
border: 1px solid #f00;
}
</style>
</head>
<body>
<div style="text-align: center">
<div>
<form action="#" method="post">
<table style="margin-left: auto; margin-right: auto">
<!--border=0 cellpadding=0 cellspacing=0-->
<tr>
<td style="width: auto; text-align: right">sm2公钥:</td>
<td style="text-align: left" valign="middle">
<textarea
rows="2"
cols="50"
name="pubkey"
id="pubkey"
></textarea>
</td>
</tr>
<tr>
<td style="width: auto; text-align: right">sm2私钥:</td>
<td style="text-align: left" valign="middle">
<textarea
rows="2"
cols="50"
name="privkey"
id="privkey"
></textarea>
</td>
</tr>
<tr>
<td style="width: auto; text-align: right">输入数据:</td>
<td style="text-align: left" valign="middle">
<textarea
rows="5"
cols="50"
name="inputtext"
id="inputtext"
></textarea>
</td>
</tr>
<tr>
<td style="width: auto; text-align: right">结果:</td>
<td style="text-align: left" valign="middle">
<textarea
rows="5"
cols="50"
name="crypttext"
id="crypttext"
></textarea>
</td>
</tr>
<tr>
<td colspan="2" style="width: auto; text-align: center">
<input type="button" value="加密" id="btn_enc" />
<input type="button" value="解密" id="btn_dec" />
</td>
</tr>
</table>
</form>
</div>
</div>
<script>
/**
* 随机生成数据测试
*/
function generate(len) {
var realLen = 0;
if (len != undefined && len > 0) {
realLen = len;
} else {
realLen = parseInt(Math.random() * 1024) + 1;
}
var data = new Array(realLen);
for (var i = 0; i < realLen; i++) {
data[i] = parseInt(Math.random() * 256);
}
return data;
}
/**
* 生成密钥
*/
// $("#btn_genkey").click(function () {
// var sm2 = new SM2();
// var keyPair = sm2.generateKeyPairHex(); //得到的keypair结构:{'privkeyhex': hPrv, 'pubkeyhex': hPub}
// $("#pubkey").val(keyPair["pubkeyhex"].toUpperCase());
// $("#privkey").val(keyPair["privkeyhex"].toUpperCase());
// });
/*
* 测试加密
*/
$("#btn_enc").click(function () {
var pubkey = $("#pubkey").val();
if (pubkey == "" || pubkey.length < 64) {
alert("公钥为空或错误");
}
var inputtext = $("#inputtext").val();
if (inputtext.length <= 0) {
alert("输入数据不能为空");
}
// inputtext = Hex.hexToUtf8Str(Hex.utf8StrToHex(inputtext))
var cipher = SM.encrypt(inputtext, pubkey);
$("#crypttext").val(cipher);
});
/*
* 测试解密
*/
$("#btn_dec").click(function () {
var privkey = $("#privkey").val();
if (privkey == "" || privkey.length < 32) {
alert("私钥为空或错误");
}
var inputtext = $("#inputtext").val();
if (inputtext.length <= 0) {
alert("输入数据不能为空");
}
//sm2加密
// var sm2 = new SM2();
// try{
// var plain = sm2Decrypt(inputtext, privkey);
var data = SM.decrypt(inputtext, privkey);
console.log(inputtext);
console.log(privkey);
console.log(data)
// var plain = sm2.decrypt(privkey, inputtext);
console.log()
// var utf8Str = Hex.hexToUtf8Str(plain);
$("#crypttext").val(data);
});
</script>
</body>
</html>
! function(t, r) {
"object" == typeof exports && "object" == typeof module ? module.exports = r() : "function" == typeof define &&
define.amd ? define([], r) : "object" == typeof exports ? exports.sm2 = r() : t.sm2 = r()
}("undefined" != typeof self ? self : this, function() {
return function(t) {
function r(e) {
if (i[e]) return i[e].exports;
var n = i[e] = {
i: e,
l: !1,
exports: {}
};
return t[e].call(n.exports, n, n.exports, r), n.l = !0, n.exports
}
var i = {};
return r.m = t, r.c = i, r.d = function(t, i, e) {
r.o(t, i) || Object.defineProperty(t, i, {
configurable: !1,
enumerable: !0,
get: e
})
}, r.n = function(t) {
var i = t && t.__esModule ? function() {
return t.default
} : function() {
return t
};
return r.d(i, "a", i), i
}, r.o = function(t, r) {
return Object.prototype.hasOwnProperty.call(t, r)
}, r.p = "", r(r.s = 2)
}([function(t, r, i) {
(function() {
function i(t, r, i) {
null != t && ("number" == typeof t ? this.fromNumber(t, r, i) : null == r &&
"string" != typeof t ? this.fromString(t, 256) : this.fromString(t, r))
}
function e() {
return new i(null)
}
function n(t, r, i, e, n, o) {
for (; --o >= 0;) {
var s = r * this[t++] + i[e] + n;
n = Math.floor(s / 67108864), i[e++] = 67108863 & s
}
return n
}
function o(t, r, i, e, n, o) {
for (var s = 32767 & r, u = r >> 15; --o >= 0;) {
var h = 32767 & this[t],
a = this[t++] >> 15,
f = u * h + a * s;
h = s * h + ((32767 & f) << 15) + i[e] + (1073741823 & n), n = (h >>> 30) + (
f >>> 15) + u * a + (n >>> 30), i[e++] = 1073741823 & h
}
return n
}
function s(t, r, i, e, n, o) {
for (var s = 16383 & r, u = r >> 14; --o >= 0;) {
var h = 16383 & this[t],
a = this[t++] >> 14,
f = u * h + a * s;
h = s * h + ((16383 & f) << 14) + i[e] + n, n = (h >> 28) + (f >> 14) + u * a,
i[e++] = 268435455 & h
}
return n
}
function u(t) {
return pr.charAt(t)
}
function h(t, r) {
var i = vr[t.charCodeAt(r)];
return null == i ? -1 : i
}
function a(t) {
for (var r = this.t - 1; r >= 0; --r) t[r] = this[r];
t.t = this.t, t.s = this.s
}
function f(t) {
this.t = 1, this.s = t < 0 ? -1 : 0, t > 0 ? this[0] = t : t < -1 ? this[0] = t +
this.DV : this.t = 0
}
function l(t) {
var r = e();
return r.fromInt(t), r
}
function c(t, r) {
var e;
if (16 == r) e = 4;
else if (8 == r) e = 3;
else if (256 == r) e = 8;
else if (2 == r) e = 1;
else if (32 == r) e = 5;
else {
if (4 != r) return void this.fromRadix(t, r);
e = 2
}
this.t = 0, this.s = 0;
for (var n = t.length, o = !1, s = 0; --n >= 0;) {
var u = 8 == e ? 255 & t[n] : h(t, n);
u < 0 ? "-" == t.charAt(n) && (o = !0) : (o = !1, 0 == s ? this[this.t++] = u :
s + e > this.DB ? (this[this.t - 1] |= (u & (1 << this.DB - s) - 1) <<
s, this[this.t++] = u >> this.DB - s) : this[this.t - 1] |= u << s,
(s += e) >= this.DB && (s -= this.DB))
}
8 == e && 0 != (128 & t[0]) && (this.s = -1, s > 0 && (this[this.t - 1] |= (1 <<
this.DB - s) - 1 << s)), this.clamp(), o && i.ZERO.subTo(this, this)
}
function p() {
for (var t = this.s & this.DM; this.t > 0 && this[this.t - 1] == t;) --this.t
}
function v(t) {
if (this.s < 0) return "-" + this.negate().toString(t);
var r;
if (16 == t) r = 4;
else if (8 == t) r = 3;
else if (2 == t) r = 1;
else if (32 == t) r = 5;
else {
if (4 != t) return this.toRadix(t);
r = 2
}
var i, e = (1 << r) - 1,
n = !1,
o = "",
s = this.t,
h = this.DB - s * this.DB % r;
if (s-- > 0)
for (h < this.DB && (i = this[s] >> h) > 0 && (n = !0, o = u(i)); s >= 0;) h <
r ? (i = (this[s] & (1 << h) - 1) << r - h, i |= this[--s] >> (h += this
.DB - r)) : (i = this[s] >> (h -= r) & e, h <= 0 && (h += this.DB, --
s)), i > 0 && (n = !0), n && (o += u(i));
return n ? o : "0"
}
function y() {
var t = e();
return i.ZERO.subTo(this, t), t
}
function m() {
return this.s < 0 ? this.negate() : this
}
function d(t) {
var r = this.s - t.s;
if (0 != r) return r;
var i = this.t;
if (0 != (r = i - t.t)) return this.s < 0 ? -r : r;
for (; --i >= 0;)
if (0 != (r = this[i] - t[i])) return r;
return 0
}
function g(t) {
var r, i = 1;
return 0 != (r = t >>> 16) && (t = r, i += 16), 0 != (r = t >> 8) && (t = r, i +=
8), 0 != (r = t >> 4) && (t = r, i += 4), 0 != (r = t >> 2) && (t = r, i += 2),
0 != (r = t >> 1) && (t = r, i += 1), i
}
function T() {
return this.t <= 0 ? 0 : this.DB * (this.t - 1) + g(this[this.t - 1] ^ this.s & this
.DM)
}
function F(t, r) {
var i;
for (i = this.t - 1; i >= 0; --i) r[i + t] = this[i];
for (i = t - 1; i >= 0; --i) r[i] = 0;
r.t = this.t + t, r.s = this.s
}
function b(t, r) {
for (var i = t; i < this.t; ++i) r[i - t] = this[i];
r.t = Math.max(this.t - t, 0), r.s = this.s
}
function w(t, r) {
var i, e = t % this.DB,
n = this.DB - e,
o = (1 << n) - 1,
s = Math.floor(t / this.DB),
u = this.s << e & this.DM;
for (i = this.t - 1; i >= 0; --i) r[i + s + 1] = this[i] >> n | u, u = (this[i] &
o) << e;
for (i = s - 1; i >= 0; --i) r[i] = 0;
r[s] = u, r.t = this.t + s + 1, r.s = this.s, r.clamp()
}
function B(t, r) {
r.s = this.s;
var i = Math.floor(t / this.DB);
if (i >= this.t) return void(r.t = 0);
var e = t % this.DB,
n = this.DB - e,
o = (1 << e) - 1;
r[0] = this[i] >> e;
for (var s = i + 1; s < this.t; ++s) r[s - i - 1] |= (this[s] & o) << n, r[s - i] =
this[s] >> e;
e > 0 && (r[this.t - i - 1] |= (this.s & o) << n), r.t = this.t - i, r.clamp()
}
function x(t, r) {
for (var i = 0, e = 0, n = Math.min(t.t, this.t); i < n;) e += this[i] - t[i], r[
i++] = e & this.DM, e >>= this.DB;
if (t.t < this.t) {
for (e -= t.s; i < this.t;) e += this[i], r[i++] = e & this.DM, e >>= this.DB;
e += this.s
} else {
for (e += this.s; i < t.t;) e -= t[i], r[i++] = e & this.DM, e >>= this.DB;
e -= t.s
}
r.s = e < 0 ? -1 : 0, e < -1 ? r[i++] = this.DV + e : e > 0 && (r[i++] = e), r.t =
i, r.clamp()
}
function D(t, r) {
var e = this.abs(),
n = t.abs(),
o = e.t;
for (r.t = o + n.t; --o >= 0;) r[o] = 0;
for (o = 0; o < n.t; ++o) r[o + e.t] = e.am(0, n[o], r, o, 0, e.t);
r.s = 0, r.clamp(), this.s != t.s && i.ZERO.subTo(r, r)
}
function I(t) {
for (var r = this.abs(), i = t.t = 2 * r.t; --i >= 0;) t[i] = 0;
for (i = 0; i < r.t - 1; ++i) {
var e = r.am(i, r[i], t, 2 * i, 0, 1);
(t[i + r.t] += r.am(i + 1, 2 * r[i], t, 2 * i + 1, e, r.t - i - 1)) >= r.DV && (
t[i + r.t] -= r.DV, t[i + r.t + 1] = 1)
}
t.t > 0 && (t[t.t - 1] += r.am(i, r[i], t, 2 * i, 0, 1)), t.s = 0, t.clamp()
}
function q(t, r, n) {
var o = t.abs();
if (!(o.t <= 0)) {
var s = this.abs();
if (s.t < o.t) return null != r && r.fromInt(0), void(null != n && this.copyTo(
n));
null == n && (n = e());
var u = e(),
h = this.s,
a = t.s,
f = this.DB - g(o[o.t - 1]);
f > 0 ? (o.lShiftTo(f, u), s.lShiftTo(f, n)) : (o.copyTo(u), s.copyTo(n));
var l = u.t,
c = u[l - 1];
if (0 != c) {
var p = c * (1 << this.F1) + (l > 1 ? u[l - 2] >> this.F2 : 0),
v = this.FV / p,
y = (1 << this.F1) / p,
m = 1 << this.F2,
d = n.t,
T = d - l,
F = null == r ? e() : r;
for (u.dlShiftTo(T, F), n.compareTo(F) >= 0 && (n[n.t++] = 1, n.subTo(F,
n)), i.ONE.dlShiftTo(l, F), F.subTo(u, u); u.t < l;) u[u.t++] = 0;
for (; --T >= 0;) {
var b = n[--d] == c ? this.DM : Math.floor(n[d] * v + (n[d - 1] + m) *
y);
if ((n[d] += u.am(0, b, n, T, 0, l)) < b)
for (u.dlShiftTo(T, F), n.subTo(F, n); n[d] < --b;) n.subTo(F, n)
}
null != r && (n.drShiftTo(l, r), h != a && i.ZERO.subTo(r, r)), n.t = l, n
.clamp(), f > 0 && n.rShiftTo(f, n), h < 0 && i.ZERO.subTo(n, n)
}
}
}
function S(t) {
var r = e();
return this.abs().divRemTo(t, null, r), this.s < 0 && r.compareTo(i.ZERO) > 0 && t
.subTo(r, r), r
}
function E(t) {
this.m = t
}
function A(t) {
return t.s < 0 || t.compareTo(this.m) >= 0 ? t.mod(this.m) : t
}
function P(t) {
return t
}
function O(t) {
t.divRemTo(this.m, null, t)
}
function R(t, r, i) {
t.multiplyTo(r, i), this.reduce(i)
}
function M(t, r) {
t.squareTo(r), this.reduce(r)
}
function C() {
if (this.t < 1) return 0;
var t = this[0];
if (0 == (1 & t)) return 0;
var r = 3 & t;
return r = r * (2 - (15 & t) * r) & 15, r = r * (2 - (255 & t) * r) & 255, r = r * (
2 - ((65535 & t) * r & 65535)) & 65535, r = r * (2 - t * r % this.DV) % this
.DV, r > 0 ? this.DV - r : -r
}
function H(t) {
this.m = t, this.mp = t.invDigit(), this.mpl = 32767 & this.mp, this.mph = this
.mp >> 15, this.um = (1 << t.DB - 15) - 1, this.mt2 = 2 * t.t
}
function k(t) {
var r = e();
return t.abs().dlShiftTo(this.m.t, r), r.divRemTo(this.m, null, r), t.s < 0 && r
.compareTo(i.ZERO) > 0 && this.m.subTo(r, r), r
}
function V(t) {
var r = e();
return t.copyTo(r), this.reduce(r), r
}
function N(t) {
for (; t.t <= this.mt2;) t[t.t++] = 0;
for (var r = 0; r < this.m.t; ++r) {
var i = 32767 & t[r],
e = i * this.mpl + ((i * this.mph + (t[r] >> 15) * this.mpl & this.um) <<
15) & t.DM;
for (i = r + this.m.t, t[i] += this.m.am(0, e, t, r, 0, this.m.t); t[i] >= t
.DV;) t[i] -= t.DV, t[++i]++
}
t.clamp(), t.drShiftTo(this.m.t, t), t.compareTo(this.m) >= 0 && t.subTo(this.m, t)
}
function j(t, r) {
t.squareTo(r), this.reduce(r)
}
function L(t, r, i) {
t.multiplyTo(r, i), this.reduce(i)
}
function z() {
return 0 == (this.t > 0 ? 1 & this[0] : this.s)
}
function K(t, r) {
if (t > 4294967295 || t < 1) return i.ONE;
var n = e(),
o = e(),
s = r.convert(this),
u = g(t) - 1;
for (s.copyTo(n); --u >= 0;)
if (r.sqrTo(n, o), (t & 1 << u) > 0) r.mulTo(o, s, n);
else {
var h = n;
n = o, o = h
} return r.revert(n)
}
function Z(t, r) {
var i;
return i = t < 256 || r.isEven() ? new E(r) : new H(r), this.exp(t, i)
}
function U() {
var t = e();
return this.copyTo(t), t
}
function _() {
if (this.s < 0) {
if (1 == this.t) return this[0] - this.DV;
if (0 == this.t) return -1
} else {
if (1 == this.t) return this[0];
if (0 == this.t) return 0
}
return (this[1] & (1 << 32 - this.DB) - 1) << this.DB | this[0]
}
function X() {
return 0 == this.t ? this.s : this[0] << 24 >> 24
}
function Y() {
return 0 == this.t ? this.s : this[0] << 16 >> 16
}
function G(t) {
return Math.floor(Math.LN2 * this.DB / Math.log(t))
}
function J() {
return this.s < 0 ? -1 : this.t <= 0 || 1 == this.t && this[0] <= 0 ? 0 : 1
}
function Q(t) {
if (null == t && (t = 10), 0 == this.signum() || t < 2 || t > 36) return "0";
var r = this.chunkSize(t),
i = Math.pow(t, r),
n = l(i),
o = e(),
s = e(),
u = "";
for (this.divRemTo(n, o, s); o.signum() > 0;) u = (i + s.intValue()).toString(t)
.substr(1) + u, o.divRemTo(n, o, s);
return s.intValue().toString(t) + u
}
function W(t, r) {
this.fromInt(0), null == r && (r = 10);
for (var e = this.chunkSize(r), n = Math.pow(r, e), o = !1, s = 0, u = 0, a = 0; a <
t.length; ++a) {
var f = h(t, a);
f < 0 ? "-" == t.charAt(a) && 0 == this.signum() && (o = !0) : (u = r * u + f,
++s >= e && (this.dMultiply(n), this.dAddOffset(u, 0), s = 0, u = 0))
}
s > 0 && (this.dMultiply(Math.pow(r, s)), this.dAddOffset(u, 0)), o && i.ZERO.subTo(
this, this)
}
function $(t, r, e) {
if ("number" == typeof r)
if (t < 2) this.fromInt(1);
else
for (this.fromNumber(t, e), this.testBit(t - 1) || this.bitwiseTo(i.ONE
.shiftLeft(t - 1), ut, this), this.isEven() && this.dAddOffset(1,
0); !this.isProbablePrime(r);) this.dAddOffset(2, 0), this.bitLength() >
t && this.subTo(i.ONE.shiftLeft(t - 1), this);
else {
var n = new Array,
o = 7 & t;
n.length = 1 + (t >> 3), r.nextBytes(n), o > 0 ? n[0] &= (1 << o) - 1 : n[0] =
0, this.fromString(n, 256)
}
}
function tt() {
var t = this.t,
r = new Array;
r[0] = this.s;
var i, e = this.DB - t * this.DB % 8,
n = 0;
if (t-- > 0)
for (e < this.DB && (i = this[t] >> e) != (this.s & this.DM) >> e && (r[n++] =
i | this.s << this.DB - e); t >= 0;) e < 8 ? (i = (this[t] & (1 << e) -
1) << 8 - e, i |= this[--t] >> (e += this.DB - 8)) : (i = this[t] >> (
e -= 8) & 255, e <= 0 && (e += this.DB, --t)), 0 != (128 & i) && (i |= -
256), 0 == n && (128 & this.s) != (128 & i) && ++n, (n > 0 || i != this
.s) && (r[n++] = i);
return r
}
function rt(t) {
return 0 == this.compareTo(t)
}
function it(t) {
return this.compareTo(t) < 0 ? this : t
}
function et(t) {
return this.compareTo(t) > 0 ? this : t
}
function nt(t, r, i) {
var e, n, o = Math.min(t.t, this.t);
for (e = 0; e < o; ++e) i[e] = r(this[e], t[e]);
if (t.t < this.t) {
for (n = t.s & this.DM, e = o; e < this.t; ++e) i[e] = r(this[e], n);
i.t = this.t
} else {
for (n = this.s & this.DM, e = o; e < t.t; ++e) i[e] = r(n, t[e]);
i.t = t.t
}
i.s = r(this.s, t.s), i.clamp()
}
function ot(t, r) {
return t & r
}
function st(t) {
var r = e();
return this.bitwiseTo(t, ot, r), r
}
function ut(t, r) {
return t | r
}
function ht(t) {
var r = e();
return this.bitwiseTo(t, ut, r), r
}
function at(t, r) {
return t ^ r
}
function ft(t) {
var r = e();
return this.bitwiseTo(t, at, r), r
}
function lt(t, r) {
return t & ~r
}
function ct(t) {
var r = e();
return this.bitwiseTo(t, lt, r), r
}
function pt() {
for (var t = e(), r = 0; r < this.t; ++r) t[r] = this.DM & ~this[r];
return t.t = this.t, t.s = ~this.s, t
}
function vt(t) {
var r = e();
return t < 0 ? this.rShiftTo(-t, r) : this.lShiftTo(t, r), r
}
function yt(t) {
var r = e();
return t < 0 ? this.lShiftTo(-t, r) : this.rShiftTo(t, r), r
}
function mt(t) {
if (0 == t) return -1;
var r = 0;
return 0 == (65535 & t) && (t >>= 16, r += 16), 0 == (255 & t) && (t >>= 8, r += 8),
0 == (15 & t) && (t >>= 4, r += 4), 0 == (3 & t) && (t >>= 2, r += 2), 0 == (1 &
t) && ++r, r
}
function dt() {
for (var t = 0; t < this.t; ++t)
if (0 != this[t]) return t * this.DB + mt(this[t]);
return this.s < 0 ? this.t * this.DB : -1
}
function gt(t) {
for (var r = 0; 0 != t;) t &= t - 1, ++r;
return r
}
function Tt() {
for (var t = 0, r = this.s & this.DM, i = 0; i < this.t; ++i) t += gt(this[i] ^ r);
return t
}
function Ft(t) {
var r = Math.floor(t / this.DB);
return r >= this.t ? 0 != this.s : 0 != (this[r] & 1 << t % this.DB)
}
function bt(t, r) {
var e = i.ONE.shiftLeft(t);
return this.bitwiseTo(e, r, e), e
}
function wt(t) {
return this.changeBit(t, ut)
}
function Bt(t) {
return this.changeBit(t, lt)
}
function xt(t) {
return this.changeBit(t, at)
}
function Dt(t, r) {
for (var i = 0, e = 0, n = Math.min(t.t, this.t); i < n;) e += this[i] + t[i], r[
i++] = e & this.DM, e >>= this.DB;
if (t.t < this.t) {
for (e += t.s; i < this.t;) e += this[i], r[i++] = e & this.DM, e >>= this.DB;
e += this.s
} else {
for (e += this.s; i < t.t;) e += t[i], r[i++] = e & this.DM, e >>= this.DB;
e += t.s
}
r.s = e < 0 ? -1 : 0, e > 0 ? r[i++] = e : e < -1 && (r[i++] = this.DV + e), r.t =
i, r.clamp()
}
function It(t) {
var r = e();
return this.addTo(t, r), r
}
function qt(t) {
var r = e();
return this.subTo(t, r), r
}
function St(t) {
var r = e();
return this.multiplyTo(t, r), r
}
function Et() {
var t = e();
return this.squareTo(t), t
}
function At(t) {
var r = e();
return this.divRemTo(t, r, null), r
}
function Pt(t) {
var r = e();
return this.divRemTo(t, null, r), r
}
function Ot(t) {
var r = e(),
i = e();
return this.divRemTo(t, r, i), new Array(r, i)
}
function Rt(t) {
this[this.t] = this.am(0, t - 1, this, 0, 0, this.t), ++this.t, this.clamp()
}
function Mt(t, r) {
if (0 != t) {
for (; this.t <= r;) this[this.t++] = 0;
for (this[r] += t; this[r] >= this.DV;) this[r] -= this.DV, ++r >= this.t && (
this[this.t++] = 0), ++this[r]
}
}
function Ct() {}
function Ht(t) {
return t
}
function kt(t, r, i) {
t.multiplyTo(r, i)
}
function Vt(t, r) {
t.squareTo(r)
}
function Nt(t) {
return this.exp(t, new Ct)
}
function jt(t, r, i) {
var e = Math.min(this.t + t.t, r);
for (i.s = 0, i.t = e; e > 0;) i[--e] = 0;
var n;
for (n = i.t - this.t; e < n; ++e) i[e + this.t] = this.am(0, t[e], i, e, 0, this
.t);
for (n = Math.min(t.t, r); e < n; ++e) this.am(0, t[e], i, e, 0, r - e);
i.clamp()
}
function Lt(t, r, i) {
--r;
var e = i.t = this.t + t.t - r;
for (i.s = 0; --e >= 0;) i[e] = 0;
for (e = Math.max(r - this.t, 0); e < t.t; ++e) i[this.t + e - r] = this.am(r - e,
t[e], i, 0, 0, this.t + e - r);
i.clamp(), i.drShiftTo(1, i)
}
function zt(t) {
this.r2 = e(), this.q3 = e(), i.ONE.dlShiftTo(2 * t.t, this.r2), this.mu = this.r2
.divide(t), this.m = t
}
function Kt(t) {
if (t.s < 0 || t.t > 2 * this.m.t) return t.mod(this.m);
if (t.compareTo(this.m) < 0) return t;
var r = e();
return t.copyTo(r), this.reduce(r), r
}
function Zt(t) {
return t
}
function Ut(t) {
for (t.drShiftTo(this.m.t - 1, this.r2), t.t > this.m.t + 1 && (t.t = this.m.t + 1,
t.clamp()), this.mu.multiplyUpperTo(this.r2, this.m.t + 1, this.q3), this.m
.multiplyLowerTo(this.q3, this.m.t + 1, this.r2); t.compareTo(this.r2) < 0;) t
.dAddOffset(1, this.m.t + 1);
for (t.subTo(this.r2, t); t.compareTo(this.m) >= 0;) t.subTo(this.m, t)
}
function _t(t, r) {
t.squareTo(r), this.reduce(r)
}
function Xt(t, r, i) {
t.multiplyTo(r, i), this.reduce(i)
}
function Yt(t, r) {
var i, n, o = t.bitLength(),
s = l(1);
if (o <= 0) return s;
i = o < 18 ? 1 : o < 48 ? 3 : o < 144 ? 4 : o < 768 ? 5 : 6, n = o < 8 ? new E(r) :
r.isEven() ? new zt(r) : new H(r);
var u = new Array,
h = 3,
a = i - 1,
f = (1 << i) - 1;
if (u[1] = n.convert(this), i > 1) {
var c = e();
for (n.sqrTo(u[1], c); h <= f;) u[h] = e(), n.mulTo(c, u[h - 2], u[h]), h += 2
}
var p, v, y = t.t - 1,
m = !0,
d = e();
for (o = g(t[y]) - 1; y >= 0;) {
for (o >= a ? p = t[y] >> o - a & f : (p = (t[y] & (1 << o + 1) - 1) << a - o,
y > 0 && (p |= t[y - 1] >> this.DB + o - a)), h = i; 0 == (1 & p);)
p >>= 1, --h;
if ((o -= h) < 0 && (o += this.DB, --y), m) u[p].copyTo(s), m = !1;
else {
for (; h > 1;) n.sqrTo(s, d), n.sqrTo(d, s), h -= 2;
h > 0 ? n.sqrTo(s, d) : (v = s, s = d, d = v), n.mulTo(d, u[p], s)
}
for (; y >= 0 && 0 == (t[y] & 1 << o);) n.sqrTo(s, d), v = s, s = d, d = v, --
o < 0 && (o = this.DB - 1, --y)
}
return n.revert(s)
}
function Gt(t) {
var r = this.s < 0 ? this.negate() : this.clone(),
i = t.s < 0 ? t.negate() : t.clone();
if (r.compareTo(i) < 0) {
var e = r;
r = i, i = e
}
var n = r.getLowestSetBit(),
o = i.getLowestSetBit();
if (o < 0) return r;
for (n < o && (o = n), o > 0 && (r.rShiftTo(o, r), i.rShiftTo(o, i)); r.signum() >
0;)(n = r.getLowestSetBit()) > 0 && r.rShiftTo(n, r), (n = i
.getLowestSetBit()) > 0 && i.rShiftTo(n, i), r.compareTo(i) >= 0 ? (r.subTo(i, r), r
.rShiftTo(1, r)) : (i.subTo(r, i), i.rShiftTo(1, i));
return o > 0 && i.lShiftTo(o, i), i
}
function Jt(t) {
if (t <= 0) return 0;
var r = this.DV % t,
i = this.s < 0 ? t - 1 : 0;
if (this.t > 0)
if (0 == r) i = this[0] % t;
else
for (var e = this.t - 1; e >= 0; --e) i = (r * i + this[e]) % t;
return i
}
function Qt(t) {
var r = t.isEven();
if (this.isEven() && r || 0 == t.signum()) return i.ZERO;
for (var e = t.clone(), n = this.clone(), o = l(1), s = l(0), u = l(0), h = l(
1); 0 != e.signum();) {
for (; e.isEven();) e.rShiftTo(1, e), r ? (o.isEven() && s.isEven() || (o.addTo(
this, o), s.subTo(t, s)), o.rShiftTo(1, o)) : s.isEven() || s.subTo(t,
s), s.rShiftTo(1, s);
for (; n.isEven();) n.rShiftTo(1, n), r ? (u.isEven() && h.isEven() || (u.addTo(
this, u), h.subTo(t, h)), u.rShiftTo(1, u)) : h.isEven() || h.subTo(t,
h), h.rShiftTo(1, h);
e.compareTo(n) >= 0 ? (e.subTo(n, e), r && o.subTo(u, o), s.subTo(h, s)) : (n
.subTo(e, n), r && u.subTo(o, u), h.subTo(s, h))
}
return 0 != n.compareTo(i.ONE) ? i.ZERO : h.compareTo(t) >= 0 ? h.subtract(t) : h
.signum() < 0 ? (h.addTo(t, h), h.signum() < 0 ? h.add(t) : h) : h
}
function Wt(t) {
var r, i = this.abs();
if (1 == i.t && i[0] <= yr[yr.length - 1]) {
for (r = 0; r < yr.length; ++r)
if (i[0] == yr[r]) return !0;
return !1
}
if (i.isEven()) return !1;
for (r = 1; r < yr.length;) {
for (var e = yr[r], n = r + 1; n < yr.length && e < mr;) e *= yr[n++];
for (e = i.modInt(e); r < n;)
if (e % yr[r++] == 0) return !1
}
return i.millerRabin(t)
}
function $t(t) {
var r = this.subtract(i.ONE),
n = r.getLowestSetBit();
if (n <= 0) return !1;
var o = r.shiftRight(n);
(t = t + 1 >> 1) > yr.length && (t = yr.length);
for (var s = e(), u = 0; u < t; ++u) {
s.fromInt(yr[Math.floor(Math.random() * yr.length)]);
var h = s.modPow(o, this);
if (0 != h.compareTo(i.ONE) && 0 != h.compareTo(r)) {
for (var a = 1; a++ < n && 0 != h.compareTo(r);)
if (h = h.modPowInt(2, this), 0 == h.compareTo(i.ONE)) return !1;
if (0 != h.compareTo(r)) return !1
}
}
return !0
}
function tr(t) {
gr[Tr++] ^= 255 & t, gr[Tr++] ^= t >> 8 & 255, gr[Tr++] ^= t >> 16 & 255, gr[
Tr++] ^= t >> 24 & 255, Tr >= Br && (Tr -= Br)
}
function rr() {
tr((new Date).getTime())
}
function ir() {
if (null == dr) {
for (rr(), dr = hr(), dr.init(gr), Tr = 0; Tr < gr.length; ++Tr) gr[Tr] = 0;
Tr = 0
}
return dr.next()
}
function er(t) {
var r;
for (r = 0; r < t.length; ++r) t[r] = ir()
}
function nr() {}
function or() {
this.i = 0, this.j = 0, this.S = new Array
}
function sr(t) {
var r, i, e;
for (r = 0; r < 256; ++r) this.S[r] = r;
for (i = 0, r = 0; r < 256; ++r) i = i + this.S[r] + t[r % t.length] & 255, e = this
.S[r], this.S[r] = this.S[i], this.S[i] = e;
this.i = 0, this.j = 0
}
function ur() {
var t;
return this.i = this.i + 1 & 255, this.j = this.j + this.S[this.i] & 255, t = this
.S[this.i], this.S[this.i] = this.S[this.j], this.S[this.j] = t, this.S[t + this
.S[this.i] & 255]
}
function hr() {
return new or
}
var ar, fr = "undefined" != typeof navigator;
fr && "Microsoft Internet Explorer" == navigator.appName ? (i.prototype.am = o, ar =
30) : fr && "Netscape" != navigator.appName ? (i.prototype.am = n, ar = 26) : (i
.prototype.am = s, ar = 28), i.prototype.DB = ar, i.prototype.DM = (1 << ar) -
1, i.prototype.DV = 1 << ar;
i.prototype.FV = Math.pow(2, 52), i.prototype.F1 = 52 - ar, i.prototype.F2 = 2 * ar -
52;
var lr, cr, pr = "0123456789abcdefghijklmnopqrstuvwxyz",
vr = new Array;
for (lr = "0".charCodeAt(0), cr = 0; cr <= 9; ++cr) vr[lr++] = cr;
for (lr = "a".charCodeAt(0), cr = 10; cr < 36; ++cr) vr[lr++] = cr;
for (lr = "A".charCodeAt(0), cr = 10; cr < 36; ++cr) vr[lr++] = cr;
E.prototype.convert = A, E.prototype.revert = P, E.prototype.reduce = O, E.prototype
.mulTo = R, E.prototype.sqrTo = M, H.prototype.convert = k, H.prototype.revert = V,
H.prototype.reduce = N, H.prototype.mulTo = L, H.prototype.sqrTo = j, i.prototype
.copyTo = a, i.prototype.fromInt = f, i.prototype.fromString = c, i.prototype
.clamp = p, i.prototype.dlShiftTo = F, i.prototype.drShiftTo = b, i.prototype
.lShiftTo = w, i.prototype.rShiftTo = B, i.prototype.subTo = x, i.prototype
.multiplyTo = D, i.prototype.squareTo = I, i.prototype.divRemTo = q, i.prototype
.invDigit = C, i.prototype.isEven = z, i.prototype.exp = K, i.prototype.toString =
v, i.prototype.negate = y, i.prototype.abs = m, i.prototype.compareTo = d, i
.prototype.bitLength = T, i.prototype.mod = S, i.prototype.modPowInt = Z, i.ZERO =
l(0), i.ONE = l(1), Ct.prototype.convert = Ht, Ct.prototype.revert = Ht, Ct
.prototype.mulTo = kt, Ct.prototype.sqrTo = Vt, zt.prototype.convert = Kt, zt
.prototype.revert = Zt, zt.prototype.reduce = Ut, zt.prototype.mulTo = Xt, zt
.prototype.sqrTo = _t;
var yr = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71,
73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157,
163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241,
251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347,
349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439,
443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547,
557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643,
647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751,
757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859,
863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977,
983, 991, 997
],
mr = (1 << 26) / yr[yr.length - 1];
i.prototype.chunkSize = G, i.prototype.toRadix = Q, i.prototype.fromRadix = W, i
.prototype.fromNumber = $, i.prototype.bitwiseTo = nt, i.prototype.changeBit = bt, i
.prototype.addTo = Dt, i.prototype.dMultiply = Rt, i.prototype.dAddOffset = Mt, i
.prototype.multiplyLowerTo = jt, i.prototype.multiplyUpperTo = Lt, i.prototype
.modInt = Jt, i.prototype.millerRabin = $t, i.prototype.clone = U, i.prototype
.intValue = _, i.prototype.byteValue = X, i.prototype.shortValue = Y, i.prototype
.signum = J, i.prototype.toByteArray = tt, i.prototype.equals = rt, i.prototype
.min = it, i.prototype.max = et, i.prototype.and = st, i.prototype.or = ht, i
.prototype.xor = ft, i.prototype.andNot = ct, i.prototype.not = pt, i.prototype
.shiftLeft = vt, i.prototype.shiftRight = yt, i.prototype.getLowestSetBit = dt, i
.prototype.bitCount = Tt, i.prototype.testBit = Ft, i.prototype.setBit = wt, i
.prototype.clearBit = Bt, i.prototype.flipBit = xt, i.prototype.add = It, i
.prototype.subtract = qt, i.prototype.multiply = St, i.prototype.divide = At, i
.prototype.remainder = Pt, i.prototype.divideAndRemainder = Ot, i.prototype.modPow =
Yt, i.prototype.modInverse = Qt, i.prototype.pow = Nt, i.prototype.gcd = Gt, i
.prototype.isProbablePrime = Wt, i.prototype.square = Et, i.prototype.Barrett = zt;
var dr, gr, Tr;
if (null == gr) {
gr = new Array, Tr = 0;
var Fr;
if ("undefined" != typeof window && window.crypto)
if (window.crypto.getRandomValues) {
var br = new Uint8Array(32);
for (window.crypto.getRandomValues(br), Fr = 0; Fr < 32; ++Fr) gr[Tr++] =
br[Fr]
} else if ("Netscape" == navigator.appName && navigator.appVersion < "5") {
var wr = window.crypto.random(32);
for (Fr = 0; Fr < wr.length; ++Fr) gr[Tr++] = 255 & wr.charCodeAt(Fr)
}
for (; Tr < Br;) Fr = Math.floor(65536 * Math.random()), gr[Tr++] = Fr >>> 8, gr[
Tr++] = 255 & Fr;
Tr = 0, rr()
}
nr.prototype.nextBytes = er, or.prototype.init = sr, or.prototype.next = ur;
var Br = 256;
r = t.exports = {
default: i,
BigInteger: i,
SecureRandom: nr
}
}).call(this)
}, function(t, r, i) {
"use strict";
function e(t) {
if (Array.isArray(t)) {
for (var r = 0, i = Array(t.length); r < t.length; r++) i[r] = t[r];
return i
}
return Array.from(t)
}
function n(t, r) {
var i = 31 & r;
return t << i | t >>> 32 - i
}
function o(t, r) {
for (var i = [], e = t.length - 1; e >= 0; e--) i[e] = 255 & (t[e] ^ r[e]);
return i
}
function s(t) {
return t ^ n(t, 9) ^ n(t, 17)
}
function u(t) {
return t ^ n(t, 15) ^ n(t, 23)
}
function h(t) {
var r = 8 * t.length,
i = r % 512;
i = i >= 448 ? 512 - i % 448 - 1 : 448 - i - 1;
for (var o = new Array((i - 7) / 8), h = new Array(8), a = 0, c = o.length; a < c; a++) o[
a] = 0;
for (var p = 0, v = h.length; p < v; p++) h[p] = 0;
r = r.toString(2);
for (var y = 7; y >= 0; y--)
if (r.length > 8) {
var m = r.length - 8;
h[y] = parseInt(r.substr(m), 2), r = r.substr(0, m)
} else r.length > 0 && (h[y] = parseInt(r, 2), r = "");
for (var d = new Uint8Array([].concat(e(t), [128], o, h)), g = new DataView(d.buffer, 0),
T = d.length / 64, F = new Uint32Array([1937774191, 1226093241, 388252375,
3666478592, 2842636476, 372324522, 3817729613, 2969243214
]), b = 0; b < T; b++) {
f.fill(0), l.fill(0);
for (var w = 16 * b, B = 0; B < 16; B++) f[B] = g.getUint32(4 * (w + B), !1);
for (var x = 16; x < 68; x++) f[x] = u(f[x - 16] ^ f[x - 9] ^ n(f[x - 3], 15)) ^ n(f[x -
13], 7) ^ f[x - 6];
for (var D = 0; D < 64; D++) l[D] = f[D] ^ f[D + 4];
for (var I = F[0], q = F[1], S = F[2], E = F[3], A = F[4], P = F[5], O = F[6], R = F[7],
M = void 0, C = void 0, H = void 0, k = void 0, V = void 0, N = 0; N < 64; N++)
V = N >= 0 && N <= 15 ? 2043430169 : 2055708042, M = n(n(I, 12) + A + n(V, N), 7),
C = M ^ n(I, 12), H = (N >= 0 && N <= 15 ? I ^ q ^ S : I & q | I & S | q & S) + E +
C + l[N], k = (N >= 0 && N <= 15 ? A ^ P ^ O : A & P | ~A & O) + R + M + f[N], E =
S, S = n(q, 9), q = I, I = H, R = O, O = n(P, 19), P = A, A = s(k);
F[0] ^= I, F[1] ^= q, F[2] ^= S, F[3] ^= E, F[4] ^= A, F[5] ^= P, F[6] ^= O, F[7] ^= R
}
for (var j = [], L = 0, z = F.length; L < z; L++) {
var K = F[L];
j.push((4278190080 & K) >>> 24, (16711680 & K) >>> 16, (65280 & K) >>> 8, 255 & K)
}
return j
}
function a(t, r) {
for (r.length > c && (r = h(r)); r.length < c;) r.push(0);
var i = o(r, p),
n = o(r, v),
s = h([].concat(e(i), e(t)));
return h([].concat(e(n), e(s)))
}
for (var f = new Uint32Array(68), l = new Uint32Array(64), c = 64, p = new Uint8Array(c), v =
new Uint8Array(c), y = 0; y < c; y++) p[y] = 54, v[y] = 92;
t.exports = {
sm3: h,
hmac: a
}
}, function(t, r, i) {
"use strict";
function e(t) {
if (Array.isArray(t)) {
for (var r = 0, i = Array(t.length); r < t.length; r++) i[r] = t[r];
return i
}
return Array.from(t)
}
function n(t, r) {
var i = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : 1;
t = "string" == typeof t ? m.hexToArray(m.utf8ToHex(t)) : Array.prototype.slice.call(t), r =
m.getGlobalCurve().decodePointHex(r);
var n = m.generateKeyPairHex(),
o = new c(n.privateKey, 16),
s = n.publicKey;
s.length > 128 && (s = s.substr(s.length - 128));
var u = r.multiply(o),
h = m.hexToArray(m.leftPad(u.getX().toBigInteger().toRadix(16), 64)),
a = m.hexToArray(m.leftPad(u.getY().toBigInteger().toRadix(16), 64)),
f = m.arrayToHex(d([].concat(h, t, a))),
l = 1,
p = 0,
v = [],
y = [].concat(h, a),
g = function() {
v = d([].concat(e(y), [l >> 24 & 255, l >> 16 & 255, l >> 8 & 255, 255 & l])), l++,
p = 0
};
g();
for (var T = 0, F = t.length; T < F; T++) p === v.length && g(), t[T] ^= 255 & v[p++];
var b = m.arrayToHex(t);
return i === w ? s + b + f : s + f + b
}
function o(t, r) {
var i = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : 1,
n = arguments.length > 3 && void 0 !== arguments[3] ? arguments[3] : {},
o = n.output,
s = void 0 === o ? "string" : o;
r = new c(r, 16);
var u = t.substr(128, 64),
h = t.substr(192);
i === w && (u = t.substr(t.length - 64), h = t.substr(128, t.length - 128 - 64));
var a = m.hexToArray(h),
f = m.getGlobalCurve().decodePointHex("04" + t.substr(0, 128)),
l = f.multiply(r),
p = m.hexToArray(m.leftPad(l.getX().toBigInteger().toRadix(16), 64)),
v = m.hexToArray(m.leftPad(l.getY().toBigInteger().toRadix(16), 64)),
y = 1,
g = 0,
T = [],
F = [].concat(p, v),
b = function() {
T = d([].concat(e(F), [y >> 24 & 255, y >> 16 & 255, y >> 8 & 255, 255 & y])), y++,
g = 0
};
b();
for (var B = 0, x = a.length; B < x; B++) g === T.length && b(), a[B] ^= 255 & T[g++];
return m.arrayToHex(d([].concat(p, a, v))) === u.toLowerCase() ? "array" === s ? a : m
.arrayToUtf8(a) : "array" === s ? [] : ""
}
function s(t, r) {
var i = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : {},
e = i.pointPool,
n = i.der,
o = i.hash,
s = i.publicKey,
u = i.userId,
l = "string" == typeof t ? m.utf8ToHex(t) : m.arrayToHex(t);
o && (s = s || a(r), l = h(l, s, u));
var p = new c(r, 16),
y = new c(l, 16),
d = null,
g = null,
T = null;
do {
do {
var F = void 0;
F = e && e.length ? e.pop() : f(), d = F.k, g = y.add(F.x1).mod(b)
} while (g.equals(c.ZERO) || g.add(d).equals(b));
T = p.add(c.ONE).modInverse(b).multiply(d.subtract(g.multiply(p))).mod(b)
} while (T.equals(c.ZERO));
return n ? v(g, T) : m.leftPad(g.toString(16), 64) + m.leftPad(T.toString(16), 64)
}
function u(t, r, i) {
var e = arguments.length > 3 && void 0 !== arguments[3] ? arguments[3] : {},
n = e.der,
o = e.hash,
s = e.userId,
u = "string" == typeof t ? m.utf8ToHex(t) : m.arrayToHex(t);
o && (u = h(u, i, s));
var a = void 0,
f = void 0;
if (n) {
var l = y(r);
a = l.r, f = l.s
} else a = new c(r.substring(0, 64), 16), f = new c(r.substring(64), 16);
var p = F.decodePointHex(i),
v = new c(u, 16),
d = a.add(f).mod(b);
if (d.equals(c.ZERO)) return !1;
var g = T.multiply(f).add(p.multiply(d)),
w = v.add(g.getX().toBigInteger()).mod(b);
return a.equals(w)
}
function h(t, r) {
var i = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : "1234567812345678";
i = m.utf8ToHex(i);
var e = m.leftPad(T.curve.a.toBigInteger().toRadix(16), 64),
n = m.leftPad(T.curve.b.toBigInteger().toRadix(16), 64),
o = m.leftPad(T.getX().toBigInteger().toRadix(16), 64),
s = m.leftPad(T.getY().toBigInteger().toRadix(16), 64),
u = void 0,
h = void 0;
if (128 === r.length) u = r.substr(0, 64), h = r.substr(64, 64);
else {
var a = T.curve.decodePointHex(r);
u = m.leftPad(a.getX().toBigInteger().toRadix(16), 64), h = m.leftPad(a.getY()
.toBigInteger().toRadix(16), 64)
}
var f = m.hexToArray(i + e + n + o + s + u + h),
l = 4 * i.length;
f.unshift(255 & l), f.unshift(l >> 8 & 255);
var c = d(f);
return m.arrayToHex(d(c.concat(m.hexToArray(t))))
}
function a(t) {
var r = T.multiply(new c(t, 16));
return "04" + m.leftPad(r.getX().toBigInteger().toString(16), 64) + m.leftPad(r.getY()
.toBigInteger().toString(16), 64)
}
function f() {
var t = m.generateKeyPairHex(),
r = F.decodePointHex(t.publicKey);
return t.k = new c(t.privateKey, 16), t.x1 = r.getX().toBigInteger(), t
}
var l = i(0),
c = l.BigInteger,
p = i(3),
v = p.encodeDer,
y = p.decodeDer,
m = i(4),
d = i(1).sm3,
g = m.generateEcparam(),
T = g.G,
F = g.curve,
b = g.n,
w = 0;
t.exports = {
generateKeyPairHex: m.generateKeyPairHex,
compressPublicKeyHex: m.compressPublicKeyHex,
comparePublicKeyHex: m.comparePublicKeyHex,
doEncrypt: n,
doDecrypt: o,
doSignature: s,
doVerifySignature: u,
getPublicKeyFromPrivateKey: a,
getPoint: f,
verifyPublicKey: m.verifyPublicKey
}
}, function(t, r, i) {
"use strict";
function e(t, r) {
if (!t) throw new ReferenceError(
"this hasn't been initialised - super() hasn't been called");
return !r || "object" != typeof r && "function" != typeof r ? t : r
}
function n(t, r) {
if ("function" != typeof r && null !== r) throw new TypeError(
"Super expression must either be null or a function, not " + typeof r);
t.prototype = Object.create(r && r.prototype, {
constructor: {
value: t,
enumerable: !1,
writable: !0,
configurable: !0
}
}), r && (Object.setPrototypeOf ? Object.setPrototypeOf(t, r) : t.__proto__ = r)
}
function o(t, r) {
if (!(t instanceof r)) throw new TypeError("Cannot call a class as a function")
}
function s(t) {
var r = t.toString(16);
if ("-" !== r[0]) r.length % 2 == 1 ? r = "0" + r : r.match(/^[0-7]/) || (r = "00" + r);
else {
r = r.substr(1);
var i = r.length;
i % 2 == 1 ? i += 1 : r.match(/^[0-7]/) || (i += 2);
for (var e = "", n = 0; n < i; n++) e += "f";
e = new c(e, 16), r = e.xor(t).add(c.ONE), r = r.toString(16).replace(/^-/, "")
}
return r
}
function u(t, r) {
return +t[r + 2] < 8 ? 1 : 128 & +t.substr(r + 2, 2)
}
function h(t, r) {
var i = u(t, r),
e = t.substr(r + 2, 2 * i);
return e ? (+e[0] < 8 ? new c(e, 16) : new c(e.substr(2), 16)).intValue() : -1
}
function a(t, r) {
return r + 2 * (u(t, r) + 1)
}
var f = function() {
function t(t, r) {
for (var i = 0; i < r.length; i++) {
var e = r[i];
e.enumerable = e.enumerable || !1, e.configurable = !0, "value" in e && (e
.writable = !0), Object.defineProperty(t, e.key, e)
}
}
return function(r, i, e) {
return i && t(r.prototype, i), e && t(r, e), r
}
}(),
l = i(0),
c = l.BigInteger,
p = function() {
function t() {
o(this, t), this.tlv = null, this.t = "00", this.l = "00", this.v = ""
}
return f(t, [{
key: "getEncodedHex",
value: function() {
return this.tlv || (this.v = this.getValue(), this.l = this
.getLength(), this.tlv = this.t + this.l + this.v), this
.tlv
}
}, {
key: "getLength",
value: function() {
var t = this.v.length / 2,
r = t.toString(16);
return r.length % 2 == 1 && (r = "0" + r), t < 128 ? r : (128 +
r.length / 2).toString(16) + r
}
}, {
key: "getValue",
value: function() {
return ""
}
}]), t
}(),
v = function(t) {
function r(t) {
o(this, r);
var i = e(this, (r.__proto__ || Object.getPrototypeOf(r)).call(this));
return i.t = "02", t && (i.v = s(t)), i
}
return n(r, t), f(r, [{
key: "getValue",
value: function() {
return this.v
}
}]), r
}(p),
y = function(t) {
function r(t) {
o(this, r);
var i = e(this, (r.__proto__ || Object.getPrototypeOf(r)).call(this));
return i.t = "30", i.asn1Array = t, i
}
return n(r, t), f(r, [{
key: "getValue",
value: function() {
return this.v = this.asn1Array.map(function(t) {
return t.getEncodedHex()
}).join(""), this.v
}
}]), r
}(p);
t.exports = {
encodeDer: function(t, r) {
var i = new v(t),
e = new v(r);
return new y([i, e]).getEncodedHex()
},
decodeDer: function(t) {
var r = a(t, 0),
i = a(t, r),
e = h(t, r),
n = t.substr(i, 2 * e),
o = i + n.length,
s = a(t, o),
u = h(t, o),
f = t.substr(s, 2 * u);
return {
r: new c(n, 16),
s: new c(f, 16)
}
}
}
}, function(t, r, i) {
"use strict";
function e() {
return b
}
function n() {
var t = new y("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFF", 16),
r = new y("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFC", 16),
i = new y("28E9FA9E9D9F5E344D5A9E4BCF6509A7F39789F515AB8F92DDBCBD414D940E93", 16),
e = new g(t, r, i);
return {
curve: e,
G: e.decodePointHex(
"0432C4AE2C1F1981195F9904466A39C9948FE30BBFF2660BE1715A4589334C74C7BC3736A2F4F6779C59BDCEE36B692153D0A9877CC62A474002DF32E52139F0A0"
),
n: new y("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFF7203DF6B21C6052B53BBF40939D54123", 16)
}
}
function o(t, r, i) {
var e = t ? new y(t, r, i) : new y(B.bitLength(), T),
n = e.mod(B.subtract(y.ONE)).add(y.ONE),
o = h(n.toString(16), 64),
s = w.multiply(n);
return {
privateKey: o,
publicKey: "04" + h(s.getX().toBigInteger().toString(16), 64) + h(s.getY()
.toBigInteger().toString(16), 64)
}
}
function s(t) {
if (130 !== t.length) throw new Error("Invalid public key to compress");
var r = (t.length - 2) / 2,
i = t.substr(2, r),
e = new y(t.substr(r + 2, r), 16),
n = "03";
return e.mod(new y("2")).equals(y.ZERO) && (n = "02"), n + i
}
function u(t) {
t = unescape(encodeURIComponent(t));
for (var r = t.length, i = [], e = 0; e < r; e++) i[e >>> 2] |= (255 & t.charCodeAt(e)) <<
24 - e % 4 * 8;
for (var n = [], o = 0; o < r; o++) {
var s = i[o >>> 2] >>> 24 - o % 4 * 8 & 255;
n.push((s >>> 4).toString(16)), n.push((15 & s).toString(16))
}
return n.join("")
}
function h(t, r) {
return t.length >= r ? t : new Array(r - t.length + 1).join("0") + t
}
function a(t) {
return t.map(function(t) {
return t = t.toString(16), 1 === t.length ? "0" + t : t
}).join("")
}
function f(t) {
for (var r = [], i = 0, e = 0; e < 2 * t.length; e += 2) r[e >>> 3] |= parseInt(t[i], 10) <<
24 - e % 8 * 4, i++;
try {
for (var n = [], o = 0; o < t.length; o++) {
var s = r[o >>> 2] >>> 24 - o % 4 * 8 & 255;
n.push(String.fromCharCode(s))
}
return decodeURIComponent(escape(n.join("")))
} catch (t) {
throw new Error("Malformed UTF-8 data")
}
}
function l(t) {
var r = [],
i = t.length;
i % 2 != 0 && (t = h(t, i + 1)), i = t.length;
for (var e = 0; e < i; e += 2) r.push(parseInt(t.substr(e, 2), 16));
return r
}
function c(t) {
var r = b.decodePointHex(t);
if (!r) return !1;
var i = r.getX();
return r.getY().square().equals(i.multiply(i.square()).add(i.multiply(b.a)).add(b.b))
}
function p(t, r) {
var i = b.decodePointHex(t);
if (!i) return !1;
var e = b.decodePointHex(r);
return !!e && i.equals(e)
}
var v = i(0),
y = v.BigInteger,
m = v.SecureRandom,
d = i(5),
g = d.ECCurveFp,
T = new m,
F = n(),
b = F.curve,
w = F.G,
B = F.n;
t.exports = {
getGlobalCurve: e,
generateEcparam: n,
generateKeyPairHex: o,
compressPublicKeyHex: s,
utf8ToHex: u,
leftPad: h,
arrayToHex: a,
arrayToUtf8: f,
hexToArray: l,
verifyPublicKey: c,
comparePublicKeyHex: p
}
}, function(t, r, i) {
"use strict";
function e(t, r) {
if (!(t instanceof r)) throw new TypeError("Cannot call a class as a function")
}
var n = function() {
function t(t, r) {
for (var i = 0; i < r.length; i++) {
var e = r[i];
e.enumerable = e.enumerable || !1, e.configurable = !0, "value" in e && (e
.writable = !0), Object.defineProperty(t, e.key, e)
}
}
return function(r, i, e) {
return i && t(r.prototype, i), e && t(r, e), r
}
}(),
o = i(0),
s = o.BigInteger,
u = new s("2"),
h = new s("3"),
a = function() {
function t(r, i) {
e(this, t), this.x = i, this.q = r
}
return n(t, [{
key: "equals",
value: function(t) {
return t === this || this.q.equals(t.q) && this.x.equals(t.x)
}
}, {
key: "toBigInteger",
value: function() {
return this.x
}
}, {
key: "negate",
value: function() {
return new t(this.q, this.x.negate().mod(this.q))
}
}, {
key: "add",
value: function(r) {
return new t(this.q, this.x.add(r.toBigInteger()).mod(this.q))
}
}, {
key: "subtract",
value: function(r) {
return new t(this.q, this.x.subtract(r.toBigInteger()).mod(this
.q))
}
}, {
key: "multiply",
value: function(r) {
return new t(this.q, this.x.multiply(r.toBigInteger()).mod(this
.q))
}
}, {
key: "divide",
value: function(r) {
return new t(this.q, this.x.multiply(r.toBigInteger()
.modInverse(this.q)).mod(this.q))
}
}, {
key: "square",
value: function() {
return new t(this.q, this.x.square().mod(this.q))
}
}]), t
}(),
f = function() {
function t(r, i, n, o) {
e(this, t), this.curve = r, this.x = i, this.y = n, this.z = null == o ? s.ONE : o,
this.zinv = null
}
return n(t, [{
key: "getX",
value: function() {
return null === this.zinv && (this.zinv = this.z.modInverse(this
.curve.q)), this.curve.fromBigInteger(this.x
.toBigInteger().multiply(this.zinv).mod(this.curve.q))
}
}, {
key: "getY",
value: function() {
return null === this.zinv && (this.zinv = this.z.modInverse(this
.curve.q)), this.curve.fromBigInteger(this.y
.toBigInteger().multiply(this.zinv).mod(this.curve.q))
}
}, {
key: "equals",
value: function(t) {
return t === this || (this.isInfinity() ? t.isInfinity() : t
.isInfinity() ? this.isInfinity() : !!t.y.toBigInteger()
.multiply(this.z).subtract(this.y.toBigInteger()
.multiply(t.z)).mod(this.curve.q).equals(s.ZERO) &&
t.x.toBigInteger().multiply(this.z).subtract(this.x
.toBigInteger().multiply(t.z)).mod(this.curve.q)
.equals(s.ZERO))
}
}, {
key: "isInfinity",
value: function() {
return null === this.x && null === this.y || this.z.equals(s
.ZERO) && !this.y.toBigInteger().equals(s.ZERO)
}
}, {
key: "negate",
value: function() {
return new t(this.curve, this.x, this.y.negate(), this.z)
}
}, {
key: "add",
value: function(r) {
if (this.isInfinity()) return r;
if (r.isInfinity()) return this;
var i = this.x.toBigInteger(),
e = this.y.toBigInteger(),
n = this.z,
o = r.x.toBigInteger(),
u = r.y.toBigInteger(),
h = r.z,
a = this.curve.q,
f = i.multiply(h).mod(a),
l = o.multiply(n).mod(a),
c = f.subtract(l),
p = e.multiply(h).mod(a),
v = u.multiply(n).mod(a),
y = p.subtract(v);
if (s.ZERO.equals(c)) return s.ZERO.equals(y) ? this.twice() :
this.curve.infinity;
var m = f.add(l),
d = n.multiply(h).mod(a),
g = c.square().mod(a),
T = c.multiply(g).mod(a),
F = d.multiply(y.square()).subtract(m.multiply(g)).mod(a),
b = c.multiply(F).mod(a),
w = y.multiply(g.multiply(f).subtract(F)).subtract(p
.multiply(T)).mod(a),
B = T.multiply(d).mod(a);
return new t(this.curve, this.curve.fromBigInteger(b), this
.curve.fromBigInteger(w), B)
}
}, {
key: "twice",
value: function() {
if (this.isInfinity()) return this;
if (!this.y.toBigInteger().signum()) return this.curve.infinity;
var r = this.x.toBigInteger(),
i = this.y.toBigInteger(),
e = this.z,
n = this.curve.q,
o = this.curve.a.toBigInteger(),
s = r.square().multiply(h).add(o.multiply(e.square())).mod(
n),
u = i.shiftLeft(1).multiply(e).mod(n),
a = i.square().mod(n),
f = a.multiply(r).multiply(e).mod(n),
l = u.square().mod(n),
c = s.square().subtract(f.shiftLeft(3)).mod(n),
p = u.multiply(c).mod(n),
v = s.multiply(f.shiftLeft(2).subtract(c)).subtract(l
.shiftLeft(1).multiply(a)).mod(n),
y = u.multiply(l).mod(n);
return new t(this.curve, this.curve.fromBigInteger(p), this
.curve.fromBigInteger(v), y)
}
}, {
key: "multiply",
value: function(t) {
if (this.isInfinity()) return this;
if (!t.signum()) return this.curve.infinity;
for (var r = t.multiply(h), i = this.negate(), e = this, n = r
.bitLength() - 2; n > 0; n--) {
e = e.twice();
var o = r.testBit(n);
o !== t.testBit(n) && (e = e.add(o ? this : i))
}
return e
}
}]), t
}(),
l = function() {
function t(r, i, n) {
e(this, t), this.q = r, this.a = this.fromBigInteger(i), this.b = this
.fromBigInteger(n), this.infinity = new f(this, null, null)
}
return n(t, [{
key: "equals",
value: function(t) {
return t === this || this.q.equals(t.q) && this.a.equals(t.a) &&
this.b.equals(t.b)
}
}, {
key: "fromBigInteger",
value: function(t) {
return new a(this.q, t)
}
}, {
key: "decodePointHex",
value: function(t) {
switch (parseInt(t.substr(0, 2), 16)) {
case 0:
return this.infinity;
case 2:
case 3:
var r = this.fromBigInteger(new s(t.substr(2), 16)),
i = this.fromBigInteger(r.multiply(r.square()).add(r
.multiply(this.a)).add(this.b)
.toBigInteger().modPow(this.q.divide(new s("4"))
.add(s.ONE), this.q));
return i.toBigInteger().mod(u).equals(new s(t.substr(0,
2), 16).subtract(u)) || (i = i.negate()), new f(
this, r, i);
case 4:
case 6:
case 7:
var e = (t.length - 2) / 2,
n = t.substr(2, e),
o = t.substr(e + 2, e);
return new f(this, this.fromBigInteger(new s(n, 16)),
this.fromBigInteger(new s(o, 16)));
default:
return null
}
}
}]), t
}();
t.exports = {
ECPointFp: f,
ECCurveFp: l
}
}])
});
\ No newline at end of file
...@@ -204,3 +204,20 @@ gemhoUtil.navigatePage = function(path) { ...@@ -204,3 +204,20 @@ gemhoUtil.navigatePage = function(path) {
} }
location.href = url; location.href = url;
} }
/**
* 爱山东下载方法
* @param {Object} url 下载文件全路径
* https://h5.tfryb.com/hos-server/pub/jmas/jmasbucket//jmopen_files/webapp/jssdk/be0c4a53adf04f9db4e39a303af78689.docx
*/
gemhoUtil.downloadFile(url) {
lightAppJssdk.download.downloadFiles({
filePath: 'https://h5.tfryb.com/hos-server/pub/jmas/jmasbucket//jmopen_files/webapp/jssdk/be0c4a53adf04f9db4e39a303af78689.docx',
success: function (data) {
alert(JSON.stringify(data))
},
fail: function (err) {
alert(JSON.stringify(err))
}
})
}
\ No newline at end of file
...@@ -120,6 +120,7 @@ window.addEventListener("load", function() { ...@@ -120,6 +120,7 @@ window.addEventListener("load", function() {
} }
this.editAble = this.form.hdStatus === 0 || this.form.hdStatus === 2 || this.form.hdStatus === 3 this.editAble = this.form.hdStatus === 0 || this.form.hdStatus === 2 || this.form.hdStatus === 3
this.editAble = true
}) })
}, },
submit() { submit() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment