From 50ae416192f630659e06a4e4919c90c709b7d84f Mon Sep 17 00:00:00 2001 From: TRHX Date: Fri, 12 Nov 2021 09:28:44 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20=E5=8C=BB=E7=96=97=E4=BF=9D?= =?UTF-8?q?=E9=9A=9C=E5=B1=80=E5=85=AC=E5=85=B1=E6=9F=A5=E8=AF=A2=E3=80=90?= =?UTF-8?q?2021.11.12=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- JSReverse/fuwu_nhsa_gov_cn/README.md | 339 +++ JSReverse/fuwu_nhsa_gov_cn/nhsa.js | 4100 ++++++++++++++++++++++++++ JSReverse/fuwu_nhsa_gov_cn/nhsa.py | 97 + 3 files changed, 4536 insertions(+) create mode 100644 JSReverse/fuwu_nhsa_gov_cn/README.md create mode 100644 JSReverse/fuwu_nhsa_gov_cn/nhsa.js create mode 100644 JSReverse/fuwu_nhsa_gov_cn/nhsa.py diff --git a/JSReverse/fuwu_nhsa_gov_cn/README.md b/JSReverse/fuwu_nhsa_gov_cn/README.md new file mode 100644 index 0000000..7a17dff --- /dev/null +++ b/JSReverse/fuwu_nhsa_gov_cn/README.md @@ -0,0 +1,339 @@ +![](https://i.loli.net/2021/08/07/JbP4zaS2TxU6Rkd.png) + +> 关注微信公众号:K哥爬虫,QQ交流群:808574309,持续分享爬虫进阶、JS/安卓逆向等技术干货! + +## 声明 + +**本文章中所有内容仅供学习交流,抓包内容、敏感网址、数据接口均已做脱敏处理,严禁用于商业用途和非法用途,否则由此产生的一切后果均与作者无关,若有侵权,请联系我立即删除!** + +## 逆向目标 + +- 目标:医疗保障局公共查询 + +- 主页:`aHR0cHM6Ly9mdXd1Lm5oc2EuZ292LmNuL25hdGlvbmFsSGFsbFN0LyMvc2VhcmNoL21lZGljYWw=` + +- 接口:`aHR0cHM6Ly9mdXd1Lm5oc2EuZ292LmNuL2VidXMvZnV3dS9hcGkvbnRobC9hcGkvZml4ZWQvcXVlcnlGaXhlZEhvc3BpdGFs` + +- 逆向参数:Request Payload 的 `encData` 和 `signData`、Request Headers 的 `x-tif-nonce` 和 `x-tif-signature` + +## 逆向过程 + +### 抓包分析 + +来到公共查询页面,点击翻页,就可以看到一个 POST 请求,Request Payload 的参数部分是加密的,主要是 appCode、encData 和 signData 参数,同样返回的数据也有这些参数,其加密解密方法是一样的,其中 encType 和 signType 分别为 SM4 和 SM2,所以大概率这是国密算法了,有关国密算法 K 哥前期文章有介绍:[《爬虫逆向基础,认识 SM1-SM9、ZUC 国密算法》](),此外请求头还有 x-tif-nonce 和 x-tif-signature 参数,如下图所示: + +![01.png](https://i.loli.net/2021/11/04/4rpKeB1AEsSibgw.png) + +### 参数逆向 + +直接全局搜索 encData 或 signData,搜索结果仅在 app.1634197175801.js 有,非常明显,上面还有设置 header 的地方,所有参数都在这里,埋下断点,可以看到这里就是加密的地方,如下图所示: + +![02.png](https://i.loli.net/2021/11/04/PRntJ7g1KsfuU63.png) + +这里的加密函数,主要都传入了一个 e 参数,我们可以先看一下这个 e,里面的参数含义如下: + +- **addr**:医疗机构详细地址,默认空; +- **medinsLvCode**:医疗机构等级代码,默认空; +- **medinsName**:医疗机构名称,默认空; +- **medinsTypeCode**:医疗机构类型代码,默认空; +- **pageNum**:页数,默认 1; +- **pageSize**:每页数据条数,默认 10; +- **regnCode**:医疗机构所在地代码,默认 110000(北京市); +- **sprtEcFlag**:暂时不知其含义,默认空。 + +等级代码、类型代码、所在地代码,都是通过请求加密接口得到的,他们的加密和解密方法都一样,在最后的完整代码里有分享,这里不再赘述。其他参数比如 appCode,是在 JS 里写死的。 + + +![03.png](https://i.loli.net/2021/11/04/JLKHMmuWNhUFAb6.png) + +我们再观察一下整个 JS 文件,在头部可以看到 .call 语句,并且有 exports 关键字,很明显是一个 webpack 形式的写法。 + +![04.png](https://i.loli.net/2021/11/04/VYJyD1Gav7ZuNhx.png) + +我们回到加密的地方,从上往下看,整个函数引用了很多其他模块,如果想整个扣下来,花费时间肯定是无比巨大的,如果想直接拿下整个 JS,再将参数导出,这种暴力做法可是可以,但是整个 JS 有七万多行,运行效率肯定是有所影响的,所以观察函数,将不用的函数去掉,有用的留下来,是比较好的做法,观察 function d,第一行 `var t = n("6c27").sha256`,点进去来到 createOutputMethod 方法,这里整个是一个 SHA256 算法,从这个方法往下整个 copy 下来即可,如下图所示: + +![05.png](https://i.loli.net/2021/11/04/MqJ7ZiwYD9hUHo1.png) + +![06.png](https://i.loli.net/2021/11/04/Ez4qdsfJK8rgoHh.png) + +这里要注意的是,观察这个函数后面导出的 sha256 实际上是调用了 createMethod 这个方法,那么我们 copy 下来的方法直接调用 createMethod 即可,即 `var t = createMethod()`,不需要这些 exports 了。 + +![07.png](https://i.loli.net/2021/11/04/KTdSXvieLfoJhGA.png) + +另外还有一些变量需要定义,整个 copy 下来的结构如下: + +![08.png](https://i.loli.net/2021/11/04/rmZRNdTlWLDfGMi.png) + +接着前面的继续往下看,还有一句 `o = Object(i.a)()`,同样点进去直接 copy 下来即可,这里没有什么需要注意的地方。 + +![09.png](https://i.loli.net/2021/11/04/1lk4KT8hdJQq3Gj.png) + +再往下看就来到了 `e.data.signData = p(e)`,点进 function p,将整个函数 copy 下来,这时候你本地调试会发现没有任何错误,实际上他这里使用了 try-catch 语句,捕获到了异常之后就没有任何处理,可以自己加一句 `console.log(e)` 来输出异常,实际上他这里会在 o.doSignature、e.from 两个位置提示未定义,同样的我们可以点进去将函数扣出来,但是后面会遇到函数不断引用其他函数,为了方便,我们可以将其写到 webpack 里,下面的 e.from 也是一样。 + +![10.png](https://i.loli.net/2021/11/04/nXdkpRTuL1BSAih.png) + +![11.png](https://i.loli.net/2021/11/04/rfqANDhYdoPc3Fb.png) + +将模块写成 webpack 形式,在自执行方法里调用,然后定义全局变量来接收,再将原来的 o, e 换成全局变量即可,这里还需要注意的一个地方,那就是 o.doSignature 传入的 h,是一个定值,需要定义一下,不然后面解密是失败的。如下图所示: + +![12.png](https://i.loli.net/2021/11/04/vY7i5pc1LQEMhHW.png) + +![13.png](https://i.loli.net/2021/11/04/D8F21LPJsZHuzWy.png) + +这里扣 webpack 模块的时候也需要注意,不要把所有原方法里有的模块都扣出来,有些根本没用到,可以直接注释掉,这个过程是需要有耐心的,你如果全部扣,那将会是无穷无尽的,还不如直接使用整个 JS 文件,所有有用的模块如下(可能会多,但不会少): + +![14.png](https://i.loli.net/2021/11/04/dbvg4Ol7sSpAo1Z.png) + +接着原来的说,`encData: v("SM4", e)` 这里用到了 function v,v 里面又用到了 A、g 等函数,全部扣下来即可,同时还需要注意,前面所说的 e 在 A 函数里也用到了,同样需要换成我们自己定义的全局变量,如下图所示: + +![15.png](https://i.loli.net/2021/11/04/NjutOorZJGXhVEs.png) + +![16.png](https://i.loli.net/2021/11/04/o9OtdjZamWK5hUk.png) + +到此加密用到的函数都扣完了,此时我们可以写一个方法,对加密的过程进行封装,使用时只需要传入类似以下参数即可: + +```json +{ + "addr": "", + "regnCode": "110000", + "medinsName": "", + "sprtEcFlag": "", + "medinsLvCode": "", + "medinsTypeCode": "", + "pageNum": 1, + "pageSize": 10 +} +``` + +如下图所示 getEncryptedData 就是加密方法: + +![17.png](https://i.loli.net/2021/11/04/rlHeWIzwmLubMVD.png) + +那么解密方法呢?很明显返回的数据是 encData,直接搜索 encData 就只有三个结果,很容易找到就行 function y,同样的,这里要注意把 `e.from` 改成我们自定义的 `e_.Buffer.from`,另外我们也可以将 header 参数的生成方法也封装成一个函数,便于调用。 + +![18.png](https://i.loli.net/2021/11/04/YEo9w1VDqHMOCZ5.png) + +![19.png](https://i.loli.net/2021/11/04/tXzIvC8LlYASNqf.png) + +## 完整代码 + +GitHub 关注 K 哥爬虫,持续分享爬虫相关代码!欢迎 star !https://github.com/kgepachong/ + +**以下只演示部分关键代码,不能直接运行!**完整代码仓库地址:https://github.com/kgepachong/crawler/ + +### JavaScript 加密关键代码架构 + +```javascript +var sm2, sm4, e_; +!function (e) { + var n = {}, + i = {app: 0}, + r = {app: 0}; + + function o(t) {} + + o.e = function (e) {} + o.m = e + o.c = n + o.d = function (e, t, n) {} + o.r = function (e) {} + o.n = function (e) {} + o.o = function (e, t) {} + + sm2 = o('4d09') + e_ = o('b639') + sm4 = o('e04e') + +}({ + "4d09": function (e, t, n) {}, + 'f33e': function (e, t, n) {}, + "4d2d": function (e, t, n) {}, + 'b381': function (e, t, n) {}, + // 此处省略 N 个模块 +}) + +// 此处省略 N 个变量 + +var createOutputMethod = function (e, t) {}, + createMethod = function (e) {}, + nodeWrap = function (method, is224) {}, + createHmacOutputMethod = function (e, t) {}, + createHmacMethod = function (e) {}; + +function Sha256(e, t) {} + +function HmacSha256(e, t, n) {} + +// 此处省略 N 个方法 + +function i() {} + +function p(t) {} + +function m(e) {} + +var c = { + paasId: undefined, + appCode: "T98HPCGN5ZVVQBS8LZQNOAEXVI9GYHKQ", + version: "1.0.0", + appSecret: "NMVFVILMKT13GEMD3BKPKCTBOQBPZR2P", + publicKey: "BEKaw3Qtc31LG/hTPHFPlriKuAn/nzTWl8LiRxLw4iQiSUIyuglptFxNkdCiNXcXvkqTH79Rh/A2sEFU6hjeK3k=", + privateKey: "AJxKNdmspMaPGj+onJNoQ0cgWk2E3CYFWKBJhpcJrAtC", + publicKeyType: "base64", + privateKeyType: "base64" + }, + l = c.appCode, + u = c.appSecret, + f = c.publicKey, + h = c.privateKey, + t = createMethod(), + // t = n("6c27").sha256, + r = Math.ceil((new Date).getTime() / 1e3), + o = i(), + a = r + o + r; + +function getEncryptedData(data) { + var e = {"data": data} + return e.data = { + data: e.data || {} + }, + e.data.appCode = c.appCode, + e.data.version = c.version, + e.data.encType = "SM4", + e.data.signType = "SM2", + e.data.timestamp = r, + e.data.signData = p(e), + e.data.data = { + encData: v("SM4", e) + }, + // e.data = JSON.stringify({ + // data: e.data + // }), + e +} + +function getDecryptedData(t) { + if (!t) + return null; + var n = e_.Buffer.from(t.data.data.encData, "hex") + , i = function(t, n) { + var i = sm4.decrypt(n, t) + , r = i[i.length - 1]; + return i = i.slice(0, i.length - r), + e_.Buffer.from(i).toString("utf-8") + }(g(l, u), n); + return JSON.parse(i) +} + +function getHeaders(){ + var headers = {} + return headers["x-tif-paasid"] = c.paasId, + headers["x-tif-signature"] = t(a), + headers["x-tif-timestamp"] = r.toString(), + headers["x-tif-nonce"] = o, + headers["Accept"] = "application/json", + headers["contentType"] = "application/x-www-form-urlencoded", + headers +} +``` + +## Python 获取数据关键代码 + +```python +# ================================== +# --*-- coding: utf-8 --*-- +# @Time : 2021-11-03 +# @Author : 微信公众号:K哥爬虫 +# @FileName: nhsa.py +# @Software: PyCharm +# ================================== + + +import execjs +import requests + + +regn_code_url = "脱敏处理,完整代码关注 GitHub:https://github.com/kgepachong/crawler" +lv_and_type_url = "脱敏处理,完整代码关注 GitHub:https://github.com/kgepachong/crawler" +result_url = "脱敏处理,完整代码关注 GitHub:https://github.com/kgepachong/crawler" +UA = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.81 Safari/537.36" + +with open('nhsa.js', 'r', encoding='utf-8') as f: + nhsa_js = execjs.compile(f.read()) + + +def get_headers(): + """获取 header 参数,每次请求改变""" + headers = nhsa_js.call("getHeaders") + headers["User-Agent"] = UA + headers["Content-Type"] = "application/json" + headers["Host"] = "脱敏处理,完整代码关注 GitHub:https://github.com/kgepachong/crawler" + headers["Origin"] = "脱敏处理,完整代码关注 GitHub:https://github.com/kgepachong/crawler" + headers["Referer"] = "脱敏处理,完整代码关注 GitHub:https://github.com/kgepachong/crawler" + # print(headers) + return headers + + +def get_regn_code(): + """获取城市代码,返回结果无加密""" + payload = {"data": {"transferFlag": ""}} + response = requests.post(url=regn_code_url, json=payload, headers=get_headers()) + print(response.text) + + +def get_medins_lv_or_type_code(key): + """获取医疗机构等级 (LV) or 类型 (TYPE) 代码""" + if key == "LV": + payload = {"type": "MEDINSLV"} + elif key == "TYPE": + payload = {"type": "MEDINS_TYPE"} + else: + print("输入有误!") + return + encrypted_payload = nhsa_js.call("getEncryptedData", payload) + encrypted_data = requests.post(url=lv_and_type_url, json=encrypted_payload, headers=get_headers()).json() + decrypted_data = nhsa_js.call("getDecryptedData", encrypted_data) + print(decrypted_data) + + +def get_result(): + addr = input("请输入医疗机构详细地址(默认无): ") or "" + medins_lv_code = input("请输入医疗机构等级代码(默认无): ") or "" + medins_name = input("请输入医疗机构名称(默认无): ") or "" + medins_type_code = input("请输入医疗机构类型代码(默认无): ") or "" + regn_code = input("请输入医疗机构所在地代码(默认北京市): ") or "110000" + page_num = input("请输入要爬取的页数(默认1): ") or 1 + + for page in range(1, int(page_num)+1): + payload = { + "addr": addr, + "medinsLvCode": medins_lv_code, + "medinsName": medins_name, + "medinsTypeCode": medins_type_code, + "pageNum": page, + "pageSize": 10, + "regnCode": regn_code, + "sprtEcFlag": "" + } + page += 1 + encrypted_payload = nhsa_js.call("getEncryptedData", payload) + encrypted_data = requests.post(url=result_url, json=encrypted_payload, headers=get_headers()).json() + decrypted_data = nhsa_js.call("getDecryptedData", encrypted_data) + print(decrypted_data) + + +def main(): + # 获取城市代码 + # get_regn_code() + # 获取医疗机构等级代码 + # get_medins_lv_or_type_code("LV") + # 获取医疗机构类型代码 + # get_medins_lv_or_type_code("TYPE") + # 获取搜索结果 + get_result() + + +if __name__ == "__main__": + main() +``` + diff --git a/JSReverse/fuwu_nhsa_gov_cn/nhsa.js b/JSReverse/fuwu_nhsa_gov_cn/nhsa.js new file mode 100644 index 0000000..7316f6d --- /dev/null +++ b/JSReverse/fuwu_nhsa_gov_cn/nhsa.js @@ -0,0 +1,4100 @@ +var sm2, sm4, e_; +!function (e) { + var n = {}, + i = {app: 0}, + r = {app: 0}; + + function o(t) { + if (n[t]) + return n[t].exports; + var i = n[t] = { + i: t, + l: !1, + exports: {} + }; + return e[t].call(i.exports, i, i.exports, o), + i.l = !0, + i.exports + } + + o.e = function (e) { + var t = []; + i[e] ? t.push(i[e]) : 0 !== i[e] && { + DetailModule: 1, + ServiceCatalog: 1, + ServiceSearchModule: 1, + "announcement-list": 1, + "download-page": 1, + home: 1, + personLogin: 1, + search: 1 + }[e] && t.push(i[e] = new Promise((function (t, n) { + for (var r = "static/css/" + ({ + DetailModule: "DetailModule", + ServiceCatalog: "ServiceCatalog", + ServiceSearchModule: "ServiceSearchModule", + "announcement-list": "announcement-list", + "download-page": "download-page", + home: "home", + personLogin: "personLogin", + redirect: "redirect", + search: "search" + }[e] || e) + "." + { + DetailModule: "3b8618b7", + ServiceCatalog: "c8f08934", + ServiceSearchModule: "a25b688d", + "announcement-list": "14718cd2", + "download-page": "edab704b", + home: "c1ac692e", + personLogin: "3dc65580", + redirect: "31d6cfe0", + search: "0241a6fe" + }[e] + ".css", a = o.p + r, s = document.getElementsByTagName("link"), c = 0; c < s.length; c++) { + var l = s[c], + u = l.getAttribute("data-href") || l.getAttribute("href"); + if ("stylesheet" === l.rel && (u === r || u === a)) + return t() + } + var f = document.getElementsByTagName("style"); + for (c = 0; c < f.length; c++) + if ((u = (l = f[c]).getAttribute("data-href")) === r || u === a) + return t(); + var h = document.createElement("link"); + h.rel = "stylesheet", + h.type = "text/css", + h.onload = t, + h.onerror = function (t) { + var r = t && t.target && t.target.src || a, + o = new Error("Loading CSS chunk " + e + " failed.\n(" + r + ")"); + o.code = "CSS_CHUNK_LOAD_FAILED", + o.request = r, + delete i[e], + h.parentNode.removeChild(h), + n(o) + }, + h.href = a, + document.getElementsByTagName("head")[0].appendChild(h) + })).then((function () { + i[e] = 0 + }))); + var n = r[e]; + if (0 !== n) + if (n) + t.push(n[2]); + else { + var a = new Promise((function (t, i) { + n = r[e] = [t, i] + })); + t.push(n[2] = a); + var s, c = document.createElement("script"); + c.charset = "utf-8", + c.timeout = 120, + o.nc && c.setAttribute("nonce", o.nc), + c.src = function (e) { + return o.p + "static/js/" + ({ + DetailModule: "DetailModule", + ServiceCatalog: "ServiceCatalog", + ServiceSearchModule: "ServiceSearchModule", + "announcement-list": "announcement-list", + "download-page": "download-page", + home: "home", + personLogin: "personLogin", + redirect: "redirect", + search: "search" + }[e] || e) + "." + { + DetailModule: "a759a6ca", + ServiceCatalog: "afa74aa4", + ServiceSearchModule: "6d935931", + "announcement-list": "36f76155", + "download-page": "9c6df0e6", + home: "05e94348", + personLogin: "ae31f204", + redirect: "8846481b", + search: "175a263f" + }[e] + ".js" + }(e); + var l = new Error; + s = function (t) { + c.onerror = c.onload = null, + clearTimeout(u); + var n = r[e]; + if (0 !== n) { + if (n) { + var i = t && ("load" === t.type ? "missing" : t.type), + o = t && t.target && t.target.src; + l.message = "Loading chunk " + e + " failed.\n(" + i + ": " + o + ")", + l.name = "ChunkLoadError", + l.type = i, + l.request = o, + n[1](l) + } + r[e] = void 0 + } + }; + var u = setTimeout((function () { + s({ + type: "timeout", + target: c + }) + }), 12e4); + c.onerror = c.onload = s, + document.head.appendChild(c) + } + return Promise.all(t) + } + o.m = e + o.c = n + o.d = function (e, t, n) { + o.o(e, t) || Object.defineProperty(e, t, { + enumerable: !0, + get: n + }) + } + o.r = function (e) { + "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(e, Symbol.toStringTag, { + value: "Module" + }), + Object.defineProperty(e, "__esModule", { + value: !0 + }) + } + o.n = function (e) { + var t = e && e.__esModule ? function () { + return e.default + } : + function () { + return e + }; + return o.d(t, "a", t), + t + } + o.o = function (e, t) { + return Object.prototype.hasOwnProperty.call(e, t) + } + + sm2 = o('4d09') + e_ = o('b639') + sm4 = o('e04e') + +}({ + "4d09": function (e, t, n) { + "use strict"; + n.r(t), + n.d(t, "doEncrypt", (function () { + return p + })), + n.d(t, "doDecrypt", (function () { + return m + })), + n.d(t, "doSignature", (function () { + return v + })), + n.d(t, "doVerifySignature", (function () { + return b + })), + n.d(t, "doSm3Hash", (function () { + return g + })), + n.d(t, "getPublicKeyFromPrivateKey", (function () { + return y + })), + n.d(t, "getPoint", (function () { + return A + })); + // n("6b54"); + + var i = n("f33e").BigInteger + // r = n("53ea") + // , o = r.encodeDer + // , a = r.decodeDer + , + s = n("4d2d").SM3Digest + // , c = n("c747").SM2Cipher + , + l = n("b381"), + u = l.generateEcparam(), + f = u.G, + h = u.curve, + d = u.n; + + function p(e, t) { + var n = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : 1, + i = new c; + e = l.hexToArray(l.parseUtf8StringToHex(e)), + t.length > 128 && (t = t.substr(t.length - 128)); + var r = t.substr(0, 64), + o = t.substr(64); + t = i.createPoint(r, o); + var a = i.initEncipher(t); + i.encryptBlock(e); + var s = l.arrayToHex(e), + u = new Array(32); + return i.doFinal(u), + u = l.arrayToHex(u), + 0 === n ? a + s + u : a + u + s + } + + function m(e, t) { + var n = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : 1, + r = new c; + t = new i(t, 16); + var o = e.substr(0, 64), + a = e.substr(0 + o.length, 64), + s = o.length + a.length, + u = e.substr(s, 64), + f = e.substr(s + 64); + 0 === n && (u = e.substr(e.length - 64), + f = e.substr(s, e.length - s - 64)); + var h = l.hexToArray(f), + d = r.createPoint(o, a); + r.initDecipher(t, d), + r.decryptBlock(h); + var p = new Array(32); + r.doFinal(p); + var m = l.arrayToHex(p) === u; + if (m) { + var v = l.arrayToUtf8(h); + return v + } + return "" + } + + function v(e, t) { + var n = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : {}, + r = n.pointPool, + a = n.der, + s = n.hash, + c = n.publicKey, + u = "string" == typeof e ? l.parseUtf8StringToHex(e) : l.parseArrayBufferToHex(e); + s && (u = g(u, c = c || y(t))); + var f = new i(t, 16), + h = new i(u, 16), + p = null, + m = null, + v = null; + do { + do { + var b = void 0; + p = (b = r && r.length ? r.pop() : A()).k, + m = h.add(b.x1).mod(d) + } while (m.equals(i.ZERO) || m.add(p).equals(d)); + v = f.add(i.ONE).modInverse(d).multiply(p.subtract(m.multiply(f))).mod(d) + } while (v.equals(i.ZERO)); + return a ? o(m, v) : l.leftPad(m.toString(16), 64) + l.leftPad(v.toString(16), 64) + } + + function b(e, t, n) { + var r, o, s = arguments.length > 3 && void 0 !== arguments[3] ? arguments[3] : {}, + c = s.der, + u = s.hash, + p = "string" == typeof e ? l.parseUtf8StringToHex(e) : l.parseArrayBufferToHex(e); + if (u && (p = g(p, n)), + c) { + var m = a(t); + r = m.r, + o = m.s + } else + r = new i(t.substring(0, 64), 16), + o = new i(t.substring(64), 16); + var v = h.decodePointHex(n), + b = new i(p, 16), + y = r.add(o).mod(d); + if (y.equals(i.ZERO)) + return !1; + var A = f.multiply(o).add(v.multiply(y)), + w = b.add(A.getX().toBigInteger()).mod(d); + return r.equals(w) + } + + function g(e, t) { + var n = new s, + i = (new s).getZ(f, t.substr(2, 128)), + r = l.hexToArray(l.arrayToHex(i).toString()), + o = e, + a = l.hexToArray(o), + c = new Array(n.getDigestSize()); + return n.blockUpdate(r, 0, r.length), + n.blockUpdate(a, 0, a.length), + n.doFinal(c, 0), + l.arrayToHex(c).toString() + } + + function y(e) { + var t = f.multiply(new i(e, 16)); + return "04" + l.leftPad(t.getX().toBigInteger().toString(16), 64) + l.leftPad(t.getY().toBigInteger().toString(16), 64) + } + + function A() { + var e = l.generateKeyPairHex(), + t = h.decodePointHex(e.publicKey); + return e.k = new i(e.privateKey, 16), + e.x1 = t.getX().toBigInteger(), + e + } + + t.default = { + generateKeyPairHex: l.generateKeyPairHex, + doEncrypt: p, + doDecrypt: m, + doSignature: v, + doVerifySignature: b, + getPoint: A + } + }, + 'f33e': function (e, t, n) { + (function () { + var t; + + function n(e, t, n) { + null != e && ("number" == typeof e ? this.fromNumber(e, t, n) : null == t && "string" != typeof e ? this.fromString(e, 256) : this.fromString(e, t)) + } + + function i() { + return new n(null) + } + + var r = "undefined" != typeof navigator; + r && "Microsoft Internet Explorer" == navigator.appName ? (n.prototype.am = function (e, t, n, i, r, o) { + for (var a = 32767 & t, s = t >> 15; --o >= 0;) { + var c = 32767 & this[e], + l = this[e++] >> 15, + u = s * c + l * a; + r = ((c = a * c + ((32767 & u) << 15) + n[i] + (1073741823 & r)) >>> 30) + (u >>> 15) + s * l + (r >>> 30), + n[i++] = 1073741823 & c + } + return r + }, + t = 30) : r && "Netscape" != navigator.appName ? (n.prototype.am = function (e, t, n, i, r, o) { + for (; --o >= 0;) { + var a = t * this[e++] + n[i] + r; + r = Math.floor(a / 67108864), + n[i++] = 67108863 & a + } + return r + }, + t = 26) : (n.prototype.am = function (e, t, n, i, r, o) { + for (var a = 16383 & t, s = t >> 14; --o >= 0;) { + var c = 16383 & this[e], + l = this[e++] >> 14, + u = s * c + l * a; + r = ((c = a * c + ((16383 & u) << 14) + n[i] + r) >> 28) + (u >> 14) + s * l, + n[i++] = 268435455 & c + } + return r + }, + t = 28), + n.prototype.DB = t, + n.prototype.DM = (1 << t) - 1, + n.prototype.DV = 1 << t; + n.prototype.FV = Math.pow(2, 52), + n.prototype.F1 = 52 - t, + n.prototype.F2 = 2 * t - 52; + var o, a, s = new Array; + for (o = "0".charCodeAt(0), + a = 0; a <= 9; ++a) + s[o++] = a; + for (o = "a".charCodeAt(0), + a = 10; a < 36; ++a) + s[o++] = a; + for (o = "A".charCodeAt(0), + a = 10; a < 36; ++a) + s[o++] = a; + + function c(e) { + return "0123456789abcdefghijklmnopqrstuvwxyz".charAt(e) + } + + function l(e, t) { + var n = s[e.charCodeAt(t)]; + return null == n ? -1 : n + } + + function u(e) { + var t = i(); + return t.fromInt(e), + t + } + + function f(e) { + var t, n = 1; + return 0 != (t = e >>> 16) && (e = t, + n += 16), + 0 != (t = e >> 8) && (e = t, + n += 8), + 0 != (t = e >> 4) && (e = t, + n += 4), + 0 != (t = e >> 2) && (e = t, + n += 2), + 0 != (t = e >> 1) && (e = t, + n += 1), + n + } + + function h(e) { + this.m = e + } + + function d(e) { + this.m = e, + this.mp = e.invDigit(), + this.mpl = 32767 & this.mp, + this.mph = this.mp >> 15, + this.um = (1 << e.DB - 15) - 1, + this.mt2 = 2 * e.t + } + + function p(e, t) { + return e & t + } + + function m(e, t) { + return e | t + } + + function v(e, t) { + return e ^ t + } + + function b(e, t) { + return e & ~t + } + + function g(e) { + if (0 == e) + return -1; + var t = 0; + return 0 == (65535 & e) && (e >>= 16, + t += 16), + 0 == (255 & e) && (e >>= 8, + t += 8), + 0 == (15 & e) && (e >>= 4, + t += 4), + 0 == (3 & e) && (e >>= 2, + t += 2), + 0 == (1 & e) && ++t, + t + } + + function y(e) { + for (var t = 0; 0 != e;) + e &= e - 1, + ++t; + return t + } + + function A() { + } + + function w(e) { + return e + } + + function _(e) { + this.r2 = i(), + this.q3 = i(), + n.ONE.dlShiftTo(2 * e.t, this.r2), + this.mu = this.r2.divide(e), + this.m = e + } + + h.prototype.convert = function (e) { + return e.s < 0 || e.compareTo(this.m) >= 0 ? e.mod(this.m) : e + }, + h.prototype.revert = function (e) { + return e + }, + h.prototype.reduce = function (e) { + e.divRemTo(this.m, null, e) + }, + h.prototype.mulTo = function (e, t, n) { + e.multiplyTo(t, n), + this.reduce(n) + }, + h.prototype.sqrTo = function (e, t) { + e.squareTo(t), + this.reduce(t) + }, + d.prototype.convert = function (e) { + var t = i(); + return e.abs().dlShiftTo(this.m.t, t), + t.divRemTo(this.m, null, t), + e.s < 0 && t.compareTo(n.ZERO) > 0 && this.m.subTo(t, t), + t + }, + d.prototype.revert = function (e) { + var t = i(); + return e.copyTo(t), + this.reduce(t), + t + }, + d.prototype.reduce = function (e) { + for (; e.t <= this.mt2;) + e[e.t++] = 0; + for (var t = 0; t < this.m.t; ++t) { + var n = 32767 & e[t], + i = n * this.mpl + ((n * this.mph + (e[t] >> 15) * this.mpl & this.um) << 15) & e.DM; + for (e[n = t + this.m.t] += this.m.am(0, i, e, t, 0, this.m.t); e[n] >= e.DV;) + e[n] -= e.DV, + e[++n]++ + } + e.clamp(), + e.drShiftTo(this.m.t, e), + e.compareTo(this.m) >= 0 && e.subTo(this.m, e) + }, + d.prototype.mulTo = function (e, t, n) { + e.multiplyTo(t, n), + this.reduce(n) + }, + d.prototype.sqrTo = function (e, t) { + e.squareTo(t), + this.reduce(t) + }, + n.prototype.copyTo = function (e) { + for (var t = this.t - 1; t >= 0; --t) + e[t] = this[t]; + e.t = this.t, + e.s = this.s + }, + n.prototype.fromInt = function (e) { + this.t = 1, + this.s = e < 0 ? -1 : 0, + e > 0 ? this[0] = e : e < -1 ? this[0] = e + this.DV : this.t = 0 + }, + n.prototype.fromString = function (e, t) { + var i; + if (16 == t) + i = 4; + else if (8 == t) + i = 3; + else if (256 == t) + i = 8; + else if (2 == t) + i = 1; + else if (32 == t) + i = 5; + else { + if (4 != t) + return void this.fromRadix(e, t); + i = 2 + } + this.t = 0, + this.s = 0; + for (var r = e.length, o = !1, a = 0; --r >= 0;) { + var s = 8 == i ? 255 & e[r] : l(e, r); + s < 0 ? "-" == e.charAt(r) && (o = !0) : (o = !1, + 0 == a ? this[this.t++] = s : a + i > this.DB ? (this[this.t - 1] |= (s & (1 << this.DB - a) - 1) << a, + this[this.t++] = s >> this.DB - a) : this[this.t - 1] |= s << a, + (a += i) >= this.DB && (a -= this.DB)) + } + 8 == i && 0 != (128 & e[0]) && (this.s = -1, + a > 0 && (this[this.t - 1] |= (1 << this.DB - a) - 1 << a)), + this.clamp(), + o && n.ZERO.subTo(this, this) + }, + n.prototype.clamp = function () { + for (var e = this.s & this.DM; this.t > 0 && this[this.t - 1] == e;) + --this.t + }, + n.prototype.dlShiftTo = function (e, t) { + var n; + for (n = this.t - 1; n >= 0; --n) + t[n + e] = this[n]; + for (n = e - 1; n >= 0; --n) + t[n] = 0; + t.t = this.t + e, + t.s = this.s + }, + n.prototype.drShiftTo = function (e, t) { + for (var n = e; n < this.t; ++n) + t[n - e] = this[n]; + t.t = Math.max(this.t - e, 0), + t.s = this.s + }, + n.prototype.lShiftTo = function (e, t) { + var n, i = e % this.DB, + r = this.DB - i, + o = (1 << r) - 1, + a = Math.floor(e / this.DB), + s = this.s << i & this.DM; + for (n = this.t - 1; n >= 0; --n) + t[n + a + 1] = this[n] >> r | s, + s = (this[n] & o) << i; + for (n = a - 1; n >= 0; --n) + t[n] = 0; + t[a] = s, + t.t = this.t + a + 1, + t.s = this.s, + t.clamp() + }, + n.prototype.rShiftTo = function (e, t) { + t.s = this.s; + var n = Math.floor(e / this.DB); + if (n >= this.t) + t.t = 0; + else { + var i = e % this.DB, + r = this.DB - i, + o = (1 << i) - 1; + t[0] = this[n] >> i; + for (var a = n + 1; a < this.t; ++a) + t[a - n - 1] |= (this[a] & o) << r, + t[a - n] = this[a] >> i; + i > 0 && (t[this.t - n - 1] |= (this.s & o) << r), + t.t = this.t - n, + t.clamp() + } + }, + n.prototype.subTo = function (e, t) { + for (var n = 0, i = 0, r = Math.min(e.t, this.t); n < r;) + i += this[n] - e[n], + t[n++] = i & this.DM, + i >>= this.DB; + if (e.t < this.t) { + for (i -= e.s; n < this.t;) + i += this[n], + t[n++] = i & this.DM, + i >>= this.DB; + i += this.s + } else { + for (i += this.s; n < e.t;) + i -= e[n], + t[n++] = i & this.DM, + i >>= this.DB; + i -= e.s + } + t.s = i < 0 ? -1 : 0, + i < -1 ? t[n++] = this.DV + i : i > 0 && (t[n++] = i), + t.t = n, + t.clamp() + }, + n.prototype.multiplyTo = function (e, t) { + var i = this.abs(), + r = e.abs(), + o = i.t; + for (t.t = o + r.t; --o >= 0;) + t[o] = 0; + for (o = 0; o < r.t; ++o) + t[o + i.t] = i.am(0, r[o], t, o, 0, i.t); + t.s = 0, + t.clamp(), + this.s != e.s && n.ZERO.subTo(t, t) + }, + n.prototype.squareTo = function (e) { + for (var t = this.abs(), n = e.t = 2 * t.t; --n >= 0;) + e[n] = 0; + for (n = 0; n < t.t - 1; ++n) { + var i = t.am(n, t[n], e, 2 * n, 0, 1); + (e[n + t.t] += t.am(n + 1, 2 * t[n], e, 2 * n + 1, i, t.t - n - 1)) >= t.DV && (e[n + t.t] -= t.DV, + e[n + t.t + 1] = 1) + } + e.t > 0 && (e[e.t - 1] += t.am(n, t[n], e, 2 * n, 0, 1)), + e.s = 0, + e.clamp() + }, + n.prototype.divRemTo = function (e, t, r) { + var o = e.abs(); + if (!(o.t <= 0)) { + var a = this.abs(); + if (a.t < o.t) + return null != t && t.fromInt(0), + void (null != r && this.copyTo(r)); + null == r && (r = i()); + var s = i(), + c = this.s, + l = e.s, + u = this.DB - f(o[o.t - 1]); + u > 0 ? (o.lShiftTo(u, s), + a.lShiftTo(u, r)) : (o.copyTo(s), + a.copyTo(r)); + var h = s.t, + d = s[h - 1]; + if (0 != d) { + var p = d * (1 << this.F1) + (h > 1 ? s[h - 2] >> this.F2 : 0), + m = this.FV / p, + v = (1 << this.F1) / p, + b = 1 << this.F2, + g = r.t, + y = g - h, + A = null == t ? i() : t; + for (s.dlShiftTo(y, A), + r.compareTo(A) >= 0 && (r[r.t++] = 1, + r.subTo(A, r)), + n.ONE.dlShiftTo(h, A), + A.subTo(s, s); s.t < h;) + s[s.t++] = 0; + for (; --y >= 0;) { + var w = r[--g] == d ? this.DM : Math.floor(r[g] * m + (r[g - 1] + b) * v); + if ((r[g] += s.am(0, w, r, y, 0, h)) < w) + for (s.dlShiftTo(y, A), + r.subTo(A, r); r[g] < --w;) + r.subTo(A, r) + } + null != t && (r.drShiftTo(h, t), + c != l && n.ZERO.subTo(t, t)), + r.t = h, + r.clamp(), + u > 0 && r.rShiftTo(u, r), + c < 0 && n.ZERO.subTo(r, r) + } + } + }, + n.prototype.invDigit = function () { + if (this.t < 1) + return 0; + var e = this[0]; + if (0 == (1 & e)) + return 0; + var t = 3 & e; + return (t = (t = (t = (t = t * (2 - (15 & e) * t) & 15) * (2 - (255 & e) * t) & 255) * (2 - ((65535 & e) * t & 65535)) & 65535) * (2 - e * t % this.DV) % this.DV) > 0 ? this.DV - t : -t + }, + n.prototype.isEven = function () { + return 0 == (this.t > 0 ? 1 & this[0] : this.s) + }, + n.prototype.exp = function (e, t) { + if (e > 4294967295 || e < 1) + return n.ONE; + var r = i(), + o = i(), + a = t.convert(this), + s = f(e) - 1; + for (a.copyTo(r); --s >= 0;) + if (t.sqrTo(r, o), + (e & 1 << s) > 0) + t.mulTo(o, a, r); + else { + var c = r; + r = o, + o = c + } + return t.revert(r) + }, + n.prototype.toString = function (e) { + if (this.s < 0) + return "-" + this.negate().toString(e); + var t; + if (16 == e) + t = 4; + else if (8 == e) + t = 3; + else if (2 == e) + t = 1; + else if (32 == e) + t = 5; + else { + if (4 != e) + return this.toRadix(e); + t = 2 + } + var n, i = (1 << t) - 1, + r = !1, + o = "", + a = this.t, + s = this.DB - a * this.DB % t; + if (a-- > 0) + for (s < this.DB && (n = this[a] >> s) > 0 && (r = !0, + o = c(n)); a >= 0;) + s < t ? (n = (this[a] & (1 << s) - 1) << t - s, + n |= this[--a] >> (s += this.DB - t)) : (n = this[a] >> (s -= t) & i, + s <= 0 && (s += this.DB, + --a)), + n > 0 && (r = !0), + r && (o += c(n)); + return r ? o : "0" + }, + n.prototype.negate = function () { + var e = i(); + return n.ZERO.subTo(this, e), + e + }, + n.prototype.abs = function () { + return this.s < 0 ? this.negate() : this + }, + n.prototype.compareTo = function (e) { + var t = this.s - e.s; + if (0 != t) + return t; + var n = this.t; + if (0 != (t = n - e.t)) + return this.s < 0 ? -t : t; + for (; --n >= 0;) + if (0 != (t = this[n] - e[n])) + return t; + return 0 + }, + n.prototype.bitLength = function () { + return this.t <= 0 ? 0 : this.DB * (this.t - 1) + f(this[this.t - 1] ^ this.s & this.DM) + }, + n.prototype.mod = function (e) { + var t = i(); + return this.abs().divRemTo(e, null, t), + this.s < 0 && t.compareTo(n.ZERO) > 0 && e.subTo(t, t), + t + }, + n.prototype.modPowInt = function (e, t) { + var n; + return n = e < 256 || t.isEven() ? new h(t) : new d(t), + this.exp(e, n) + }, + n.ZERO = u(0), + n.ONE = u(1), + A.prototype.convert = w, + A.prototype.revert = w, + A.prototype.mulTo = function (e, t, n) { + e.multiplyTo(t, n) + }, + A.prototype.sqrTo = function (e, t) { + e.squareTo(t) + }, + _.prototype.convert = function (e) { + if (e.s < 0 || e.t > 2 * this.m.t) + return e.mod(this.m); + if (e.compareTo(this.m) < 0) + return e; + var t = i(); + return e.copyTo(t), + this.reduce(t), + t + }, + _.prototype.revert = function (e) { + return e + }, + _.prototype.reduce = function (e) { + for (e.drShiftTo(this.m.t - 1, this.r2), + e.t > this.m.t + 1 && (e.t = this.m.t + 1, + e.clamp()), + this.mu.multiplyUpperTo(this.r2, this.m.t + 1, this.q3), + this.m.multiplyLowerTo(this.q3, this.m.t + 1, this.r2); e.compareTo(this.r2) < 0;) + e.dAddOffset(1, this.m.t + 1); + for (e.subTo(this.r2, e); e.compareTo(this.m) >= 0;) + e.subTo(this.m, e) + }, + _.prototype.mulTo = function (e, t, n) { + e.multiplyTo(t, n), + this.reduce(n) + }, + _.prototype.sqrTo = function (e, t) { + e.squareTo(t), + this.reduce(t) + }; + var x, S, k, + C = [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], + E = (1 << 26) / C[C.length - 1]; + + function O() { + !function (e) { + S[k++] ^= 255 & e, + S[k++] ^= e >> 8 & 255, + S[k++] ^= e >> 16 & 255, + S[k++] ^= e >> 24 & 255, + k >= N && (k -= N) + }((new Date).getTime()) + } + + if (n.prototype.chunkSize = function (e) { + return Math.floor(Math.LN2 * this.DB / Math.log(e)) + }, + n.prototype.toRadix = function (e) { + if (null == e && (e = 10), + 0 == this.signum() || e < 2 || e > 36) + return "0"; + var t = this.chunkSize(e), + n = Math.pow(e, t), + r = u(n), + o = i(), + a = i(), + s = ""; + for (this.divRemTo(r, o, a); o.signum() > 0;) + s = (n + a.intValue()).toString(e).substr(1) + s, + o.divRemTo(r, o, a); + return a.intValue().toString(e) + s + }, + n.prototype.fromRadix = function (e, t) { + this.fromInt(0), + null == t && (t = 10); + for (var i = this.chunkSize(t), r = Math.pow(t, i), o = !1, a = 0, s = 0, c = 0; c < e.length; ++c) { + var u = l(e, c); + u < 0 ? "-" == e.charAt(c) && 0 == this.signum() && (o = !0) : (s = t * s + u, + ++a >= i && (this.dMultiply(r), + this.dAddOffset(s, 0), + a = 0, + s = 0)) + } + a > 0 && (this.dMultiply(Math.pow(t, a)), + this.dAddOffset(s, 0)), + o && n.ZERO.subTo(this, this) + }, + n.prototype.fromNumber = function (e, t, i) { + if ("number" == typeof t) + if (e < 2) + this.fromInt(1); + else + for (this.fromNumber(e, i), + this.testBit(e - 1) || this.bitwiseTo(n.ONE.shiftLeft(e - 1), m, this), + this.isEven() && this.dAddOffset(1, 0); !this.isProbablePrime(t);) + this.dAddOffset(2, 0), + this.bitLength() > e && this.subTo(n.ONE.shiftLeft(e - 1), this); + else { + var r = new Array, + o = 7 & e; + r.length = 1 + (e >> 3), + t.nextBytes(r), + o > 0 ? r[0] &= (1 << o) - 1 : r[0] = 0, + this.fromString(r, 256) + } + }, + n.prototype.bitwiseTo = function (e, t, n) { + var i, r, o = Math.min(e.t, this.t); + for (i = 0; i < o; ++i) + n[i] = t(this[i], e[i]); + if (e.t < this.t) { + for (r = e.s & this.DM, + i = o; i < this.t; ++i) + n[i] = t(this[i], r); + n.t = this.t + } else { + for (r = this.s & this.DM, + i = o; i < e.t; ++i) + n[i] = t(r, e[i]); + n.t = e.t + } + n.s = t(this.s, e.s), + n.clamp() + }, + n.prototype.changeBit = function (e, t) { + var i = n.ONE.shiftLeft(e); + return this.bitwiseTo(i, t, i), + i + }, + n.prototype.addTo = function (e, t) { + for (var n = 0, i = 0, r = Math.min(e.t, this.t); n < r;) + i += this[n] + e[n], + t[n++] = i & this.DM, + i >>= this.DB; + if (e.t < this.t) { + for (i += e.s; n < this.t;) + i += this[n], + t[n++] = i & this.DM, + i >>= this.DB; + i += this.s + } else { + for (i += this.s; n < e.t;) + i += e[n], + t[n++] = i & this.DM, + i >>= this.DB; + i += e.s + } + t.s = i < 0 ? -1 : 0, + i > 0 ? t[n++] = i : i < -1 && (t[n++] = this.DV + i), + t.t = n, + t.clamp() + }, + n.prototype.dMultiply = function (e) { + this[this.t] = this.am(0, e - 1, this, 0, 0, this.t), + ++this.t, + this.clamp() + }, + n.prototype.dAddOffset = function (e, t) { + if (0 != e) { + for (; this.t <= t;) + this[this.t++] = 0; + for (this[t] += e; this[t] >= this.DV;) + this[t] -= this.DV, + ++t >= this.t && (this[this.t++] = 0), + ++this[t] + } + }, + n.prototype.multiplyLowerTo = function (e, t, n) { + var i, r = Math.min(this.t + e.t, t); + for (n.s = 0, + n.t = r; r > 0;) + n[--r] = 0; + for (i = n.t - this.t; r < i; ++r) + n[r + this.t] = this.am(0, e[r], n, r, 0, this.t); + for (i = Math.min(e.t, t); r < i; ++r) + this.am(0, e[r], n, r, 0, t - r); + n.clamp() + }, + n.prototype.multiplyUpperTo = function (e, t, n) { + --t; + var i = n.t = this.t + e.t - t; + for (n.s = 0; --i >= 0;) + n[i] = 0; + for (i = Math.max(t - this.t, 0); i < e.t; ++i) + n[this.t + i - t] = this.am(t - i, e[i], n, 0, 0, this.t + i - t); + n.clamp(), + n.drShiftTo(1, n) + }, + n.prototype.modInt = function (e) { + if (e <= 0) + return 0; + var t = this.DV % e, + n = this.s < 0 ? e - 1 : 0; + if (this.t > 0) + if (0 == t) + n = this[0] % e; + else + for (var i = this.t - 1; i >= 0; --i) + n = (t * n + this[i]) % e; + return n + }, + n.prototype.millerRabin = function (e) { + var t = this.subtract(n.ONE), + r = t.getLowestSetBit(); + if (r <= 0) + return !1; + var o = t.shiftRight(r); + (e = e + 1 >> 1) > C.length && (e = C.length); + for (var a = i(), s = 0; s < e; ++s) { + a.fromInt(C[Math.floor(Math.random() * C.length)]); + var c = a.modPow(o, this); + if (0 != c.compareTo(n.ONE) && 0 != c.compareTo(t)) { + for (var l = 1; l++ < r && 0 != c.compareTo(t);) + if (0 == (c = c.modPowInt(2, this)).compareTo(n.ONE)) + return !1; + if (0 != c.compareTo(t)) + return !1 + } + } + return !0 + }, + n.prototype.clone = function () { + var e = i(); + return this.copyTo(e), + e + }, + n.prototype.intValue = 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] + }, + n.prototype.byteValue = function () { + return 0 == this.t ? this.s : this[0] << 24 >> 24 + }, + n.prototype.shortValue = function () { + return 0 == this.t ? this.s : this[0] << 16 >> 16 + }, + n.prototype.signum = function () { + return this.s < 0 ? -1 : this.t <= 0 || 1 == this.t && this[0] <= 0 ? 0 : 1 + }, + n.prototype.toByteArray = function () { + var e = this.t, + t = new Array; + t[0] = this.s; + var n, i = this.DB - e * this.DB % 8, + r = 0; + if (e-- > 0) + for (i < this.DB && (n = this[e] >> i) != (this.s & this.DM) >> i && (t[r++] = n | this.s << this.DB - i); e >= 0;) + i < 8 ? (n = (this[e] & (1 << i) - 1) << 8 - i, + n |= this[--e] >> (i += this.DB - 8)) : (n = this[e] >> (i -= 8) & 255, + i <= 0 && (i += this.DB, + --e)), + 0 != (128 & n) && (n |= -256), + 0 == r && (128 & this.s) != (128 & n) && ++r, + (r > 0 || n != this.s) && (t[r++] = n); + return t + }, + n.prototype.equals = function (e) { + return 0 == this.compareTo(e) + }, + n.prototype.min = function (e) { + return this.compareTo(e) < 0 ? this : e + }, + n.prototype.max = function (e) { + return this.compareTo(e) > 0 ? this : e + }, + n.prototype.and = function (e) { + var t = i(); + return this.bitwiseTo(e, p, t), + t + }, + n.prototype.or = function (e) { + var t = i(); + return this.bitwiseTo(e, m, t), + t + }, + n.prototype.xor = function (e) { + var t = i(); + return this.bitwiseTo(e, v, t), + t + }, + n.prototype.andNot = function (e) { + var t = i(); + return this.bitwiseTo(e, b, t), + t + }, + n.prototype.not = function () { + for (var e = i(), t = 0; t < this.t; ++t) + e[t] = this.DM & ~this[t]; + return e.t = this.t, + e.s = ~this.s, + e + }, + n.prototype.shiftLeft = function (e) { + var t = i(); + return e < 0 ? this.rShiftTo(-e, t) : this.lShiftTo(e, t), + t + }, + n.prototype.shiftRight = function (e) { + var t = i(); + return e < 0 ? this.lShiftTo(-e, t) : this.rShiftTo(e, t), + t + }, + n.prototype.getLowestSetBit = function () { + for (var e = 0; e < this.t; ++e) + if (0 != this[e]) + return e * this.DB + g(this[e]); + return this.s < 0 ? this.t * this.DB : -1 + }, + n.prototype.bitCount = function () { + for (var e = 0, t = this.s & this.DM, n = 0; n < this.t; ++n) + e += y(this[n] ^ t); + return e + }, + n.prototype.testBit = function (e) { + var t = Math.floor(e / this.DB); + return t >= this.t ? 0 != this.s : 0 != (this[t] & 1 << e % this.DB) + }, + n.prototype.setBit = function (e) { + return this.changeBit(e, m) + }, + n.prototype.clearBit = function (e) { + return this.changeBit(e, b) + }, + n.prototype.flipBit = function (e) { + return this.changeBit(e, v) + }, + n.prototype.add = function (e) { + var t = i(); + return this.addTo(e, t), + t + }, + n.prototype.subtract = function (e) { + var t = i(); + return this.subTo(e, t), + t + }, + n.prototype.multiply = function (e) { + var t = i(); + return this.multiplyTo(e, t), + t + }, + n.prototype.divide = function (e) { + var t = i(); + return this.divRemTo(e, t, null), + t + }, + n.prototype.remainder = function (e) { + var t = i(); + return this.divRemTo(e, null, t), + t + }, + n.prototype.divideAndRemainder = function (e) { + var t = i(), + n = i(); + return this.divRemTo(e, t, n), + new Array(t, n) + }, + n.prototype.modPow = function (e, t) { + var n, r, o = e.bitLength(), + a = u(1); + if (o <= 0) + return a; + n = o < 18 ? 1 : o < 48 ? 3 : o < 144 ? 4 : o < 768 ? 5 : 6, + r = o < 8 ? new h(t) : t.isEven() ? new _(t) : new d(t); + var s = new Array, + c = 3, + l = n - 1, + p = (1 << n) - 1; + if (s[1] = r.convert(this), + n > 1) { + var m = i(); + for (r.sqrTo(s[1], m); c <= p;) + s[c] = i(), + r.mulTo(m, s[c - 2], s[c]), + c += 2 + } + var v, b, g = e.t - 1, + y = !0, + A = i(); + for (o = f(e[g]) - 1; g >= 0;) { + for (o >= l ? v = e[g] >> o - l & p : (v = (e[g] & (1 << o + 1) - 1) << l - o, + g > 0 && (v |= e[g - 1] >> this.DB + o - l)), + c = n; 0 == (1 & v);) + v >>= 1, + --c; + if ((o -= c) < 0 && (o += this.DB, + --g), + y) + s[v].copyTo(a), + y = !1; + else { + for (; c > 1;) + r.sqrTo(a, A), + r.sqrTo(A, a), + c -= 2; + c > 0 ? r.sqrTo(a, A) : (b = a, + a = A, + A = b), + r.mulTo(A, s[v], a) + } + for (; g >= 0 && 0 == (e[g] & 1 << o);) + r.sqrTo(a, A), + b = a, + a = A, + A = b, + --o < 0 && (o = this.DB - 1, + --g) + } + return r.revert(a) + }, + n.prototype.modInverse = function (e) { + var t = e.isEven(); + if (this.isEven() && t || 0 == e.signum()) + return n.ZERO; + for (var i = e.clone(), r = this.clone(), o = u(1), a = u(0), s = u(0), c = u(1); 0 != i.signum();) { + for (; i.isEven();) + i.rShiftTo(1, i), + t ? (o.isEven() && a.isEven() || (o.addTo(this, o), + a.subTo(e, a)), + o.rShiftTo(1, o)) : a.isEven() || a.subTo(e, a), + a.rShiftTo(1, a); + for (; r.isEven();) + r.rShiftTo(1, r), + t ? (s.isEven() && c.isEven() || (s.addTo(this, s), + c.subTo(e, c)), + s.rShiftTo(1, s)) : c.isEven() || c.subTo(e, c), + c.rShiftTo(1, c); + i.compareTo(r) >= 0 ? (i.subTo(r, i), + t && o.subTo(s, o), + a.subTo(c, a)) : (r.subTo(i, r), + t && s.subTo(o, s), + c.subTo(a, c)) + } + return 0 != r.compareTo(n.ONE) ? n.ZERO : c.compareTo(e) >= 0 ? c.subtract(e) : c.signum() < 0 ? (c.addTo(e, c), + c.signum() < 0 ? c.add(e) : c) : c + }, + n.prototype.pow = function (e) { + return this.exp(e, new A) + }, + n.prototype.gcd = function (e) { + var t = this.s < 0 ? this.negate() : this.clone(), + n = e.s < 0 ? e.negate() : e.clone(); + if (t.compareTo(n) < 0) { + var i = t; + t = n, + n = i + } + var r = t.getLowestSetBit(), + o = n.getLowestSetBit(); + if (o < 0) + return t; + for (r < o && (o = r), + o > 0 && (t.rShiftTo(o, t), + n.rShiftTo(o, n)); t.signum() > 0;) + (r = t.getLowestSetBit()) > 0 && t.rShiftTo(r, t), + (r = n.getLowestSetBit()) > 0 && n.rShiftTo(r, n), + t.compareTo(n) >= 0 ? (t.subTo(n, t), + t.rShiftTo(1, t)) : (n.subTo(t, n), + n.rShiftTo(1, n)); + return o > 0 && n.lShiftTo(o, n), + n + }, + n.prototype.isProbablePrime = function (e) { + var t, n = this.abs(); + if (1 == n.t && n[0] <= C[C.length - 1]) { + for (t = 0; t < C.length; ++t) + if (n[0] == C[t]) + return !0; + return !1 + } + if (n.isEven()) + return !1; + for (t = 1; t < C.length;) { + for (var i = C[t], r = t + 1; r < C.length && i < E;) + i *= C[r++]; + for (i = n.modInt(i); t < r;) + if (i % C[t++] == 0) + return !1 + } + return n.millerRabin(e) + }, + n.prototype.square = function () { + var e = i(); + return this.squareTo(e), + e + }, + n.prototype.Barrett = _, + null == S) { + var M; + if (S = new Array, + k = 0, + "undefined" != typeof window && window.crypto) + if (window.crypto.getRandomValues) { + var T = new Uint8Array(32); + for (window.crypto.getRandomValues(T), + M = 0; M < 32; ++M) + S[k++] = T[M] + } else if ("Netscape" == navigator.appName && navigator.appVersion < "5") { + var D = window.crypto.random(32); + for (M = 0; M < D.length; ++M) + S[k++] = 255 & D.charCodeAt(M) + } + for (; k < N;) + M = Math.floor(65536 * Math.random()), + S[k++] = M >>> 8, + S[k++] = 255 & M; + k = 0, + O() + } + + function P() { + if (null == x) { + for (O(), + (x = new j).init(S), + k = 0; k < S.length; ++k) + S[k] = 0; + k = 0 + } + return x.next() + } + + function I() { + } + + function j() { + this.i = 0, + this.j = 0, + this.S = new Array + } + + I.prototype.nextBytes = function (e) { + var t; + for (t = 0; t < e.length; ++t) + e[t] = P() + }, + j.prototype.init = function (e) { + var t, n, i; + for (t = 0; t < 256; ++t) + this.S[t] = t; + for (n = 0, + t = 0; t < 256; ++t) + n = n + this.S[t] + e[t % e.length] & 255, + i = this.S[t], + this.S[t] = this.S[n], + this.S[n] = i; + this.i = 0, + this.j = 0 + }, + j.prototype.next = function () { + var e; + return this.i = this.i + 1 & 255, + this.j = this.j + this.S[this.i] & 255, + e = this.S[this.i], + this.S[this.i] = this.S[this.j], + this.S[this.j] = e, + this.S[e + this.S[this.i] & 255] + }; + var N = 256; + n.SecureRandom = I, + n.BigInteger = n, + e.exports = n + }).call(this) + }, + "4d2d": function (e, t, n) { + "use strict"; + n.r(t), + n.d(t, "SM3Digest", (function () { + return l + })) + // , + // n("ac6a"), + // n("456d") + ; + var i = n("d225"), + r = n("b0b4"), + // o = (n("6b54"), n("c5f6"), n("f33e")).BigInteger + o = n("f33e").BigInteger, + a = n("b381"), + s = function (e, t, n, i, r) { + for (var o = 0; o < r; o++) + n[i + o] = e[t + o] + }, + c = { + minValue: -2147483648, + maxValue: 2147483647, + parse: function (e) { + if (e < this.minValue) { + for (var t = Number(-e).toString(2), n = t.substr(t.length - 31, 31), i = "", r = 0; r < n.length; r++) { + i += "0" === n.substr(r, 1) ? "1" : "0" + } + return parseInt(i, 2) + 1 + } + if (e > this.maxValue) { + for (var o = Number(e).toString(2), a = o.substr(o.length - 31, 31), s = "", c = 0; c < a.length; c++) { + s += "0" === a.substr(c, 1) ? "1" : "0" + } + return -(parseInt(s, 2) + 1) + } + return e + }, + parseByte: function (e) { + if (e < 0) { + for (var t = Number(-e).toString(2), n = t.substr(t.length - 8, 8), i = "", r = 0; r < n.length; r++) { + i += "0" === n.substr(r, 1) ? "1" : "0" + } + return (parseInt(i, 2) + 1) % 256 + } + if (e > 255) { + var o = Number(e).toString(2); + return parseInt(o.substr(o.length - 8, 8), 2) + } + return e + } + }, + l = function () { + function e() { + Object(i.a)(this, e), + this.xBuf = [], + this.xBufOff = 0, + this.byteCount = 0, + this.DIGEST_LENGTH = 32, + this.v0 = [1937774191, 1226093241, 388252375, 3666478592, 2842636476, 372324522, 3817729613, 2969243214], + this.v0 = [1937774191, 1226093241, 388252375, -628488704, -1452330820, 372324522, -477237683, -1325724082], + this.v = new Array(8), + this.v_ = new Array(8), + this.X0 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + this.X = new Array(68), + this.xOff = 0, + this.T_00_15 = 2043430169, + this.T_16_63 = 2055708042, + arguments.length > 0 ? this.initDigest(arguments.length <= 0 ? void 0 : arguments[0]) : this.init() + } + + return Object(r.a)(e, [{ + key: "init", + value: function () { + this.xBuf = new Array(4), + this.reset() + } + }, { + key: "initDigest", + value: function (e) { + this.xBuf = [].concat(e.xBuf), + this.xBufOff = e.xBufOff, + this.byteCount = e.byteCount, + s(e.X, 0, this.X, 0, e.X.length), + this.xOff = e.xOff, + s(e.v, 0, this.v, 0, e.v.length) + } + }, { + key: "getDigestSize", + value: function () { + return this.DIGEST_LENGTH + } + }, { + key: "reset", + value: function () { + this.byteCount = 0, + this.xBufOff = 0; + for (var e = Object.keys(this.xBuf), t = 0, n = e.length; t < n; t++) + this.xBuf[e[t]] = null; + s(this.v0, 0, this.v, 0, this.v0.length), + this.xOff = 0, + s(this.X0, 0, this.X, 0, this.X0.length) + } + }, { + key: "processBlock", + value: function () { + var e, t = this.X, + n = new Array(64); + for (e = 16; e < 68; e++) + t[e] = this.p1(t[e - 16] ^ t[e - 9] ^ this.rotate(t[e - 3], 15)) ^ this.rotate(t[e - 13], 7) ^ t[e - 6]; + for (e = 0; e < 64; e++) + n[e] = t[e] ^ t[e + 4]; + var i, r, o, a, l, u = this.v, + f = this.v_; + for (s(u, 0, f, 0, this.v0.length), + e = 0; e < 16; e++) + l = this.rotate(f[0], 12), + i = c.parse(c.parse(l + f[4]) + this.rotate(this.T_00_15, e)), + r = (i = this.rotate(i, 7)) ^ l, + o = c.parse(c.parse(this.ff_00_15(f[0], f[1], f[2]) + f[3]) + r) + n[e], + a = c.parse(c.parse(this.gg_00_15(f[4], f[5], f[6]) + f[7]) + i) + t[e], + f[3] = f[2], + f[2] = this.rotate(f[1], 9), + f[1] = f[0], + f[0] = o, + f[7] = f[6], + f[6] = this.rotate(f[5], 19), + f[5] = f[4], + f[4] = this.p0(a); + for (e = 16; e < 64; e++) + l = this.rotate(f[0], 12), + i = c.parse(c.parse(l + f[4]) + this.rotate(this.T_16_63, e)), + r = (i = this.rotate(i, 7)) ^ l, + o = c.parse(c.parse(this.ff_16_63(f[0], f[1], f[2]) + f[3]) + r) + n[e], + a = c.parse(c.parse(this.gg_16_63(f[4], f[5], f[6]) + f[7]) + i) + t[e], + f[3] = f[2], + f[2] = this.rotate(f[1], 9), + f[1] = f[0], + f[0] = o, + f[7] = f[6], + f[6] = this.rotate(f[5], 19), + f[5] = f[4], + f[4] = this.p0(a); + for (e = 0; e < 8; e++) + u[e] ^= c.parse(f[e]); + this.xOff = 0, + s(this.X0, 0, this.X, 0, this.X0.length) + } + }, { + key: "processWord", + value: function (e, t) { + var n = e[t] << 24; + n |= (255 & e[++t]) << 16, + n |= (255 & e[++t]) << 8, + n |= 255 & e[++t], + this.X[this.xOff] = n, + 16 == ++this.xOff && this.processBlock() + } + }, { + key: "processLength", + value: function (e) { + this.xOff > 14 && this.processBlock(), + this.X[14] = this.urShiftLong(e, 32), + this.X[15] = 4294967295 & e + } + }, { + key: "intToBigEndian", + value: function (e, t, n) { + t[n] = 255 & c.parseByte(this.urShift(e, 24)), + t[++n] = 255 & c.parseByte(this.urShift(e, 16)), + t[++n] = 255 & c.parseByte(this.urShift(e, 8)), + t[++n] = 255 & c.parseByte(e) + } + }, { + key: "doFinal", + value: function (e, t) { + this.finish(); + for (var n = 0; n < 8; n++) + this.intToBigEndian(this.v[n], e, t + 4 * n); + return this.reset(), + this.DIGEST_LENGTH + } + }, { + key: "update", + value: function (e) { + this.xBuf[this.xBufOff++] = e, + this.xBufOff === this.xBuf.length && (this.processWord(this.xBuf, 0), + this.xBufOff = 0), + this.byteCount++ + } + }, { + key: "blockUpdate", + value: function (e, t, n) { + for (; 0 !== this.xBufOff && n > 0;) + this.update(e[t]), + t++, + n--; + for (; n > this.xBuf.length;) + this.processWord(e, t), + t += this.xBuf.length, + n -= this.xBuf.length, + this.byteCount += this.xBuf.length; + for (; n > 0;) + this.update(e[t]), + t++, + n-- + } + }, { + key: "finish", + value: function () { + var e = this.byteCount << 3; + for (this.update(128); 0 !== this.xBufOff;) + this.update(0); + this.processLength(e), + this.processBlock() + } + }, { + key: "rotate", + value: function (e, t) { + return e << t | this.urShift(e, 32 - t) + } + }, { + key: "p0", + value: function (e) { + return e ^ this.rotate(e, 9) ^ this.rotate(e, 17) + } + }, { + key: "p1", + value: function (e) { + return e ^ this.rotate(e, 15) ^ this.rotate(e, 23) + } + }, { + key: "ff_00_15", + value: function (e, t, n) { + return e ^ t ^ n + } + }, { + key: "ff_16_63", + value: function (e, t, n) { + return e & t | e & n | t & n + } + }, { + key: "gg_00_15", + value: function (e, t, n) { + return e ^ t ^ n + } + }, { + key: "gg_16_63", + value: function (e, t, n) { + return e & t | ~e & n + } + }, { + key: "urShift", + value: function (e, t) { + return (e > c.maxValue || e < c.minValue) && (e = c.parse(e)), + e >>> t + } + }, { + key: "urShiftLong", + value: function (e, t) { + var n, i = new o; + if (i.fromInt(e), + i.signum() >= 0) + n = i.shiftRight(t).intValue(); + else { + var r = new o; + r.fromInt(2); + var a = ~t, + s = ""; + if (a < 0) { + for (var c = 64 + a, l = 0; l < c; l++) + s += "0"; + var u = new o; + u.fromInt(e >> t); + var f = new o("10" + s, 2); + s = f.toRadix(10), + n = f.add(u).toRadix(10) + } else + n = (e >> t) + (s = r.shiftLeft(~t).intValue()) + } + return n + } + }, { + key: "getZ", + value: function (e, t) { + var n = a.parseUtf8StringToHex("1234567812345678"), + i = 4 * n.length; + this.update(i >> 8 & 255), + this.update(255 & i); + var r = a.hexToArray(n); + this.blockUpdate(r, 0, r.length); + var o = a.hexToArray(e.curve.a.toBigInteger().toRadix(16)), + s = a.hexToArray(e.curve.b.toBigInteger().toRadix(16)), + c = a.hexToArray(e.getX().toBigInteger().toRadix(16)), + l = a.hexToArray(e.getY().toBigInteger().toRadix(16)), + u = a.hexToArray(t.substr(0, 64)), + f = a.hexToArray(t.substr(64, 64)); + this.blockUpdate(o, 0, o.length), + this.blockUpdate(s, 0, s.length), + this.blockUpdate(c, 0, c.length), + this.blockUpdate(l, 0, l.length), + this.blockUpdate(u, 0, u.length), + this.blockUpdate(f, 0, f.length); + var h = new Array(this.getDigestSize()); + return this.doFinal(h, 0), + h + } + }]), + e + }() + }, + 'b381': function (e, t, n) { + "use strict"; + n.r(t), + n.d(t, "getGlobalCurve", (function () { + return b + })), + n.d(t, "generateEcparam", (function () { + return g + })), + n.d(t, "generateKeyPairHex", (function () { + return y + })), + n.d(t, "parseUtf8StringToHex", (function () { + return A + })), + n.d(t, "parseArrayBufferToHex", (function () { + return w + })), + n.d(t, "leftPad", (function () { + return _ + })), + n.d(t, "arrayToHex", (function () { + return x + })), + n.d(t, "arrayToUtf8", (function () { + return S + })), + n.d(t, "hexToArray", (function () { + return k + })) + // , + // n("34ef"), + // n("6b54") + ; + var i = n("d225"), + r = n("b0b4"), + o = n("f33e").BigInteger, + a = new o("3"), + s = function () { + function e(t, n) { + Object(i.a)(this, e), + this.x = n, + this.q = t + } + + return Object(r.a)(e, [{ + key: "equals", + value: function (e) { + return e === this || this.q.equals(e.q) && this.x.equals(e.x) + } + }, { + key: "toBigInteger", + value: function () { + return this.x + } + }, { + key: "negate", + value: function () { + return new e(this.q, this.x.negate().mod(this.q)) + } + }, { + key: "add", + value: function (t) { + return new e(this.q, this.x.add(t.toBigInteger()).mod(this.q)) + } + }, { + key: "subtract", + value: function (t) { + return new e(this.q, this.x.subtract(t.toBigInteger()).mod(this.q)) + } + }, { + key: "multiply", + value: function (t) { + return new e(this.q, this.x.multiply(t.toBigInteger()).mod(this.q)) + } + }, { + key: "divide", + value: function (t) { + return new e(this.q, this.x.multiply(t.toBigInteger().modInverse(this.q)).mod(this.q)) + } + }, { + key: "square", + value: function () { + return new e(this.q, this.x.square().mod(this.q)) + } + }]), + e + }(), + c = function () { + function e(t, n, r, a) { + Object(i.a)(this, e), + this.curve = t, + this.x = n, + this.y = r, + this.z = null == a ? o.ONE : a, + this.zinv = null + } + + return Object(r.a)(e, [{ + 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 (e) { + return e === this || (this.isInfinity() ? e.isInfinity() : e.isInfinity() ? this.isInfinity() : !!e.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(e.z)).mod(this.curve.q).equals(o.ZERO) && e.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(e.z)).mod(this.curve.q).equals(o.ZERO)) + } + }, { + key: "isInfinity", + value: function () { + return null === this.x && null === this.y || this.z.equals(o.ZERO) && !this.y.toBigInteger().equals(o.ZERO) + } + }, { + key: "negate", + value: function () { + return new e(this.curve, this.x, this.y.negate(), this.z) + } + }, { + key: "add", + value: function (t) { + if (this.isInfinity()) + return t; + if (t.isInfinity()) + return this; + var n = this.x.toBigInteger(), + i = this.y.toBigInteger(), + r = this.z, + a = t.x.toBigInteger(), + s = t.y.toBigInteger(), + c = t.z, + l = this.curve.q, + u = n.multiply(c).mod(l), + f = a.multiply(r).mod(l), + h = u.subtract(f), + d = i.multiply(c).mod(l), + p = s.multiply(r).mod(l), + m = d.subtract(p); + if (o.ZERO.equals(h)) + return o.ZERO.equals(m) ? this.twice() : this.curve.infinity; + var v = u.add(f), + b = r.multiply(c).mod(l), + g = h.square().mod(l), + y = h.multiply(g).mod(l), + A = b.multiply(m.square()).subtract(v.multiply(g)).mod(l), + w = h.multiply(A).mod(l), + _ = m.multiply(g.multiply(u).subtract(A)).subtract(d.multiply(y)).mod(l), + x = y.multiply(b).mod(l); + return new e(this.curve, this.curve.fromBigInteger(w), this.curve.fromBigInteger(_), x) + } + }, { + key: "twice", + value: function () { + if (this.isInfinity()) + return this; + if (!this.y.toBigInteger().signum()) + return this.curve.infinity; + var t = this.x.toBigInteger(), + n = this.y.toBigInteger(), + i = this.z, + r = this.curve.q, + o = this.curve.a.toBigInteger(), + s = t.square().multiply(a).add(o.multiply(i.square())).mod(r), + c = n.shiftLeft(1).multiply(i).mod(r), + l = n.square().mod(r), + u = l.multiply(t).multiply(i).mod(r), + f = c.square().mod(r), + h = s.square().subtract(u.shiftLeft(3)).mod(r), + d = c.multiply(h).mod(r), + p = s.multiply(u.shiftLeft(2).subtract(h)).subtract(f.shiftLeft(1).multiply(l)).mod(r), + m = c.multiply(f).mod(r); + return new e(this.curve, this.curve.fromBigInteger(d), this.curve.fromBigInteger(p), m) + } + }, { + key: "multiply", + value: function (e) { + if (this.isInfinity()) + return this; + if (!e.signum()) + return this.curve.infinity; + for (var t = e.multiply(a), n = this.negate(), i = this, r = t.bitLength() - 2; r > 0; r--) { + i = i.twice(); + var o = t.testBit(r); + o !== e.testBit(r) && (i = i.add(o ? this : n)) + } + return i + } + }]), + e + }(), + l = function () { + function e(t, n, r) { + Object(i.a)(this, e), + this.q = t, + this.a = this.fromBigInteger(n), + this.b = this.fromBigInteger(r), + this.infinity = new c(this, null, null) + } + + return Object(r.a)(e, [{ + key: "equals", + value: function (e) { + return e === this || this.q.equals(e.q) && this.a.equals(e.a) && this.b.equals(e.b) + } + }, { + key: "fromBigInteger", + value: function (e) { + return new s(this.q, e) + } + }, { + key: "decodePointHex", + value: function (e) { + switch (parseInt(e.substr(0, 2), 16)) { + case 0: + return this.infinity; + case 2: + case 3: + return null; + case 4: + case 6: + case 7: + var t = (e.length - 2) / 2, + n = e.substr(2, t), + i = e.substr(t + 2, t); + return new c(this, this.fromBigInteger(new o(n, 16)), this.fromBigInteger(new o(i, 16))); + default: + return null + } + } + }]), + e + }(), + u = n("f33e"), + f = u.BigInteger, + h = new (0, + u.SecureRandom), + d = g(), + p = d.curve, + m = d.G, + v = d.n; + + function b() { + return p + } + + function g() { + var e = new f("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFF", 16), + t = new f("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFC", 16), + n = new f("28E9FA9E9D9F5E344D5A9E4BCF6509A7F39789F515AB8F92DDBCBD414D940E93", 16), + i = new l(e, t, n), + r = i.decodePointHex("0432C4AE2C1F1981195F9904466A39C9948FE30BBFF2660BE1715A4589334C74C7BC3736A2F4F6779C59BDCEE36B692153D0A9877CC62A474002DF32E52139F0A0"); + return { + curve: i, + G: r, + n: new f("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFF7203DF6B21C6052B53BBF40939D54123", 16) + } + } + + function y() { + var e = new f(v.bitLength(), h).mod(v.subtract(f.ONE)).add(f.ONE), + t = _(e.toString(16), 64), + n = m.multiply(e); + return { + privateKey: t, + publicKey: "04" + _(n.getX().toBigInteger().toString(16), 64) + _(n.getY().toBigInteger().toString(16), 64) + } + } + + function A(e) { + for (var t = (e = unescape(encodeURIComponent(e))).length, n = [], i = 0; i < t; i++) + n[i >>> 2] |= (255 & e.charCodeAt(i)) << 24 - i % 4 * 8; + for (var r = [], o = 0; o < t; o++) { + var a = n[o >>> 2] >>> 24 - o % 4 * 8 & 255; + r.push((a >>> 4).toString(16)), + r.push((15 & a).toString(16)) + } + return r.join("") + } + + function w(e) { + return Array.prototype.map.call(new Uint8Array(e), (function (e) { + return ("00" + e.toString(16)).slice(-2) + })).join("") + } + + function _(e, t) { + return e.length >= t ? e : new Array(t - e.length + 1).join("0") + e + } + + function x(e) { + for (var t = [], n = 0, i = 0; i < 2 * e.length; i += 2) + t[i >>> 3] |= parseInt(e[n], 10) << 24 - i % 8 * 4, + n++; + for (var r = [], o = 0; o < e.length; o++) { + var a = t[o >>> 2] >>> 24 - o % 4 * 8 & 255; + r.push((a >>> 4).toString(16)), + r.push((15 & a).toString(16)) + } + return r.join("") + } + + function S(e) { + for (var t = [], n = 0, i = 0; i < 2 * e.length; i += 2) + t[i >>> 3] |= parseInt(e[n], 10) << 24 - i % 8 * 4, + n++; + try { + for (var r = [], o = 0; o < e.length; o++) { + var a = t[o >>> 2] >>> 24 - o % 4 * 8 & 255; + r.push(String.fromCharCode(a)) + } + return decodeURIComponent(escape(r.join(""))) + } catch (e) { + throw new Error("Malformed UTF-8 data") + } + } + + function k(e) { + var t = [], + n = e.length; + n % 2 != 0 && (e = _(e, n + 1)), + n = e.length; + for (var i = 0; i < n; i += 2) + t.push(parseInt(e.substr(i, 2), 16)); + return t + } + + t.default = { + getGlobalCurve: b, + generateEcparam: g, + generateKeyPairHex: y, + parseUtf8StringToHex: A, + parseArrayBufferToHex: w, + leftPad: _, + arrayToHex: x, + arrayToUtf8: S, + hexToArray: k + } + }, + 'e04e': function (e, t, n) { + "use strict"; + n.r(t), + n.d(t, "encrypt", (function () { + return h + })), + n.d(t, "decrypt", (function () { + return d + })); + var i = [214, 144, 233, 254, 204, 225, 61, 183, 22, 182, 20, 194, 40, 251, 44, 5, 43, 103, 154, 118, 42, 190, 4, 195, 170, 68, 19, 38, 73, 134, 6, 153, 156, 66, 80, 244, 145, 239, 152, 122, 51, 84, 11, 67, 237, 207, 172, 98, 228, 179, 28, 169, 201, 8, 232, 149, 128, 223, 148, 250, 117, 143, 63, 166, 71, 7, 167, 252, 243, 115, 23, 186, 131, 89, 60, 25, 230, 133, 79, 168, 104, 107, 129, 178, 113, 100, 218, 139, 248, 235, 15, 75, 112, 86, 157, 53, 30, 36, 14, 94, 99, 88, 209, 162, 37, 34, 124, 59, 1, 33, 120, 135, 212, 0, 70, 87, 159, 211, 39, 82, 76, 54, 2, 231, 160, 196, 200, 158, 234, 191, 138, 210, 64, 199, 56, 181, 163, 247, 242, 206, 249, 97, 21, 161, 224, 174, 93, 164, 155, 52, 26, 85, 173, 147, 50, 48, 245, 140, 177, 227, 29, 246, 226, 46, 130, 102, 202, 96, 192, 41, 35, 171, 13, 83, 78, 111, 213, 219, 55, 69, 222, 253, 142, 47, 3, 255, 106, 114, 109, 108, 91, 81, 141, 27, 175, 146, 187, 221, 188, 127, 17, 217, 92, 65, 31, 16, 90, 216, 10, 193, 49, 136, 165, 205, 123, 189, 45, 116, 208, 18, 184, 229, 180, 176, 137, 105, 151, 74, 12, 150, 119, 126, 101, 185, 241, 9, 197, 110, 198, 132, 24, 240, 125, 236, 58, 220, 77, 32, 121, 238, 95, 62, 215, 203, 57, 72], + r = [462357, 472066609, 943670861, 1415275113, 1886879365, 2358483617, 2830087869, 3301692121, 3773296373, 4228057617, 404694573, 876298825, 1347903077, 1819507329, 2291111581, 2762715833, 3234320085, 3705924337, 4177462797, 337322537, 808926789, 1280531041, 1752135293, 2223739545, 2695343797, 3166948049, 3638552301, 4110090761, 269950501, 741554753, 1213159005, 1684763257]; + + function o(e, t) { + return e << t | e >>> 32 - t + } + + function a(e) { + return (255 & i[e >>> 24 & 255]) << 24 | (255 & i[e >>> 16 & 255]) << 16 | (255 & i[e >>> 8 & 255]) << 8 | 255 & i[255 & e] + } + + function s(e) { + return e ^ o(e, 2) ^ o(e, 10) ^ o(e, 18) ^ o(e, 24) + } + + function c(e) { + return e ^ o(e, 13) ^ o(e, 23) + } + + function l(e, t, n) { + for (var i, r, o = new Array(4), c = new Array(4), l = 0; l < 4; l++) + c[0] = 255 & e[0 + 4 * l], + c[1] = 255 & e[1 + 4 * l], + c[2] = 255 & e[2 + 4 * l], + c[3] = 255 & e[3 + 4 * l], + o[l] = c[0] << 24 | c[1] << 16 | c[2] << 8 | c[3]; + for (i = 0; i < 32; i += 4) + r = a(r = o[1] ^ o[2] ^ o[3] ^ n[i + 0]), + o[0] ^= s(r), + r = a(r = o[2] ^ o[3] ^ o[0] ^ n[i + 1]), + o[1] ^= s(r), + r = a(r = o[3] ^ o[0] ^ o[1] ^ n[i + 2]), + o[2] ^= s(r), + r = a(r = o[0] ^ o[1] ^ o[2] ^ n[i + 3]), + o[3] ^= s(r); + for (var u = 0; u < 16; u += 4) + t[u] = o[3 - u / 4] >>> 24 & 255, + t[u + 1] = o[3 - u / 4] >>> 16 & 255, + t[u + 2] = o[3 - u / 4] >>> 8 & 255, + t[u + 3] = 255 & o[3 - u / 4] + } + + function u(e, t, n) { + for (var i, o, s = new Array(4), l = new Array(4), u = 0; u < 4; u++) + l[0] = 255 & e[0 + 4 * u], + l[1] = 255 & e[1 + 4 * u], + l[2] = 255 & e[2 + 4 * u], + l[3] = 255 & e[3 + 4 * u], + s[u] = l[0] << 24 | l[1] << 16 | l[2] << 8 | l[3]; + for (s[0] ^= 2746333894, + s[1] ^= 1453994832, + s[2] ^= 1736282519, + s[3] ^= 2993693404, + i = 0; i < 32; i += 4) + o = a(o = s[1] ^ s[2] ^ s[3] ^ r[i + 0]), + t[i + 0] = s[0] ^= c(o), + o = a(o = s[2] ^ s[3] ^ s[0] ^ r[i + 1]), + t[i + 1] = s[1] ^= c(o), + o = a(o = s[3] ^ s[0] ^ s[1] ^ r[i + 2]), + t[i + 2] = s[2] ^= c(o), + o = a(o = s[0] ^ s[1] ^ s[2] ^ r[i + 3]), + t[i + 3] = s[3] ^= c(o); + if (0 === n) + for (i = 0; i < 16; i++) + o = t[i], + t[i] = t[31 - i], + t[31 - i] = o + } + + function f(e, t, n) { + var i = [], + r = 0, + o = new Array(32); + u(t, o, n); + new Array(16); + for (var a = new Array(16), s = e.length; s >= 16;) { + l(e.slice(r, r + 16), a, o); + for (var c = 0; c < 16; c++) + i[r + c] = a[c]; + s -= 16, + r += 16 + } + return i + } + + function h(e, t) { + return f(e, t, 1) + } + + function d(e, t) { + return f(e, t, 0) + } + + t.default = { + encrypt: h, + decrypt: d + } + }, + "63b6": function (e, t, n) { + var i = n("e53d"), + r = n("584a"), + o = n("d864"), + a = n("35e8"), + s = n("07e3"), + c = "prototype", + l = function (e, t, n) { + var u, f, h, d = e & l.F, + p = e & l.G, + m = e & l.S, + v = e & l.P, + b = e & l.B, + g = e & l.W, + y = p ? r : r[t] || (r[t] = {}), + A = y[c], + w = p ? i : m ? i[t] : (i[t] || {})[c]; + for (u in p && (n = t), + n) + (f = !d && w && void 0 !== w[u]) && s(y, u) || (h = f ? w[u] : n[u], + y[u] = p && "function" != typeof w[u] ? n[u] : b && f ? o(h, i) : g && w[u] == h ? function (e) { + var t = function (t, n, i) { + if (this instanceof e) { + switch (arguments.length) { + case 0: + return new e; + case 1: + return new e(t); + case 2: + return new e(t, n) + } + return new e(t, n, i) + } + return e.apply(this, arguments) + }; + return t[c] = e[c], + t + }(h) : v && "function" == typeof h ? o(Function.call, h) : h, + v && ((y.virtual || (y.virtual = {}))[u] = h, + e & l.R && A && !A[u] && a(A, u, h))) + }; + l.F = 1, + l.G = 2, + l.S = 4, + l.P = 8, + l.B = 16, + l.W = 32, + l.U = 64, + l.R = 128, + e.exports = l + }, + 'e53d': function (e, t) { + var n = e.exports = "undefined" != typeof window && window.Math == Math ? window : "undefined" != typeof self && self.Math == Math ? self : Function("return this")(); + "number" == typeof __g && (__g = n) + }, + "584a": function (e, t) { + var n = e.exports = { + version: "2.6.11" + }; + "number" == typeof __e && (__e = n) + }, + 'd864': function (e, t, n) { + var i = n("79aa"); + e.exports = function (e, t, n) { + if (i(e), + void 0 === t) + return e; + switch (n) { + case 1: + return function (n) { + return e.call(t, n) + }; + case 2: + return function (n, i) { + return e.call(t, n, i) + }; + case 3: + return function (n, i, r) { + return e.call(t, n, i, r) + } + } + return function () { + return e.apply(t, arguments) + } + } + }, + "79aa": function (e, t) { + e.exports = function (e) { + if ("function" != typeof e) + throw TypeError(e + " is not a function!"); + return e + } + }, + "35e8": function (e, t, n) { + var i = n("d9f6"), + r = n("aebd"); + e.exports = n("8e60") ? function (e, t, n) { + return i.f(e, t, r(1, n)) + } : + function (e, t, n) { + return e[t] = n, + e + } + }, + 'd9f6': function (e, t, n) { + var i = n("e4ae"), + r = n("794b"), + o = n("1bc3"), + a = Object.defineProperty; + t.f = n("8e60") ? Object.defineProperty : function (e, t, n) { + if (i(e), + t = o(t, !0), + i(n), + r) + try { + return a(e, t, n) + } catch (e) { + } + if ("get" in n || "set" in n) + throw TypeError("Accessors not supported!"); + return "value" in n && (e[t] = n.value), + e + } + }, + 'e4ae': function (e, t, n) { + var i = n("f772"); + e.exports = function (e) { + if (!i(e)) + throw TypeError(e + " is not an object!"); + return e + } + }, + 'f772': function (e, t) { + e.exports = function (e) { + return "object" == typeof e ? null !== e : "function" == typeof e + } + }, + "794b": function (e, t, n) { + e.exports = !n("8e60") && !n("294c")((function () { + return 7 != Object.defineProperty(n("1ec9")("div"), "a", { + get: function () { + return 7 + } + }).a + })) + }, + "8e60": function (e, t, n) { + e.exports = !n("294c")((function () { + return 7 != Object.defineProperty({}, "a", { + get: function () { + return 7 + } + }).a + })) + }, + "294c": function (e, t) { + e.exports = function (e) { + try { + return !!e() + } catch (e) { + return !0 + } + } + }, + "1bc3": function (e, t, n) { + var i = n("f772"); + e.exports = function (e, t) { + if (!i(e)) + return e; + var n, r; + if (t && "function" == typeof (n = e.toString) && !i(r = n.call(e))) + return r; + if ("function" == typeof (n = e.valueOf) && !i(r = n.call(e))) + return r; + if (!t && "function" == typeof (n = e.toString) && !i(r = n.call(e))) + return r; + throw TypeError("Can't convert object to primitive value") + } + }, + 'aebd': function (e, t) { + e.exports = function (e, t) { + return { + enumerable: !(1 & e), + configurable: !(2 & e), + writable: !(4 & e), + value: t + } + } + }, + "07e3": function (e, t) { + var n = {}.hasOwnProperty; + e.exports = function (e, t) { + return n.call(e, t) + } + }, + 'd225': function (e, t, n) { + "use strict"; + + function i(e, t) { + if (!(e instanceof t)) + throw new TypeError("Cannot call a class as a function") + } + + n.d(t, "a", (function () { + return i + })) + }, + 'b0b4': function (e, t, n) { + "use strict"; + n.d(t, "a", (function () { + return a + })); + var i = n("85f2"), + r = n.n(i); + + function o(e, t) { + for (var n = 0; n < t.length; n++) { + var i = t[n]; + i.enumerable = i.enumerable || !1, + i.configurable = !0, + "value" in i && (i.writable = !0), + r()(e, i.key, i) + } + } + + function a(e, t, n) { + return t && o(e.prototype, t), + n && o(e, n), + e + } + }, + "85f2": function (e, t, n) { + e.exports = n("454f") + }, + "454f": function (e, t, n) { + n("46a7"); + var i = n("584a").Object; + e.exports = function (e, t, n) { + return i.defineProperty(e, t, n) + } + }, + "46a7": function (e, t, n) { + var i = n("63b6"); + i(i.S + i.F * !n("8e60"), "Object", { + defineProperty: n("d9f6").f + }) + }, + 'b639': function (e, t, n) { + "use strict"; + (function (e) { + var i = n("1fb5"), + r = n("9152"), + o = n("e3db"); + + function a() { + return c.TYPED_ARRAY_SUPPORT ? 2147483647 : 1073741823 + } + + function s(e, t) { + if (a() < t) + throw new RangeError("Invalid typed array length"); + return c.TYPED_ARRAY_SUPPORT ? (e = new Uint8Array(t)).__proto__ = c.prototype : (null === e && (e = new c(t)), + e.length = t), + e + } + + function c(e, t, n) { + if (!(c.TYPED_ARRAY_SUPPORT || this instanceof c)) + return new c(e, t, n); + if ("number" == typeof e) { + if ("string" == typeof t) + throw new Error("If encoding is specified then the first argument must be a string"); + return f(this, e) + } + return l(this, e, t, n) + } + + function l(e, t, n, i) { + if ("number" == typeof t) + throw new TypeError('"value" argument must not be a number'); + return "undefined" != typeof ArrayBuffer && t instanceof ArrayBuffer ? function (e, t, n, i) { + if (t.byteLength, + n < 0 || t.byteLength < n) + throw new RangeError("'offset' is out of bounds"); + if (t.byteLength < n + (i || 0)) + throw new RangeError("'length' is out of bounds"); + return t = void 0 === n && void 0 === i ? new Uint8Array(t) : void 0 === i ? new Uint8Array(t, n) : new Uint8Array(t, n, i), + c.TYPED_ARRAY_SUPPORT ? (e = t).__proto__ = c.prototype : e = h(e, t), + e + }(e, t, n, i) : "string" == typeof t ? function (e, t, n) { + if ("string" == typeof n && "" !== n || (n = "utf8"), !c.isEncoding(n)) + throw new TypeError('"encoding" must be a valid string encoding'); + var i = 0 | p(t, n), + r = (e = s(e, i)).write(t, n); + return r !== i && (e = e.slice(0, r)), + e + }(e, t, n) : function (e, t) { + if (c.isBuffer(t)) { + var n = 0 | d(t.length); + return 0 === (e = s(e, n)).length || t.copy(e, 0, 0, n), + e + } + if (t) { + if ("undefined" != typeof ArrayBuffer && t.buffer instanceof ArrayBuffer || "length" in t) + return "number" != typeof t.length || function (e) { + return e != e + }(t.length) ? s(e, 0) : h(e, t); + if ("Buffer" === t.type && o(t.data)) + return h(e, t.data) + } + throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.") + }(e, t) + } + + function u(e) { + if ("number" != typeof e) + throw new TypeError('"size" argument must be a number'); + if (e < 0) + throw new RangeError('"size" argument must not be negative') + } + + function f(e, t) { + if (u(t), + e = s(e, t < 0 ? 0 : 0 | d(t)), !c.TYPED_ARRAY_SUPPORT) + for (var n = 0; n < t; ++n) + e[n] = 0; + return e + } + + function h(e, t) { + var n = t.length < 0 ? 0 : 0 | d(t.length); + e = s(e, n); + for (var i = 0; i < n; i += 1) + e[i] = 255 & t[i]; + return e + } + + function d(e) { + if (e >= a()) + throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x" + a().toString(16) + " bytes"); + return 0 | e + } + + function p(e, t) { + if (c.isBuffer(e)) + return e.length; + if ("undefined" != typeof ArrayBuffer && "function" == typeof ArrayBuffer.isView && (ArrayBuffer.isView(e) || e instanceof ArrayBuffer)) + return e.byteLength; + "string" != typeof e && (e = "" + e); + var n = e.length; + if (0 === n) + return 0; + for (var i = !1; ;) + switch (t) { + case "ascii": + case "latin1": + case "binary": + return n; + case "utf8": + case "utf-8": + case void 0: + return V(e).length; + case "ucs2": + case "ucs-2": + case "utf16le": + case "utf-16le": + return 2 * n; + case "hex": + return n >>> 1; + case "base64": + return z(e).length; + default: + if (i) + return V(e).length; + t = ("" + t).toLowerCase(), + i = !0 + } + } + + function m(e, t, n) { + var i = !1; + if ((void 0 === t || t < 0) && (t = 0), + t > this.length) + return ""; + if ((void 0 === n || n > this.length) && (n = this.length), + n <= 0) + return ""; + if ((n >>>= 0) <= (t >>>= 0)) + return ""; + for (e || (e = "utf8"); ;) + switch (e) { + case "hex": + return M(this, t, n); + case "utf8": + case "utf-8": + return C(this, t, n); + case "ascii": + return E(this, t, n); + case "latin1": + case "binary": + return O(this, t, n); + case "base64": + return k(this, t, n); + case "ucs2": + case "ucs-2": + case "utf16le": + case "utf-16le": + return T(this, t, n); + default: + if (i) + throw new TypeError("Unknown encoding: " + e); + e = (e + "").toLowerCase(), + i = !0 + } + } + + function v(e, t, n) { + var i = e[t]; + e[t] = e[n], + e[n] = i + } + + function b(e, t, n, i, r) { + if (0 === e.length) + return -1; + if ("string" == typeof n ? (i = n, + n = 0) : n > 2147483647 ? n = 2147483647 : n < -2147483648 && (n = -2147483648), + n = +n, + isNaN(n) && (n = r ? 0 : e.length - 1), + n < 0 && (n = e.length + n), + n >= e.length) { + if (r) + return -1; + n = e.length - 1 + } else if (n < 0) { + if (!r) + return -1; + n = 0 + } + if ("string" == typeof t && (t = c.from(t, i)), + c.isBuffer(t)) + return 0 === t.length ? -1 : g(e, t, n, i, r); + if ("number" == typeof t) + return t &= 255, + c.TYPED_ARRAY_SUPPORT && "function" == typeof Uint8Array.prototype.indexOf ? r ? Uint8Array.prototype.indexOf.call(e, t, n) : Uint8Array.prototype.lastIndexOf.call(e, t, n) : g(e, [t], n, i, r); + throw new TypeError("val must be string, number or Buffer") + } + + function g(e, t, n, i, r) { + var o, a = 1, + s = e.length, + c = t.length; + if (void 0 !== i && ("ucs2" === (i = String(i).toLowerCase()) || "ucs-2" === i || "utf16le" === i || "utf-16le" === i)) { + if (e.length < 2 || t.length < 2) + return -1; + a = 2, + s /= 2, + c /= 2, + n /= 2 + } + + function l(e, t) { + return 1 === a ? e[t] : e.readUInt16BE(t * a) + } + + if (r) { + var u = -1; + for (o = n; o < s; o++) + if (l(e, o) === l(t, -1 === u ? 0 : o - u)) { + if (-1 === u && (u = o), + o - u + 1 === c) + return u * a + } else + -1 !== u && (o -= o - u), + u = -1 + } else + for (n + c > s && (n = s - c), + o = n; o >= 0; o--) { + for (var f = !0, h = 0; h < c; h++) + if (l(e, o + h) !== l(t, h)) { + f = !1; + break + } + if (f) + return o + } + return -1 + } + + function y(e, t, n, i) { + n = Number(n) || 0; + var r = e.length - n; + i ? (i = Number(i)) > r && (i = r) : i = r; + var o = t.length; + if (o % 2 != 0) + throw new TypeError("Invalid hex string"); + i > o / 2 && (i = o / 2); + for (var a = 0; a < i; ++a) { + var s = parseInt(t.substr(2 * a, 2), 16); + if (isNaN(s)) + return a; + e[n + a] = s + } + return a + } + + function A(e, t, n, i) { + return H(V(t, e.length - n), e, n, i) + } + + function w(e, t, n, i) { + return H(function (e) { + for (var t = [], n = 0; n < e.length; ++n) + t.push(255 & e.charCodeAt(n)); + return t + }(t), e, n, i) + } + + function _(e, t, n, i) { + return w(e, t, n, i) + } + + function x(e, t, n, i) { + return H(z(t), e, n, i) + } + + function S(e, t, n, i) { + return H(function (e, t) { + for (var n, i, r, o = [], a = 0; a < e.length && !((t -= 2) < 0); ++a) + n = e.charCodeAt(a), + i = n >> 8, + r = n % 256, + o.push(r), + o.push(i); + return o + }(t, e.length - n), e, n, i) + } + + function k(e, t, n) { + return 0 === t && n === e.length ? i.fromByteArray(e) : i.fromByteArray(e.slice(t, n)) + } + + function C(e, t, n) { + n = Math.min(e.length, n); + for (var i = [], r = t; r < n;) { + var o, a, s, c, l = e[r], + u = null, + f = l > 239 ? 4 : l > 223 ? 3 : l > 191 ? 2 : 1; + if (r + f <= n) + switch (f) { + case 1: + l < 128 && (u = l); + break; + case 2: + 128 == (192 & (o = e[r + 1])) && ((c = (31 & l) << 6 | 63 & o) > 127 && (u = c)); + break; + case 3: + o = e[r + 1], + a = e[r + 2], + 128 == (192 & o) && 128 == (192 & a) && ((c = (15 & l) << 12 | (63 & o) << 6 | 63 & a) > 2047 && (c < 55296 || c > 57343) && (u = c)); + break; + case 4: + o = e[r + 1], + a = e[r + 2], + s = e[r + 3], + 128 == (192 & o) && 128 == (192 & a) && 128 == (192 & s) && ((c = (15 & l) << 18 | (63 & o) << 12 | (63 & a) << 6 | 63 & s) > 65535 && c < 1114112 && (u = c)) + } + null === u ? (u = 65533, + f = 1) : u > 65535 && (u -= 65536, + i.push(u >>> 10 & 1023 | 55296), + u = 56320 | 1023 & u), + i.push(u), + r += f + } + return function (e) { + var t = e.length; + if (t <= 4096) + return String.fromCharCode.apply(String, e); + var n = "", + i = 0; + for (; i < t;) + n += String.fromCharCode.apply(String, e.slice(i, i += 4096)); + return n + }(i) + } + + t.Buffer = c, + t.SlowBuffer = function (e) { + return +e != e && (e = 0), + c.alloc(+e) + }, + t.INSPECT_MAX_BYTES = 50, + c.TYPED_ARRAY_SUPPORT = void 0 !== e.TYPED_ARRAY_SUPPORT ? e.TYPED_ARRAY_SUPPORT : function () { + try { + var e = new Uint8Array(1); + return e.__proto__ = { + __proto__: Uint8Array.prototype, + foo: function () { + return 42 + } + }, + 42 === e.foo() && "function" == typeof e.subarray && 0 === e.subarray(1, 1).byteLength + } catch (e) { + return !1 + } + }(), + t.kMaxLength = a(), + c.poolSize = 8192, + c._augment = function (e) { + return e.__proto__ = c.prototype, + e + }, + c.from = function (e, t, n) { + return l(null, e, t, n) + }, + c.TYPED_ARRAY_SUPPORT && (c.prototype.__proto__ = Uint8Array.prototype, + c.__proto__ = Uint8Array, + "undefined" != typeof Symbol && Symbol.species && c[Symbol.species] === c && Object.defineProperty(c, Symbol.species, { + value: null, + configurable: !0 + })), + c.alloc = function (e, t, n) { + return function (e, t, n, i) { + return u(t), + t <= 0 ? s(e, t) : void 0 !== n ? "string" == typeof i ? s(e, t).fill(n, i) : s(e, t).fill(n) : s(e, t) + }(null, e, t, n) + }, + c.allocUnsafe = function (e) { + return f(null, e) + }, + c.allocUnsafeSlow = function (e) { + return f(null, e) + }, + c.isBuffer = function (e) { + return !(null == e || !e._isBuffer) + }, + c.compare = function (e, t) { + if (!c.isBuffer(e) || !c.isBuffer(t)) + throw new TypeError("Arguments must be Buffers"); + if (e === t) + return 0; + for (var n = e.length, i = t.length, r = 0, o = Math.min(n, i); r < o; ++r) + if (e[r] !== t[r]) { + n = e[r], + i = t[r]; + break + } + return n < i ? -1 : i < n ? 1 : 0 + }, + c.isEncoding = function (e) { + switch (String(e).toLowerCase()) { + case "hex": + case "utf8": + case "utf-8": + case "ascii": + case "latin1": + case "binary": + case "base64": + case "ucs2": + case "ucs-2": + case "utf16le": + case "utf-16le": + return !0; + default: + return !1 + } + }, + c.concat = function (e, t) { + if (!o(e)) + throw new TypeError('"list" argument must be an Array of Buffers'); + if (0 === e.length) + return c.alloc(0); + var n; + if (void 0 === t) + for (t = 0, + n = 0; n < e.length; ++n) + t += e[n].length; + var i = c.allocUnsafe(t), + r = 0; + for (n = 0; n < e.length; ++n) { + var a = e[n]; + if (!c.isBuffer(a)) + throw new TypeError('"list" argument must be an Array of Buffers'); + a.copy(i, r), + r += a.length + } + return i + }, + c.byteLength = p, + c.prototype._isBuffer = !0, + c.prototype.swap16 = function () { + var e = this.length; + if (e % 2 != 0) + throw new RangeError("Buffer size must be a multiple of 16-bits"); + for (var t = 0; t < e; t += 2) + v(this, t, t + 1); + return this + }, + c.prototype.swap32 = function () { + var e = this.length; + if (e % 4 != 0) + throw new RangeError("Buffer size must be a multiple of 32-bits"); + for (var t = 0; t < e; t += 4) + v(this, t, t + 3), + v(this, t + 1, t + 2); + return this + }, + c.prototype.swap64 = function () { + var e = this.length; + if (e % 8 != 0) + throw new RangeError("Buffer size must be a multiple of 64-bits"); + for (var t = 0; t < e; t += 8) + v(this, t, t + 7), + v(this, t + 1, t + 6), + v(this, t + 2, t + 5), + v(this, t + 3, t + 4); + return this + }, + c.prototype.toString = function () { + var e = 0 | this.length; + return 0 === e ? "" : 0 === arguments.length ? C(this, 0, e) : m.apply(this, arguments) + }, + c.prototype.equals = function (e) { + if (!c.isBuffer(e)) + throw new TypeError("Argument must be a Buffer"); + return this === e || 0 === c.compare(this, e) + }, + c.prototype.inspect = function () { + var e = "", + n = t.INSPECT_MAX_BYTES; + return this.length > 0 && (e = this.toString("hex", 0, n).match(/.{2}/g).join(" "), + this.length > n && (e += " ... ")), + "" + }, + c.prototype.compare = function (e, t, n, i, r) { + if (!c.isBuffer(e)) + throw new TypeError("Argument must be a Buffer"); + if (void 0 === t && (t = 0), + void 0 === n && (n = e ? e.length : 0), + void 0 === i && (i = 0), + void 0 === r && (r = this.length), + t < 0 || n > e.length || i < 0 || r > this.length) + throw new RangeError("out of range index"); + if (i >= r && t >= n) + return 0; + if (i >= r) + return -1; + if (t >= n) + return 1; + if (this === e) + return 0; + for (var o = (r >>>= 0) - (i >>>= 0), a = (n >>>= 0) - (t >>>= 0), s = Math.min(o, a), l = this.slice(i, r), u = e.slice(t, n), f = 0; f < s; ++f) + if (l[f] !== u[f]) { + o = l[f], + a = u[f]; + break + } + return o < a ? -1 : a < o ? 1 : 0 + }, + c.prototype.includes = function (e, t, n) { + return -1 !== this.indexOf(e, t, n) + }, + c.prototype.indexOf = function (e, t, n) { + return b(this, e, t, n, !0) + }, + c.prototype.lastIndexOf = function (e, t, n) { + return b(this, e, t, n, !1) + }, + c.prototype.write = function (e, t, n, i) { + if (void 0 === t) + i = "utf8", + n = this.length, + t = 0; + else if (void 0 === n && "string" == typeof t) + i = t, + n = this.length, + t = 0; + else { + if (!isFinite(t)) + throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported"); + t |= 0, + isFinite(n) ? (n |= 0, + void 0 === i && (i = "utf8")) : (i = n, + n = void 0) + } + var r = this.length - t; + if ((void 0 === n || n > r) && (n = r), + e.length > 0 && (n < 0 || t < 0) || t > this.length) + throw new RangeError("Attempt to write outside buffer bounds"); + i || (i = "utf8"); + for (var o = !1; ;) + switch (i) { + case "hex": + return y(this, e, t, n); + case "utf8": + case "utf-8": + return A(this, e, t, n); + case "ascii": + return w(this, e, t, n); + case "latin1": + case "binary": + return _(this, e, t, n); + case "base64": + return x(this, e, t, n); + case "ucs2": + case "ucs-2": + case "utf16le": + case "utf-16le": + return S(this, e, t, n); + default: + if (o) + throw new TypeError("Unknown encoding: " + i); + i = ("" + i).toLowerCase(), + o = !0 + } + }, + c.prototype.toJSON = function () { + return { + type: "Buffer", + data: Array.prototype.slice.call(this._arr || this, 0) + } + }; + + function E(e, t, n) { + var i = ""; + n = Math.min(e.length, n); + for (var r = t; r < n; ++r) + i += String.fromCharCode(127 & e[r]); + return i + } + + function O(e, t, n) { + var i = ""; + n = Math.min(e.length, n); + for (var r = t; r < n; ++r) + i += String.fromCharCode(e[r]); + return i + } + + function M(e, t, n) { + var i = e.length; + (!t || t < 0) && (t = 0), + (!n || n < 0 || n > i) && (n = i); + for (var r = "", o = t; o < n; ++o) + r += L(e[o]); + return r + } + + function T(e, t, n) { + for (var i = e.slice(t, n), r = "", o = 0; o < i.length; o += 2) + r += String.fromCharCode(i[o] + 256 * i[o + 1]); + return r + } + + function D(e, t, n) { + if (e % 1 != 0 || e < 0) + throw new RangeError("offset is not uint"); + if (e + t > n) + throw new RangeError("Trying to access beyond buffer length") + } + + function P(e, t, n, i, r, o) { + if (!c.isBuffer(e)) + throw new TypeError('"buffer" argument must be a Buffer instance'); + if (t > r || t < o) + throw new RangeError('"value" argument is out of bounds'); + if (n + i > e.length) + throw new RangeError("Index out of range") + } + + function I(e, t, n, i) { + t < 0 && (t = 65535 + t + 1); + for (var r = 0, o = Math.min(e.length - n, 2); r < o; ++r) + e[n + r] = (t & 255 << 8 * (i ? r : 1 - r)) >>> 8 * (i ? r : 1 - r) + } + + function j(e, t, n, i) { + t < 0 && (t = 4294967295 + t + 1); + for (var r = 0, o = Math.min(e.length - n, 4); r < o; ++r) + e[n + r] = t >>> 8 * (i ? r : 3 - r) & 255 + } + + function N(e, t, n, i, r, o) { + if (n + i > e.length) + throw new RangeError("Index out of range"); + if (n < 0) + throw new RangeError("Index out of range") + } + + function B(e, t, n, i, o) { + return o || N(e, 0, n, 4), + r.write(e, t, n, i, 23, 4), + n + 4 + } + + function R(e, t, n, i, o) { + return o || N(e, 0, n, 8), + r.write(e, t, n, i, 52, 8), + n + 8 + } + + c.prototype.slice = function (e, t) { + var n, i = this.length; + if ((e = ~~e) < 0 ? (e += i) < 0 && (e = 0) : e > i && (e = i), + (t = void 0 === t ? i : ~~t) < 0 ? (t += i) < 0 && (t = 0) : t > i && (t = i), + t < e && (t = e), + c.TYPED_ARRAY_SUPPORT) + (n = this.subarray(e, t)).__proto__ = c.prototype; + else { + var r = t - e; + n = new c(r, void 0); + for (var o = 0; o < r; ++o) + n[o] = this[o + e] + } + return n + }, + c.prototype.readUIntLE = function (e, t, n) { + e |= 0, + t |= 0, + n || D(e, t, this.length); + for (var i = this[e], r = 1, o = 0; ++o < t && (r *= 256);) + i += this[e + o] * r; + return i + }, + c.prototype.readUIntBE = function (e, t, n) { + e |= 0, + t |= 0, + n || D(e, t, this.length); + for (var i = this[e + --t], r = 1; t > 0 && (r *= 256);) + i += this[e + --t] * r; + return i + }, + c.prototype.readUInt8 = function (e, t) { + return t || D(e, 1, this.length), + this[e] + }, + c.prototype.readUInt16LE = function (e, t) { + return t || D(e, 2, this.length), + this[e] | this[e + 1] << 8 + }, + c.prototype.readUInt16BE = function (e, t) { + return t || D(e, 2, this.length), + this[e] << 8 | this[e + 1] + }, + c.prototype.readUInt32LE = function (e, t) { + return t || D(e, 4, this.length), + (this[e] | this[e + 1] << 8 | this[e + 2] << 16) + 16777216 * this[e + 3] + }, + c.prototype.readUInt32BE = function (e, t) { + return t || D(e, 4, this.length), + 16777216 * this[e] + (this[e + 1] << 16 | this[e + 2] << 8 | this[e + 3]) + }, + c.prototype.readIntLE = function (e, t, n) { + e |= 0, + t |= 0, + n || D(e, t, this.length); + for (var i = this[e], r = 1, o = 0; ++o < t && (r *= 256);) + i += this[e + o] * r; + return i >= (r *= 128) && (i -= Math.pow(2, 8 * t)), + i + }, + c.prototype.readIntBE = function (e, t, n) { + e |= 0, + t |= 0, + n || D(e, t, this.length); + for (var i = t, r = 1, o = this[e + --i]; i > 0 && (r *= 256);) + o += this[e + --i] * r; + return o >= (r *= 128) && (o -= Math.pow(2, 8 * t)), + o + }, + c.prototype.readInt8 = function (e, t) { + return t || D(e, 1, this.length), + 128 & this[e] ? -1 * (255 - this[e] + 1) : this[e] + }, + c.prototype.readInt16LE = function (e, t) { + t || D(e, 2, this.length); + var n = this[e] | this[e + 1] << 8; + return 32768 & n ? 4294901760 | n : n + }, + c.prototype.readInt16BE = function (e, t) { + t || D(e, 2, this.length); + var n = this[e + 1] | this[e] << 8; + return 32768 & n ? 4294901760 | n : n + }, + c.prototype.readInt32LE = function (e, t) { + return t || D(e, 4, this.length), + this[e] | this[e + 1] << 8 | this[e + 2] << 16 | this[e + 3] << 24 + }, + c.prototype.readInt32BE = function (e, t) { + return t || D(e, 4, this.length), + this[e] << 24 | this[e + 1] << 16 | this[e + 2] << 8 | this[e + 3] + }, + c.prototype.readFloatLE = function (e, t) { + return t || D(e, 4, this.length), + r.read(this, e, !0, 23, 4) + }, + c.prototype.readFloatBE = function (e, t) { + return t || D(e, 4, this.length), + r.read(this, e, !1, 23, 4) + }, + c.prototype.readDoubleLE = function (e, t) { + return t || D(e, 8, this.length), + r.read(this, e, !0, 52, 8) + }, + c.prototype.readDoubleBE = function (e, t) { + return t || D(e, 8, this.length), + r.read(this, e, !1, 52, 8) + }, + c.prototype.writeUIntLE = function (e, t, n, i) { + (e = +e, + t |= 0, + n |= 0, + i) || P(this, e, t, n, Math.pow(2, 8 * n) - 1, 0); + var r = 1, + o = 0; + for (this[t] = 255 & e; ++o < n && (r *= 256);) + this[t + o] = e / r & 255; + return t + n + }, + c.prototype.writeUIntBE = function (e, t, n, i) { + (e = +e, + t |= 0, + n |= 0, + i) || P(this, e, t, n, Math.pow(2, 8 * n) - 1, 0); + var r = n - 1, + o = 1; + for (this[t + r] = 255 & e; --r >= 0 && (o *= 256);) + this[t + r] = e / o & 255; + return t + n + }, + c.prototype.writeUInt8 = function (e, t, n) { + return e = +e, + t |= 0, + n || P(this, e, t, 1, 255, 0), + c.TYPED_ARRAY_SUPPORT || (e = Math.floor(e)), + this[t] = 255 & e, + t + 1 + }, + c.prototype.writeUInt16LE = function (e, t, n) { + return e = +e, + t |= 0, + n || P(this, e, t, 2, 65535, 0), + c.TYPED_ARRAY_SUPPORT ? (this[t] = 255 & e, + this[t + 1] = e >>> 8) : I(this, e, t, !0), + t + 2 + }, + c.prototype.writeUInt16BE = function (e, t, n) { + return e = +e, + t |= 0, + n || P(this, e, t, 2, 65535, 0), + c.TYPED_ARRAY_SUPPORT ? (this[t] = e >>> 8, + this[t + 1] = 255 & e) : I(this, e, t, !1), + t + 2 + }, + c.prototype.writeUInt32LE = function (e, t, n) { + return e = +e, + t |= 0, + n || P(this, e, t, 4, 4294967295, 0), + c.TYPED_ARRAY_SUPPORT ? (this[t + 3] = e >>> 24, + this[t + 2] = e >>> 16, + this[t + 1] = e >>> 8, + this[t] = 255 & e) : j(this, e, t, !0), + t + 4 + }, + c.prototype.writeUInt32BE = function (e, t, n) { + return e = +e, + t |= 0, + n || P(this, e, t, 4, 4294967295, 0), + c.TYPED_ARRAY_SUPPORT ? (this[t] = e >>> 24, + this[t + 1] = e >>> 16, + this[t + 2] = e >>> 8, + this[t + 3] = 255 & e) : j(this, e, t, !1), + t + 4 + }, + c.prototype.writeIntLE = function (e, t, n, i) { + if (e = +e, + t |= 0, !i) { + var r = Math.pow(2, 8 * n - 1); + P(this, e, t, n, r - 1, -r) + } + var o = 0, + a = 1, + s = 0; + for (this[t] = 255 & e; ++o < n && (a *= 256);) + e < 0 && 0 === s && 0 !== this[t + o - 1] && (s = 1), + this[t + o] = (e / a >> 0) - s & 255; + return t + n + }, + c.prototype.writeIntBE = function (e, t, n, i) { + if (e = +e, + t |= 0, !i) { + var r = Math.pow(2, 8 * n - 1); + P(this, e, t, n, r - 1, -r) + } + var o = n - 1, + a = 1, + s = 0; + for (this[t + o] = 255 & e; --o >= 0 && (a *= 256);) + e < 0 && 0 === s && 0 !== this[t + o + 1] && (s = 1), + this[t + o] = (e / a >> 0) - s & 255; + return t + n + }, + c.prototype.writeInt8 = function (e, t, n) { + return e = +e, + t |= 0, + n || P(this, e, t, 1, 127, -128), + c.TYPED_ARRAY_SUPPORT || (e = Math.floor(e)), + e < 0 && (e = 255 + e + 1), + this[t] = 255 & e, + t + 1 + }, + c.prototype.writeInt16LE = function (e, t, n) { + return e = +e, + t |= 0, + n || P(this, e, t, 2, 32767, -32768), + c.TYPED_ARRAY_SUPPORT ? (this[t] = 255 & e, + this[t + 1] = e >>> 8) : I(this, e, t, !0), + t + 2 + }, + c.prototype.writeInt16BE = function (e, t, n) { + return e = +e, + t |= 0, + n || P(this, e, t, 2, 32767, -32768), + c.TYPED_ARRAY_SUPPORT ? (this[t] = e >>> 8, + this[t + 1] = 255 & e) : I(this, e, t, !1), + t + 2 + }, + c.prototype.writeInt32LE = function (e, t, n) { + return e = +e, + t |= 0, + n || P(this, e, t, 4, 2147483647, -2147483648), + c.TYPED_ARRAY_SUPPORT ? (this[t] = 255 & e, + this[t + 1] = e >>> 8, + this[t + 2] = e >>> 16, + this[t + 3] = e >>> 24) : j(this, e, t, !0), + t + 4 + }, + c.prototype.writeInt32BE = function (e, t, n) { + return e = +e, + t |= 0, + n || P(this, e, t, 4, 2147483647, -2147483648), + e < 0 && (e = 4294967295 + e + 1), + c.TYPED_ARRAY_SUPPORT ? (this[t] = e >>> 24, + this[t + 1] = e >>> 16, + this[t + 2] = e >>> 8, + this[t + 3] = 255 & e) : j(this, e, t, !1), + t + 4 + }, + c.prototype.writeFloatLE = function (e, t, n) { + return B(this, e, t, !0, n) + }, + c.prototype.writeFloatBE = function (e, t, n) { + return B(this, e, t, !1, n) + }, + c.prototype.writeDoubleLE = function (e, t, n) { + return R(this, e, t, !0, n) + }, + c.prototype.writeDoubleBE = function (e, t, n) { + return R(this, e, t, !1, n) + }, + c.prototype.copy = function (e, t, n, i) { + if (n || (n = 0), + i || 0 === i || (i = this.length), + t >= e.length && (t = e.length), + t || (t = 0), + i > 0 && i < n && (i = n), + i === n) + return 0; + if (0 === e.length || 0 === this.length) + return 0; + if (t < 0) + throw new RangeError("targetStart out of bounds"); + if (n < 0 || n >= this.length) + throw new RangeError("sourceStart out of bounds"); + if (i < 0) + throw new RangeError("sourceEnd out of bounds"); + i > this.length && (i = this.length), + e.length - t < i - n && (i = e.length - t + n); + var r, o = i - n; + if (this === e && n < t && t < i) + for (r = o - 1; r >= 0; --r) + e[r + t] = this[r + n]; + else if (o < 1e3 || !c.TYPED_ARRAY_SUPPORT) + for (r = 0; r < o; ++r) + e[r + t] = this[r + n]; + else + Uint8Array.prototype.set.call(e, this.subarray(n, n + o), t); + return o + }, + c.prototype.fill = function (e, t, n, i) { + if ("string" == typeof e) { + if ("string" == typeof t ? (i = t, + t = 0, + n = this.length) : "string" == typeof n && (i = n, + n = this.length), + 1 === e.length) { + var r = e.charCodeAt(0); + r < 256 && (e = r) + } + if (void 0 !== i && "string" != typeof i) + throw new TypeError("encoding must be a string"); + if ("string" == typeof i && !c.isEncoding(i)) + throw new TypeError("Unknown encoding: " + i) + } else + "number" == typeof e && (e &= 255); + if (t < 0 || this.length < t || this.length < n) + throw new RangeError("Out of range index"); + if (n <= t) + return this; + var o; + if (t >>>= 0, + n = void 0 === n ? this.length : n >>> 0, + e || (e = 0), + "number" == typeof e) + for (o = t; o < n; ++o) + this[o] = e; + else { + var a = c.isBuffer(e) ? e : V(new c(e, i).toString()), + s = a.length; + for (o = 0; o < n - t; ++o) + this[o + t] = a[o % s] + } + return this + }; + var F = /[^+\/0-9A-Za-z-_]/g; + + function L(e) { + return e < 16 ? "0" + e.toString(16) : e.toString(16) + } + + function V(e, t) { + var n; + t = t || 1 / 0; + for (var i = e.length, r = null, o = [], a = 0; a < i; ++a) { + if ((n = e.charCodeAt(a)) > 55295 && n < 57344) { + if (!r) { + if (n > 56319) { + (t -= 3) > -1 && o.push(239, 191, 189); + continue + } + if (a + 1 === i) { + (t -= 3) > -1 && o.push(239, 191, 189); + continue + } + r = n; + continue + } + if (n < 56320) { + (t -= 3) > -1 && o.push(239, 191, 189), + r = n; + continue + } + n = 65536 + (r - 55296 << 10 | n - 56320) + } else + r && (t -= 3) > -1 && o.push(239, 191, 189); + if (r = null, + n < 128) { + if ((t -= 1) < 0) + break; + o.push(n) + } else if (n < 2048) { + if ((t -= 2) < 0) + break; + o.push(n >> 6 | 192, 63 & n | 128) + } else if (n < 65536) { + if ((t -= 3) < 0) + break; + o.push(n >> 12 | 224, n >> 6 & 63 | 128, 63 & n | 128) + } else { + if (!(n < 1114112)) + throw new Error("Invalid code point"); + if ((t -= 4) < 0) + break; + o.push(n >> 18 | 240, n >> 12 & 63 | 128, n >> 6 & 63 | 128, 63 & n | 128) + } + } + return o + } + + function z(e) { + return i.toByteArray(function (e) { + if ((e = function (e) { + return e.trim ? e.trim() : e.replace(/^\s+|\s+$/g, "") + }(e).replace(F, "")).length < 2) + return ""; + for (; e.length % 4 != 0;) + e += "="; + return e + }(e)) + } + + function H(e, t, n, i) { + for (var r = 0; r < i && !(r + n >= t.length || r >= e.length); ++r) + t[r + n] = e[r]; + return r + } + }).call(this, n("c8ba")) + }, + 'c8ba': function (e, t) { + var n; + n = function () { + return this + }(); + try { + n = n || new Function("return this")() + } catch (e) { + "object" == typeof window && (n = window) + } + e.exports = n + }, + "1fb5": function (e, t, n) { + "use strict"; + t.byteLength = function (e) { + var t = l(e), + n = t[0], + i = t[1]; + return 3 * (n + i) / 4 - i + }, + t.toByteArray = function (e) { + var t, n, i = l(e), + a = i[0], + s = i[1], + c = new o(function (e, t, n) { + return 3 * (t + n) / 4 - n + }(0, a, s)), + u = 0, + f = s > 0 ? a - 4 : a; + for (n = 0; n < f; n += 4) + t = r[e.charCodeAt(n)] << 18 | r[e.charCodeAt(n + 1)] << 12 | r[e.charCodeAt(n + 2)] << 6 | r[e.charCodeAt(n + 3)], + c[u++] = t >> 16 & 255, + c[u++] = t >> 8 & 255, + c[u++] = 255 & t; + return 2 === s && (t = r[e.charCodeAt(n)] << 2 | r[e.charCodeAt(n + 1)] >> 4, + c[u++] = 255 & t), + 1 === s && (t = r[e.charCodeAt(n)] << 10 | r[e.charCodeAt(n + 1)] << 4 | r[e.charCodeAt(n + 2)] >> 2, + c[u++] = t >> 8 & 255, + c[u++] = 255 & t), + c + }, + t.fromByteArray = function (e) { + for (var t, n = e.length, r = n % 3, o = [], a = 16383, s = 0, c = n - r; s < c; s += a) + o.push(f(e, s, s + a > c ? c : s + a)); + return 1 === r ? (t = e[n - 1], + o.push(i[t >> 2] + i[t << 4 & 63] + "==")) : 2 === r && (t = (e[n - 2] << 8) + e[n - 1], + o.push(i[t >> 10] + i[t >> 4 & 63] + i[t << 2 & 63] + "=")), + o.join("") + }; + for (var i = [], r = [], o = "undefined" != typeof Uint8Array ? Uint8Array : Array, a = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", s = 0, c = a.length; s < c; ++s) + i[s] = a[s], + r[a.charCodeAt(s)] = s; + + function l(e) { + var t = e.length; + if (t % 4 > 0) + throw new Error("Invalid string. Length must be a multiple of 4"); + var n = e.indexOf("="); + return -1 === n && (n = t), [n, n === t ? 0 : 4 - n % 4] + } + + function u(e) { + return i[e >> 18 & 63] + i[e >> 12 & 63] + i[e >> 6 & 63] + i[63 & e] + } + + function f(e, t, n) { + for (var i, r = [], o = t; o < n; o += 3) + i = (e[o] << 16 & 16711680) + (e[o + 1] << 8 & 65280) + (255 & e[o + 2]), + r.push(u(i)); + return r.join("") + } + + r["-".charCodeAt(0)] = 62, + r["_".charCodeAt(0)] = 63 + }, + 9152: function (e, t) { + t.read = function (e, t, n, i, r) { + var o, a, s = 8 * r - i - 1, + c = (1 << s) - 1, + l = c >> 1, + u = -7, + f = n ? r - 1 : 0, + h = n ? -1 : 1, + d = e[t + f]; + for (f += h, + o = d & (1 << -u) - 1, + d >>= -u, + u += s; u > 0; o = 256 * o + e[t + f], + f += h, + u -= 8) + ; + for (a = o & (1 << -u) - 1, + o >>= -u, + u += i; u > 0; a = 256 * a + e[t + f], + f += h, + u -= 8) + ; + if (0 === o) + o = 1 - l; + else { + if (o === c) + return a ? NaN : 1 / 0 * (d ? -1 : 1); + a += Math.pow(2, i), + o -= l + } + return (d ? -1 : 1) * a * Math.pow(2, o - i) + }, + t.write = function (e, t, n, i, r, o) { + var a, s, c, l = 8 * o - r - 1, + u = (1 << l) - 1, + f = u >> 1, + h = 23 === r ? Math.pow(2, -24) - Math.pow(2, -77) : 0, + d = i ? 0 : o - 1, + p = i ? 1 : -1, + m = t < 0 || 0 === t && 1 / t < 0 ? 1 : 0; + for (t = Math.abs(t), + isNaN(t) || t === 1 / 0 ? (s = isNaN(t) ? 1 : 0, + a = u) : (a = Math.floor(Math.log(t) / Math.LN2), + t * (c = Math.pow(2, -a)) < 1 && (a--, + c *= 2), + (t += a + f >= 1 ? h / c : h * Math.pow(2, 1 - f)) * c >= 2 && (a++, + c /= 2), + a + f >= u ? (s = 0, + a = u) : a + f >= 1 ? (s = (t * c - 1) * Math.pow(2, r), + a += f) : (s = t * Math.pow(2, f - 1) * Math.pow(2, r), + a = 0)); r >= 8; e[n + d] = 255 & s, + d += p, + s /= 256, + r -= 8) + ; + for (a = a << r | s, + l += r; l > 0; e[n + d] = 255 & a, + d += p, + a /= 256, + l -= 8) + ; + e[n + d - p] |= 128 * m + } + }, + 'e3db': function (e, t) { + var n = {}.toString; + e.exports = Array.isArray || function (e) { + return "[object Array]" == n.call(e) + } + }, +}) + + +var HEX_CHARS = "0123456789abcdef".split(""), + EXTRA = [-2147483648, 8388608, 32768, 128], + SHIFT = [24, 16, 8, 0], + K = [1116352408, 1899447441, 3049323471, 3921009573, 961987163, 1508970993, 2453635748, 2870763221, 3624381080, 310598401, 607225278, 1426881987, 1925078388, 2162078206, 2614888103, 3248222580, 3835390401, 4022224774, 264347078, 604807628, 770255983, 1249150122, 1555081692, 1996064986, 2554220882, 2821834349, 2952996808, 3210313671, 3336571891, 3584528711, 113926993, 338241895, 666307205, 773529912, 1294757372, 1396182291, 1695183700, 1986661051, 2177026350, 2456956037, 2730485921, 2820302411, 3259730800, 3345764771, 3516065817, 3600352804, 4094571909, 275423344, 430227734, 506948616, 659060556, 883997877, 958139571, 1322822218, 1537002063, 1747873779, 1955562222, 2024104815, 2227730452, 2361852424, 2428436474, 2756734187, 3204031479, 3329325298], + OUTPUT_TYPES = ["hex", "array", "digest", "arrayBuffer"], + blocks = []; + +var createOutputMethod = function (e, t) { + return function (n) { + return new Sha256(t, !0).update(n)[e]() + } +}, + createMethod = function (e) { + var t = createOutputMethod("hex", e); + var NODE_JS; + NODE_JS && (t = nodeWrap(t, e)), + t.create = function () { + return new Sha256(e) + } + , + t.update = function (e) { + return t.create().update(e) + } + ; + for (var n = 0; n < OUTPUT_TYPES.length; ++n) { + var i = OUTPUT_TYPES[n]; + t[i] = createOutputMethod(i, e) + } + return t + }, + nodeWrap = function (method, is224) { + var crypto = eval("require('crypto')") + , Buffer = eval("require('buffer').Buffer") + , algorithm = is224 ? "sha224" : "sha256" + , nodeMethod = function (e) { + if ("string" == typeof e) + return crypto.createHash(algorithm).update(e, "utf8").digest("hex"); + if (null == e) + throw new Error(ERROR); + return e.constructor === ArrayBuffer && (e = new Uint8Array(e)), + Array.isArray(e) || ArrayBuffer.isView(e) || e.constructor === Buffer ? crypto.createHash(algorithm).update(new Buffer(e)).digest("hex") : method(e) + }; + return nodeMethod + }, + createHmacOutputMethod = function (e, t) { + return function (n, i) { + return new HmacSha256(n, t, !0).update(i)[e]() + } + }, + createHmacMethod = function (e) { + var t = createHmacOutputMethod("hex", e); + t.create = function (t) { + return new HmacSha256(t, e) + } + , + t.update = function (e, n) { + return t.create(e).update(n) + } + ; + for (var n = 0; n < OUTPUT_TYPES.length; ++n) { + var i = OUTPUT_TYPES[n]; + t[i] = createHmacOutputMethod(i, e) + } + return t + }; + +function Sha256(e, t) { + t ? (blocks[0] = blocks[16] = blocks[1] = blocks[2] = blocks[3] = blocks[4] = blocks[5] = blocks[6] = blocks[7] = blocks[8] = blocks[9] = blocks[10] = blocks[11] = blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0, + this.blocks = blocks) : this.blocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + e ? (this.h0 = 3238371032, + this.h1 = 914150663, + this.h2 = 812702999, + this.h3 = 4144912697, + this.h4 = 4290775857, + this.h5 = 1750603025, + this.h6 = 1694076839, + this.h7 = 3204075428) : (this.h0 = 1779033703, + this.h1 = 3144134277, + this.h2 = 1013904242, + this.h3 = 2773480762, + this.h4 = 1359893119, + this.h5 = 2600822924, + this.h6 = 528734635, + this.h7 = 1541459225), + this.block = this.start = this.bytes = this.hBytes = 0, + this.finalized = this.hashed = !1, + this.first = !0, + this.is224 = e +} + +function HmacSha256(e, t, n) { + var i, r = typeof e; + if ("string" === r) { + var o, a = [], s = e.length, c = 0; + for (i = 0; i < s; ++i) + (o = e.charCodeAt(i)) < 128 ? a[c++] = o : o < 2048 ? (a[c++] = 192 | o >> 6, + a[c++] = 128 | 63 & o) : o < 55296 || o >= 57344 ? (a[c++] = 224 | o >> 12, + a[c++] = 128 | o >> 6 & 63, + a[c++] = 128 | 63 & o) : (o = 65536 + ((1023 & o) << 10 | 1023 & e.charCodeAt(++i)), + a[c++] = 240 | o >> 18, + a[c++] = 128 | o >> 12 & 63, + a[c++] = 128 | o >> 6 & 63, + a[c++] = 128 | 63 & o); + e = a + } else { + if ("object" !== r) + throw new Error(ERROR); + if (null === e) + throw new Error(ERROR); + if (ARRAY_BUFFER && e.constructor === ArrayBuffer) + e = new Uint8Array(e); + else if (!(Array.isArray(e) || ARRAY_BUFFER && ArrayBuffer.isView(e))) + throw new Error(ERROR) + } + e.length > 64 && (e = new Sha256(t, !0).update(e).array()); + var l = [] + , u = []; + for (i = 0; i < 64; ++i) { + var f = e[i] || 0; + l[i] = 92 ^ f, + u[i] = 54 ^ f + } + Sha256.call(this, t, n), + this.update(u), + this.oKeyPad = l, + this.inner = !0, + this.sharedMemory = n +} + +Sha256.prototype.update = function (e) { + if (!this.finalized) { + var t, n = typeof e; + if ("string" !== n) { + if ("object" !== n) + throw new Error(ERROR); + if (null === e) + throw new Error(ERROR); + if (ARRAY_BUFFER && e.constructor === ArrayBuffer) + e = new Uint8Array(e); + else if (!(Array.isArray(e) || ARRAY_BUFFER && ArrayBuffer.isView(e))) + throw new Error(ERROR); + t = !0 + } + for (var i, r, o = 0, a = e.length, s = this.blocks; o < a;) { + if (this.hashed && (this.hashed = !1, + s[0] = this.block, + s[16] = s[1] = s[2] = s[3] = s[4] = s[5] = s[6] = s[7] = s[8] = s[9] = s[10] = s[11] = s[12] = s[13] = s[14] = s[15] = 0), + t) + for (r = this.start; o < a && r < 64; ++o) + s[r >> 2] |= e[o] << SHIFT[3 & r++]; + else + for (r = this.start; o < a && r < 64; ++o) + (i = e.charCodeAt(o)) < 128 ? s[r >> 2] |= i << SHIFT[3 & r++] : i < 2048 ? (s[r >> 2] |= (192 | i >> 6) << SHIFT[3 & r++], + s[r >> 2] |= (128 | 63 & i) << SHIFT[3 & r++]) : i < 55296 || i >= 57344 ? (s[r >> 2] |= (224 | i >> 12) << SHIFT[3 & r++], + s[r >> 2] |= (128 | i >> 6 & 63) << SHIFT[3 & r++], + s[r >> 2] |= (128 | 63 & i) << SHIFT[3 & r++]) : (i = 65536 + ((1023 & i) << 10 | 1023 & e.charCodeAt(++o)), + s[r >> 2] |= (240 | i >> 18) << SHIFT[3 & r++], + s[r >> 2] |= (128 | i >> 12 & 63) << SHIFT[3 & r++], + s[r >> 2] |= (128 | i >> 6 & 63) << SHIFT[3 & r++], + s[r >> 2] |= (128 | 63 & i) << SHIFT[3 & r++]); + this.lastByteIndex = r, + this.bytes += r - this.start, + r >= 64 ? (this.block = s[16], + this.start = r - 64, + this.hash(), + this.hashed = !0) : this.start = r + } + return this.bytes > 4294967295 && (this.hBytes += this.bytes / 4294967296 << 0, + this.bytes = this.bytes % 4294967296), + this + } +}, +Sha256.prototype.finalize = function () { + if (!this.finalized) { + this.finalized = !0; + var e = this.blocks + , t = this.lastByteIndex; + e[16] = this.block, + e[t >> 2] |= EXTRA[3 & t], + this.block = e[16], + t >= 56 && (this.hashed || this.hash(), + e[0] = this.block, + e[16] = e[1] = e[2] = e[3] = e[4] = e[5] = e[6] = e[7] = e[8] = e[9] = e[10] = e[11] = e[12] = e[13] = e[14] = e[15] = 0), + e[14] = this.hBytes << 3 | this.bytes >>> 29, + e[15] = this.bytes << 3, + this.hash() + } + }, +Sha256.prototype.hash = function () { + var e, t, n, i, r, o, a, s, c, l = this.h0, u = this.h1, f = this.h2, h = this.h3, d = this.h4, p = this.h5, + m = this.h6, v = this.h7, b = this.blocks; + for (e = 16; e < 64; ++e) + t = ((r = b[e - 15]) >>> 7 | r << 25) ^ (r >>> 18 | r << 14) ^ r >>> 3, + n = ((r = b[e - 2]) >>> 17 | r << 15) ^ (r >>> 19 | r << 13) ^ r >>> 10, + b[e] = b[e - 16] + t + b[e - 7] + n << 0; + for (c = u & f, + e = 0; e < 64; e += 4) + this.first ? (this.is224 ? (o = 300032, + v = (r = b[0] - 1413257819) - 150054599 << 0, + h = r + 24177077 << 0) : (o = 704751109, + v = (r = b[0] - 210244248) - 1521486534 << 0, + h = r + 143694565 << 0), + this.first = !1) : (t = (l >>> 2 | l << 30) ^ (l >>> 13 | l << 19) ^ (l >>> 22 | l << 10), + i = (o = l & u) ^ l & f ^ c, + v = h + (r = v + (n = (d >>> 6 | d << 26) ^ (d >>> 11 | d << 21) ^ (d >>> 25 | d << 7)) + (d & p ^ ~d & m) + K[e] + b[e]) << 0, + h = r + (t + i) << 0), + t = (h >>> 2 | h << 30) ^ (h >>> 13 | h << 19) ^ (h >>> 22 | h << 10), + i = (a = h & l) ^ h & u ^ o, + m = f + (r = m + (n = (v >>> 6 | v << 26) ^ (v >>> 11 | v << 21) ^ (v >>> 25 | v << 7)) + (v & d ^ ~v & p) + K[e + 1] + b[e + 1]) << 0, + t = ((f = r + (t + i) << 0) >>> 2 | f << 30) ^ (f >>> 13 | f << 19) ^ (f >>> 22 | f << 10), + i = (s = f & h) ^ f & l ^ a, + p = u + (r = p + (n = (m >>> 6 | m << 26) ^ (m >>> 11 | m << 21) ^ (m >>> 25 | m << 7)) + (m & v ^ ~m & d) + K[e + 2] + b[e + 2]) << 0, + t = ((u = r + (t + i) << 0) >>> 2 | u << 30) ^ (u >>> 13 | u << 19) ^ (u >>> 22 | u << 10), + i = (c = u & f) ^ u & h ^ s, + d = l + (r = d + (n = (p >>> 6 | p << 26) ^ (p >>> 11 | p << 21) ^ (p >>> 25 | p << 7)) + (p & m ^ ~p & v) + K[e + 3] + b[e + 3]) << 0, + l = r + (t + i) << 0; + this.h0 = this.h0 + l << 0, + this.h1 = this.h1 + u << 0, + this.h2 = this.h2 + f << 0, + this.h3 = this.h3 + h << 0, + this.h4 = this.h4 + d << 0, + this.h5 = this.h5 + p << 0, + this.h6 = this.h6 + m << 0, + this.h7 = this.h7 + v << 0 + }, +Sha256.prototype.hex = function () { + this.finalize(); + var e = this.h0 + , t = this.h1 + , n = this.h2 + , i = this.h3 + , r = this.h4 + , o = this.h5 + , a = this.h6 + , s = this.h7 + , + c = HEX_CHARS[e >> 28 & 15] + HEX_CHARS[e >> 24 & 15] + HEX_CHARS[e >> 20 & 15] + HEX_CHARS[e >> 16 & 15] + HEX_CHARS[e >> 12 & 15] + HEX_CHARS[e >> 8 & 15] + HEX_CHARS[e >> 4 & 15] + HEX_CHARS[15 & e] + HEX_CHARS[t >> 28 & 15] + HEX_CHARS[t >> 24 & 15] + HEX_CHARS[t >> 20 & 15] + HEX_CHARS[t >> 16 & 15] + HEX_CHARS[t >> 12 & 15] + HEX_CHARS[t >> 8 & 15] + HEX_CHARS[t >> 4 & 15] + HEX_CHARS[15 & t] + HEX_CHARS[n >> 28 & 15] + HEX_CHARS[n >> 24 & 15] + HEX_CHARS[n >> 20 & 15] + HEX_CHARS[n >> 16 & 15] + HEX_CHARS[n >> 12 & 15] + HEX_CHARS[n >> 8 & 15] + HEX_CHARS[n >> 4 & 15] + HEX_CHARS[15 & n] + HEX_CHARS[i >> 28 & 15] + HEX_CHARS[i >> 24 & 15] + HEX_CHARS[i >> 20 & 15] + HEX_CHARS[i >> 16 & 15] + HEX_CHARS[i >> 12 & 15] + HEX_CHARS[i >> 8 & 15] + HEX_CHARS[i >> 4 & 15] + HEX_CHARS[15 & i] + HEX_CHARS[r >> 28 & 15] + HEX_CHARS[r >> 24 & 15] + HEX_CHARS[r >> 20 & 15] + HEX_CHARS[r >> 16 & 15] + HEX_CHARS[r >> 12 & 15] + HEX_CHARS[r >> 8 & 15] + HEX_CHARS[r >> 4 & 15] + HEX_CHARS[15 & r] + HEX_CHARS[o >> 28 & 15] + HEX_CHARS[o >> 24 & 15] + HEX_CHARS[o >> 20 & 15] + HEX_CHARS[o >> 16 & 15] + HEX_CHARS[o >> 12 & 15] + HEX_CHARS[o >> 8 & 15] + HEX_CHARS[o >> 4 & 15] + HEX_CHARS[15 & o] + HEX_CHARS[a >> 28 & 15] + HEX_CHARS[a >> 24 & 15] + HEX_CHARS[a >> 20 & 15] + HEX_CHARS[a >> 16 & 15] + HEX_CHARS[a >> 12 & 15] + HEX_CHARS[a >> 8 & 15] + HEX_CHARS[a >> 4 & 15] + HEX_CHARS[15 & a]; + return this.is224 || (c += HEX_CHARS[s >> 28 & 15] + HEX_CHARS[s >> 24 & 15] + HEX_CHARS[s >> 20 & 15] + HEX_CHARS[s >> 16 & 15] + HEX_CHARS[s >> 12 & 15] + HEX_CHARS[s >> 8 & 15] + HEX_CHARS[s >> 4 & 15] + HEX_CHARS[15 & s]), + c + }, +Sha256.prototype.toString = Sha256.prototype.hex, +Sha256.prototype.digest = function () { + this.finalize(); + var e = this.h0 + , t = this.h1 + , n = this.h2 + , i = this.h3 + , r = this.h4 + , o = this.h5 + , a = this.h6 + , s = this.h7 + , + c = [e >> 24 & 255, e >> 16 & 255, e >> 8 & 255, 255 & e, t >> 24 & 255, t >> 16 & 255, t >> 8 & 255, 255 & t, n >> 24 & 255, n >> 16 & 255, n >> 8 & 255, 255 & n, i >> 24 & 255, i >> 16 & 255, i >> 8 & 255, 255 & i, r >> 24 & 255, r >> 16 & 255, r >> 8 & 255, 255 & r, o >> 24 & 255, o >> 16 & 255, o >> 8 & 255, 255 & o, a >> 24 & 255, a >> 16 & 255, a >> 8 & 255, 255 & a]; + return this.is224 || c.push(s >> 24 & 255, s >> 16 & 255, s >> 8 & 255, 255 & s), + c + }, +Sha256.prototype.array = Sha256.prototype.digest, +Sha256.prototype.arrayBuffer = function () { + this.finalize(); + var e = new ArrayBuffer(this.is224 ? 28 : 32) + , t = new DataView(e); + return t.setUint32(0, this.h0), + t.setUint32(4, this.h1), + t.setUint32(8, this.h2), + t.setUint32(12, this.h3), + t.setUint32(16, this.h4), + t.setUint32(20, this.h5), + t.setUint32(24, this.h6), + this.is224 || t.setUint32(28, this.h7), + e + }, +HmacSha256.prototype = new Sha256, +HmacSha256.prototype.finalize = function () { + if (Sha256.prototype.finalize.call(this), + this.inner) { + this.inner = !1; + var e = this.array(); + Sha256.call(this, this.is224, this.sharedMemory), + this.update(this.oKeyPad), + this.update(e), + Sha256.prototype.finalize.call(this) + } + }; + +function i() { + return function () { + var t = e(6, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789") + , n = e(1, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") + , i = e(1, "0123456789"); + return n + i + t + }(); + + function e(e, t) { + e = e || 32; + for (var n = "", i = 0; i < e; i++) + n += t.charAt(Math.ceil(1e3 * Math.random()) % t.length); + return n + } +} + +function p(t) { + try { + var n = m(function (e) { + var t = {} + , n = ["signData", "encData", "extra"]; + for (var i in e) + e.hasOwnProperty(i) && !n.includes(i) && null != e[i] && (t[i] = e[i]); + return t + }(t.data)); + n.data = m(n.data); + var i = function (e) { + var t = []; + for (var n in e) + if (e.hasOwnProperty(n) && (e[n] || "".concat(e[n]))) + if ("data" === n) { + var i = Object.assign({}, e[n]); + for (var r in i) { + if ("number" != typeof i[r] && "boolean" != typeof i[r] || (i[r] = "" + i[r]), + Array.isArray(i[r]) && !i[r].length && delete i[r], + Array.isArray(i[r]) && i[r].length > 0) + for (var o = 0; o < i[r].length; o++) + i[r][o] = m(i[r][o]); + null != i[r] && i[r] || delete i[r] + } + var a = m(i); + t.push("".concat(n, "=").concat(JSON.stringify(a))) + } else + t.push("".concat(n, "=").concat(e[n])); + return t.push("key=".concat(u)), + t.join("&") + }(n), + h = '009c4a35d9aca4c68f1a3fa89c93684347205a4d84dc260558a049869709ac0b42', + // r = o.doSignature(i, h, {hash: !0}) + r = sm2.doSignature(i, h, {hash: !0}); + // return e.from(r, "hex").toString("base64") + return e_.Buffer.from(r, "hex").toString("base64") + } catch (e) { + // console.log(e) + } +} + +function m(e) { + var t = new Array + , n = 0; + for (var i in e) + t[n] = i, + n++; + var r = [].concat(t).sort() + , o = {}; + for (var a in r) + o[r[a]] = e[r[a]]; + return o +} + +function v(e, t) { + switch (e.toUpperCase()) { + case "SM2": + return function (e) { + try { + var t = o.generateKeyPairHex().publicKey + , n = e; + o.doEncrypt(n, t, 1) + } catch (e) { + } + }(t); + case "SM3": + return function (e) { + try { + return a(e) + } catch (e) { + } + }(t); + case "SM4": + return function (e) { + try { + var t = w(e.data.data && JSON.stringify(e.data.data)); + return e.data.appCode && e.data.appCode !== l && (l = e.data.appCode), + A(g(l, u), t).toUpperCase() + } catch (e) { + console.log(e) + } + }(t) + } +} + +function g(e, t) { + var n = w(e.substr(0, 16)) + , i = w(t); + return w(A(n, i).toUpperCase().substr(0, 16)) +} + +function A(t, n) { + var i = 16 - parseInt(n.length % 16); + n = n.concat(new Array(i).fill(i)); + var r = sm4.encrypt(n, t); + // return e.from(r).toString("hex") + return e_.Buffer.from(r).toString("hex") +} + +function w(e) { + var t, n, i = new Array; + t = e.length; + for (var r = 0; r < t; r++) + (n = e.charCodeAt(r)) >= 65536 && n <= 1114111 ? (i.push(n >> 18 & 7 | 240), + i.push(n >> 12 & 63 | 128), + i.push(n >> 6 & 63 | 128), + i.push(63 & n | 128)) : n >= 2048 && n <= 65535 ? (i.push(n >> 12 & 15 | 224), + i.push(n >> 6 & 63 | 128), + i.push(63 & n | 128)) : n >= 128 && n <= 2047 ? (i.push(n >> 6 & 31 | 192), + i.push(63 & n | 128)) : i.push(255 & n); + return i +} + +var c = { + paasId: undefined, + appCode: "T98HPCGN5ZVVQBS8LZQNOAEXVI9GYHKQ", + version: "1.0.0", + appSecret: "NMVFVILMKT13GEMD3BKPKCTBOQBPZR2P", + publicKey: "BEKaw3Qtc31LG/hTPHFPlriKuAn/nzTWl8LiRxLw4iQiSUIyuglptFxNkdCiNXcXvkqTH79Rh/A2sEFU6hjeK3k=", + privateKey: "AJxKNdmspMaPGj+onJNoQ0cgWk2E3CYFWKBJhpcJrAtC", + publicKeyType: "base64", + privateKeyType: "base64" + }, + l = c.appCode, + u = c.appSecret, + f = c.publicKey, + h = c.privateKey, + t = createMethod(), + // t = n("6c27").sha256, + r = Math.ceil((new Date).getTime() / 1e3), + o = i(), + a = r + o + r; + +function getEncryptedData(data) { + var e = {"data": data} + return e.data = { + data: e.data || {} + }, + e.data.appCode = c.appCode, + e.data.version = c.version, + e.data.encType = "SM4", + e.data.signType = "SM2", + e.data.timestamp = r, + e.data.signData = p(e), + e.data.data = { + encData: v("SM4", e) + }, + // e.data = JSON.stringify({ + // data: e.data + // }), + e +} + +function getDecryptedData(t) { + if (!t) + return null; + var n = e_.Buffer.from(t.data.data.encData, "hex") + , i = function(t, n) { + var i = sm4.decrypt(n, t) + , r = i[i.length - 1]; + return i = i.slice(0, i.length - r), + e_.Buffer.from(i).toString("utf-8") + }(g(l, u), n); + return JSON.parse(i) +} + +function getHeaders(){ + var headers = {} + return headers["x-tif-paasid"] = c.paasId, + headers["x-tif-signature"] = t(a), + headers["x-tif-timestamp"] = r.toString(), + headers["x-tif-nonce"] = o, + headers["Accept"] = "application/json", + headers["contentType"] = "application/x-www-form-urlencoded", + headers +} + +// 测试样例 +// console.log(getHeaders()) +// console.log(getEncryptedData({"addr": "", "regnCode": "110000", "medinsName": "", "sprtEcFlag": "", "medinsLvCode": "", "medinsTypeCode": "", "pageNum": 4, "pageSize": 10})) +// console.log(getDecryptedData({"code":0,"data":{"signData":"PMo/95DIC0gKtCZAU74F+bn83Rl1UTff0qCRXEOZ4zSdWH5nJxHq3I4X9xs/TPntsUb6kiUpQfhsQWDDT/8nTA==","encType":"SM4","data":{"encData":"79EA29DF93BA4831B56A66EE3BE43BB0320BEB5533410E68F76FA211821D0AB094B0C57502419BEC4CDA8E27C6C103FF1CA22FDD0B961DFE1A3C0B3F6C9B5FCA79541A4DCBD71957B4C95782EE13C89F7E119234DB3672AC16B998466FA07D4E0E3A82F1B564CEF934E0E2AE703D80B93582034E49E9BA089BA393DB54DE67C8"},"signType":"SM2","appCode":"T98HPCGN5ZVVQBS8LZQNOAEXVI9GYHKQ","version":"1.0.0","timestamp":"1635906980133"},"message":"成功","timestamp":"1635906980","type":"success"})) diff --git a/JSReverse/fuwu_nhsa_gov_cn/nhsa.py b/JSReverse/fuwu_nhsa_gov_cn/nhsa.py new file mode 100644 index 0000000..afb1221 --- /dev/null +++ b/JSReverse/fuwu_nhsa_gov_cn/nhsa.py @@ -0,0 +1,97 @@ +# ================================== +# --*-- coding: utf-8 --*-- +# @Time : 2021-11-03 +# @Author : TRHX +# @Blog : www.itrhx.com +# @CSDN : itrhx.blog.csdn.net +# @FileName: nhsa.py +# @Software: PyCharm +# ================================== + + +import execjs +import requests + + +regn_code_url = "https://fuwu.nhsa.gov.cn/ebus/fuwu/api/nthl/api/dic/queryAdmdvsTree" +lv_and_type_url = "https://fuwu.nhsa.gov.cn/ebus/fuwu/api/nthl/api/fixed/queryDicByType" +result_url = "https://fuwu.nhsa.gov.cn/ebus/fuwu/api/nthl/api/fixed/queryFixedHospital" +UA = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.81 Safari/537.36" + +with open('nhsa.js', 'r', encoding='utf-8') as f: + nhsa_js = execjs.compile(f.read()) + + +def get_headers(): + """获取 header 参数,每次请求改变""" + headers = nhsa_js.call("getHeaders") + headers["User-Agent"] = UA + headers["Content-Type"] = "application/json" + headers["Host"] = "fuwu.nhsa.gov.cn" + headers["Origin"] = "https://fuwu.nhsa.gov.cn" + headers["Referer"] = "https://fuwu.nhsa.gov.cn/nationalHallSt/" + # print(headers) + return headers + + +def get_regn_code(): + """获取城市代码,返回结果无加密""" + payload = {"data": {"transferFlag": ""}} + response = requests.post(url=regn_code_url, json=payload, headers=get_headers()) + print(response.text) + + +def get_medins_lv_or_type_code(key): + """获取医疗机构等级 (LV) or 类型 (TYPE) 代码""" + if key == "LV": + payload = {"type": "MEDINSLV"} + elif key == "TYPE": + payload = {"type": "MEDINS_TYPE"} + else: + print("输入有误!") + return + encrypted_payload = nhsa_js.call("getEncryptedData", payload) + encrypted_data = requests.post(url=lv_and_type_url, json=encrypted_payload, headers=get_headers()).json() + decrypted_data = nhsa_js.call("getDecryptedData", encrypted_data) + print(decrypted_data) + + +def get_result(): + addr = input("请输入医疗机构详细地址(默认无): ") or "" + medins_lv_code = input("请输入医疗机构等级代码(默认无): ") or "" + medins_name = input("请输入医疗机构名称(默认无): ") or "" + medins_type_code = input("请输入医疗机构类型代码(默认无): ") or "" + regn_code = input("请输入医疗机构所在地代码(默认北京市): ") or "110000" + page_num = input("请输入要爬取的页数(默认1): ") or 1 + + for page in range(1, int(page_num)+1): + payload = { + "addr": addr, + "medinsLvCode": medins_lv_code, + "medinsName": medins_name, + "medinsTypeCode": medins_type_code, + "pageNum": page, + "pageSize": 10, + "regnCode": regn_code, + "sprtEcFlag": "" + } + page += 1 + encrypted_payload = nhsa_js.call("getEncryptedData", payload) + encrypted_data = requests.post(url=result_url, json=encrypted_payload, headers=get_headers()).json() + decrypted_data = nhsa_js.call("getDecryptedData", encrypted_data) + print(decrypted_data) + + +def main(): + # 获取城市代码 + # get_regn_code() + # 获取医疗机构等级代码 + # get_medins_lv_or_type_code("LV") + # 获取医疗机构类型代码 + # get_medins_lv_or_type_code("TYPE") + # 获取搜索结果 + get_result() + + +if __name__ == "__main__": + main() -- GitLab