Code Monkey home page Code Monkey logo

sm-crypto's People

Contributors

aerchen avatar changhr2013 avatar hyfree avatar juneandgreen avatar painterq avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sm-crypto's Issues

sm4 加密pdf最后一行EOF missing

这个我不知道是加密导致的,还是我base64或者buffer等转换中导致。pdf加密,然后以表单上传到后端,下载,解密,生成pdf.
解密下载后的pdf可以打开,但是会提醒我修改了,用ultraEdit查看,最后一行EOF消失了。

这个issue可以打个question标签

SM2解密二进制数据?

doDecrypt似乎期待解码出来的是utf8的数据,如果明文是二进制的,会报错 Malformed UTF-8 data
有办法开选项返回个Buffer、Uint8Array之类的吗,还是我应该直接改代码?

所有验签都失败!!!!

`let sigValueHex6 = sm2.doSignature("这是加密123456", privateKeyWeb, {
hash: true,
publicKeyWeb,
userId: '1234567812345678',
})
console.log(sigValueHex6);

let verifyResult6 = sm2.doVerifySignature("这是加密123456", sigValueHex6, publicKeyWeb, {
hash: true,
userId: '1234567812345678',
})

console.log(verifyResult6);`

错误如下 :
[Running] node "d:\Workspace\newProject\aggregate\tianjinfarmer\src\service\tempCodeRunnerFile.js"
0897d7bf791a538f32e5d18a17f5b4578c9434800d884c89d554ebbcbded056708adb68956f3d74baa80d3d1d3e57211158b2d0960c27678ed126d45a4059cc7
D:\Workspace\newProject\aggregate\tianjinfarmer\node_modules_sm-crypto@0.2.1@sm-crypto\src\sm2\index.js:154
const x1y1 = G.multiply(s).add(PA.multiply(t))
^

TypeError: Cannot read property 'multiply' of null
at Object.doVerifySignature (D:\Workspace\newProject\aggregate\tianjinfarmer\node_modules_sm-crypto@0.2.1@sm-crypto\src\sm2\index.js:154:37)
at Object. (d:\Workspace\newProject\aggregate\tianjinfarmer\src\service\tempCodeRunnerFile.js:36:25)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)

这个问题很懵啊 所有的签名都能过去 但就是 验签 过不了 都会报** Cannot read property 'multiply' of null**

循环加密解密好像会报错

var sm2 = require('sm-crypto').sm2;
var sm3 = require('sm-crypto').sm3;
var sm4 = require('sm-crypto').sm4;
var assert = require('assert');

var plainMsg = 'hello world!';
var keypair = sm2.generateKeyPairHex();
console.log('keypair:' + keypair);

var i = 0
for (;;) {
i++;
if (i == 1000) {
i = 0;
}
var encryptData = sm2.doEncrypt(plainMsg, keypair.publicKey);
console.log('encrypt result:' + encryptData);
var decryptData = sm2.doDecrypt(encryptData, keypair.privateKey);
console.log('decrypt result:' + decryptData);
assert.equal(plainMsg == decryptData, true, 'error');

// var hashResult = sm3(plainMsg);
// console.log('sm3 hash:' + hashResult);

}

angular2+和react 在ts环境下报错

通过npm install @types/sm-crypto --save
安装成功,文件中也成功import,但是项目启动的时候报错:
Module not found: Error: Can't resolve 'sm-crypto' in 'D:\idea workspace\XXX\src\app'

angular 2+和react 项目都一样。

sm2签名同一个字符串,每次得出来的结果都不一样,怎样设置可以让只要字符串和私钥相同得出来的签名都是一样的?

待签名字符串:eyJraWQiOiIwMDEiLCJ0eXAiOiJKV1QiLCJhbGciOiJTTTIifQ.eyJleHAiOjE1NzQ5NjQ5MjMzMzgsImlhdCI6MTU3NDk2NDkyMTMzOCwianRpIjoiNmFkZmM2Y2UtMjZjYS00ZmRlLThmMDctM2QxMGFiNDA4ZGI2XzE1NzQ5NjQ5MjEzMzgifQ

私钥:f4e08d945183fc9fa6425561e4799efa8facfe0b715cb93c2db8a8142aad6f24

调用方法:sm2.doSignature(待签名字符串,私钥)

结果:

image

SM4算法加密原文对emoji的支持

发现一个现象, 前端用sm4加密, 原文包含emoji表情,以字符串形式传入, 后端解密发现emoji表情信息为乱码, 其余内容正常
前端自己加密, 自己解密, emoji正常;
后端对相同原文自己加密自己解密, emoji正常;
不进行加解密, emoji正常;

调试了一下发现, 如果原文入参转成数组, 比如 Buffer.from("😃"), 后端可以正常处理,
对后端包含emoji表情的密文, 解密后以数组输出, 再用Buffer.from("解密后的数组").toString(), 也可以正常显示了

感觉 utf8ToArray()以及arrayToUtf8()这两个函数对于emoji的处理需要优化支持一下
非前端开发, 能力有限, 只是找到了一个暂时解决的办法.

java加密,前端解密问题

sm-crypto:0.3.6
后端采用java 公钥进行sm2加密,前端使用私钥进行解密。
前端解密时,计算出c3与checkC3校验时因字母大小写,导致验证失败。无法解密。
前端js加解密无此问题。
应加上字符串转为小写,判断是否一致。
104行
if (checkC3 === c3) { #此处修改为 if (checkC3.toLowerCase() === c3.toLowerCase() ) {
return output === 'array' ? msg : _.arrayToUtf8(msg)
} else {
return output === 'array' ? [] : ''
}

image

直接引用src js源码问题

ec.js 源码引用到工程使用报错,将88行代码修改为 this.z = z === undefined ? BigInteger.ONE : z 后即可正常使用。

sm4前后端没办法互相解密

sm2 前端去掉 04 后端加上 04 可以相互加解密,sm3 加密结果也是一致的。但是进行 sm4 加解密时候就出现没办法解密的问题,前端传给后端的代码后端解密不了,前端解后端的加密最后也输出的空......最后又找了一个 gm-crypto 解密的。请问这是什么原因啊 QAQ

sm4加密短字符串的问题

sm4加密的时候如果需要加密的串太短且当padding为none时不进入加密循环 while (restLen >= BLOCK),使得outArray为空,加密出来为空

webpack 开启UglifyJsPlugin,打包时报错

ERROR in static-apph5/js/vendor.386ad02019772f8f622f.js from UglifyJs
Unexpected token name «i», expected punc «;» [./node_modules/sm-crypto/src/sm4/index.js:41,0][static-apph5/js/vendor.386ad02019772f8f622f.js:128191,11]

签名函数错误

function doSignature(msg, privateKey, { pointPool, der, hash, publicKey } = {}) {
let hashHex = typeof msg === 'string' ? _.parseUtf8StringToHex(msg) : _.parseArrayBufferToHex(msg);

if (hash) {
    // sm3杂凑
    let publicKey = publicKey || getPublicKeyFromPrivateKey(privateKey);
    hashHex = doSm3Hash(hashHex, publicKey);
}

修改为:

function doSignature(msg, privateKey, { pointPool, der, hash, publicKey } = {}) {
let hashHex = typeof msg === 'string' ? _.parseUtf8StringToHex(msg) : _.parseArrayBufferToHex(msg);

if (hash) {
    // sm3杂凑
    let pubKey= publicKey || getPublicKeyFromPrivateKey(privateKey);
    hashHex = doSm3Hash(hashHex, pubKey);
}

dist 中SM2随机出错,加密的数据 别的加密机或解密卡不能解密(自己加自己解没有问题,自己加的数据送到加密机不能解密 出错率 10%左右)一下抓取了一条出错数据:

dist 中SM2随机出错,加密的数据 别的加密机或解密卡不能解密(自己加自己解没有问题,自己加的数据送到加密机不能解密 出错率 10%左右)以下抓取了一条出错数据:
明文:"11111111"
密文:1db3c72f5f0d012e2e56c6b92ea7f4081b49e2fd93e4a89c59cbe2dd028d8c8328d357b8e5e4e43ed395aa439d7fe032f92858ea0d53a02526a36eadb34faaa92ea1646f642f53812a4fc38876dbf253d38ea2ba4096d876462840b7b51c33b5719c09b08a170655
私钥:46D77D6E14C1DDC632159FA6E2AC3E204F6961869342DC99BC2684EDD71C57AB

Originally posted by @wangjun796 in #1 (comment)

后端生成的密钥对,前端加密成功,但无法解密

实际开发中遇到个问题,想请教下大佬们:
后端用Go语言生成的密钥对,前端用公钥能加密成功,在Go和Java上也能用对应的私钥解密成功,但前端无法解密

公钥:(取后130位)3059301306072a8648ce3d020106082a811ccf5501822d0342000410ee64f73e0acb2380bada2697e80a22b39968ac72833b7692968ff2c21bc88e8afcbdc1b89c3382089415cea907e61b02060194675a16c4d48c5e3a57c49388
私钥:308193020100301306072a8648ce3d020106082a811ccf5501822d047930770201010420ff54e3914a41191006633b5f08fcc5e42dbdf2c26c18d55dd9501f0d889c151ea00a06082a811ccf5501822da1440342000410ee64f73e0acb2380bada2697e80a22b39968ac72833b7692968ff2c21bc88e8afcbdc1b89c3382089415cea907e61b02060194675a16c4d48c5e3a57c49388

原文:你好啊
密文:(已添加 04 标识)044fd2407ae9b39d7e8080c15fa39ad392ce0ba26829345c6422c9fa1a8746ad4c5f42c3a1d6aaab0a8f16405afdcb3fb708c2a200b48ebd9b12adcaf686e4a060c6182903dd43e9b401afccc8504d9360d572a14d372dc7665fc2eb762f2e34c45cf50283c7c07b6e4d

Go和Java均能解密出原文,但是用sm-crypto解密后结果是空的。。

密钥格式

最近做项目遇到一个问题,我是用硬件里面的sm2加密(解密),使用sm-crypto解密(解密),发现大多数情况下都能成功,但是也存在不成功的时候。但是只使用硬件加密解密都能成功(测试1000次),使用sm-crypto加密解密也能成功(测试1000次),但是用交互使用的时候就存在不能解密的可能。请教一下这个问题是怎么回事?

webpack es5 打包问题

你好,我在webpack上面使用es5打包后,android9.0手机上面报错了
Uncaught TypeError: Cannot assign to read only property 'window' of object '#'
以下是报错段代码:
catch(e){t.window={}}e.exports={sm2:n(306),sm3:n(309),sm4:n(310)}}).call(this,n(26))},function(e,t,n){"use strict";var r=n(38).BigInteger,o=n(307),i=o.encodeDer,a=o.decodeDer,s=n(88).ECPointFp,u=n(132),l=n(308),c=n(89),f=c.generateEcparam(),d=f.G,h=f.curve,p=f.n,m=0;function y(e,t){var n=new u,r=(new u).getZ(d,t.substr(2,128)),o=c.hexToArray(c.arrayToHex(r).toString()),i=e,a=c.hexToArray(i),s=new Array(n.getDigestSize());return n.blockUpdate(o,0,o.length),n.blockUpdate(a,0,a.length),n.doFinal(s,0),c.arrayToHex(s).toString()}function v(){var e=c.generateKeyPairHex(),t=s.decodeFromHex(h,e.publicKey);return e.k=new r(e.privateKey,16),e.x1=t.getX().toBigInteger(),e}e.exports={generateKeyPairHex:c.generateKeyPairHex,doEncrypt:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,r=new l;e=c.hexToArray(c.parseUtf8StringToHex(e)),t.length>128&&(t=t.substr(t.length-128));var o=t.substr(0,64),i=t.substr(64);t=r.createPoint(o,i);var a=r.initEncipher(t);r.encryptBlock(e);var s=c.arrayToHex(e),u=new Array(32);return r.doFinal(u),u=c.arrayToHex(u),n===m?a+s+u:a+u+s},doDecrypt:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,o=new l(n);t=new r(t,16);var i=e.substr(0,64),a=e.substr(0+i.length,64),s=i.length+a.length,u=e.substr(s,64),f=e.substr(s+64);n===m&&(u=e.substr(e.length-64),f=e.substr(s,e.length-s-64));var d=c.hexToArray(f),h=o.createPoint(i,a);o.initDecipher(t,h),o.decryptBlock(d);var p=new Array(32);return o.doFinal(p),c.arrayToHex(p)==u?c.arrayToUtf8(d):""},doSignature:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=n.pointPool,a=n.der,s=n.hash,u=n.publicKey,l="string"==typeof e?c.parseUtf8StringToHex(e):c.parseArrayBufferToHex(e);s&&(l=y(l,u=u||function(e){var t=d.multiply(new r(e,16)),n=c.leftPad(t.getX().toBigInteger().toString(16),64),o=c.leftPad(t.getY().toBigInteger().toString(16),64);return"04"+n+o}(t)));var f=new r(t,16),h=new r(l,16),m=null,g=null,b=null;do{do{var =void 0;m=(=o&&o.length?o.pop():v()).k,g=h.add(.x1).mod(p)}while(g.equals(r.ZERO)||g.add(m).equals(p));b=f.add(r.ONE).modInverse(p).multiply(m.subtract(g.multiply(f))).mod(p)}while(b.equals(r.ZERO));return a?i(g,b):c.leftPad(g.toString(16),64)+c.leftPad(b.toString(16),64)},doVerifySignature:function(e,t,n){var o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i=o.der,u=o.hash,l="string"==typeof e?c.parseUtf8StringToHex(e):c.parseArrayBufferToHex(e);u&&(l=y(l,n));var f=void 0,m=void 0;if(i){var v=a(t);f=v.r,m=v.s}else f=new r(t.substring(0,64),16),m=new r(t.substring(64),16);var g=s.decodeFromHex(h,n),b=new r(l,16),=f.add(m).mod(p);if(.equals(r.ZERO))return!1;var w=d.multiply(m).add(g.multiply()),S=b.add(w.getX().toBigInteger()).mod(p);return f.equals(S)},getPoint:v}},function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.proto=t)}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var s=n(38).BigInteger;var u=function(){function e(){a(this,e),this.isModified=!0,this.hTLV=null,this.hT="00",this.hL="00",this.hV=""}return r(e,[{key:"getLengthHexFromValue",value:function(){var e=this.hV.length/2,t=e.toString(16);return t.length%2==1&&(t="0"+t),e<128?t:(128+t.length/2).toString(16)+t}},{key:"getEncodedHex",value:function(){return(null==this.hTLV||this.isModified)&&(this.hV=this.getFreshValueHex(),this.hL=this.getLengthHexFromValue(),this.hTLV=this.hT+this.hL+this.hV,this.isModified=!1),this.hTLV}},{key:"getFreshValueHex",value:function(){return""}}]),e}(),l=function(e){function t(e){a(this,t);var n=o(this,(t.proto||Object.getPrototypeOf(t)).call(this));return n.hT="02",e&&e.bigint&&(n.hTLV=null,n.isModified=!0,n.hV=function(e){var t=e.toString(16);if("-"!==t.substr(0,1))t.length%2==1?t="0"+t:t.match(/^[0-7]/)||(t="00"+t);else{var n=t.substr(1).length;n%2==1?n+=1:t.match(/^[0-7]/)||(n+=2);for(var r="",o=0;o<n;o++)r+="f";t=new s(r,16).xor(e).add(s.ONE).toString(16).replace(/^-/,"")}return t}(e.bigint)),n}return i(t,u),r(t,[{key:"getFreshValueHex",value:function(){return this.hV}}]),t}(),c=function(e){function t(e){a(this,t);var n=o(this,(t.proto||Object.getPrototypeOf(t)).call(this));return n.hT="30",n.asn1Array=[],e&&e.array&&(n.asn1Array=e.array),n}return i(t,u),r(t,[{key:"getFreshValueHex",value:function(){for(var e="",t=0;t<this.asn1Array.length;t++){e+=this.asn1Array[t].getEncodedHex()}return this.hV=e,this.hV}}]),t}();function f(e,t){if("8"!==e.substring(t+2,t+3))return 1;var n=parseInt(e.substring(t+3,t+4));return 0===n?-1:0<n&&n<10?n+1:-2}function d(e,t){var n=function(e,t){var n=f(e,t);return n<1?"":e.substring(t+2,t+2+2n)}(e,t);if(""===n)return-1;return(parseInt(n.substring(0,1))<8?new s(n,16):new s(n.substring(2),16)).intValue()}function h(e,t){var n=f(e,t);return n<0?l_len:t+2(n+1)}function p(e,t){var n=h(e,t),r=d(e,t);return e.substring(n,n+2r)}function m(e,t){return h(e,t)+2d(e,t)}e.exports={encodeDer:function(e,t){var n=new l({bigint:e}),r=new l({bigint:t});return new c({array:[n,r]}).getEncodedHex()},decodeDer:function(e){var t=function(e,t){var n=[],r=h(e,t);n.push(r);for(var o=d(e,t),i=r,a=0;;){var s=m(e,i);if(null===s||s-r>=2o)break;if(a>=200)break;n.push(s),i=s,a++}return n}(e,0),n=t[0],r=t[1],o=p(e,n),i=p(e,r);return{r:new s(o,16),s:new s(i,16)}}}},function(e,t,n){"use strict";var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();var o=n(38).BigInteger,i=n(88).ECPointFp,a=n(132),s=n(89),u=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.ct=1,this.p2=null,this.sm3keybase=null,this.sm3c3=null,this.key=new Array(32),this.keyOff=0}return r(e,[{key:"reset",value:function(){this.sm3keybase=new a,this.sm3c3=new a;var e=s.hexToArray(this.p2.getX().toBigInteger().toRadix(16)),t=s.hexToArray(this.p2.getY().toBigInteger().toRadix(16));this.sm3keybase.blockUpdate(e,0,e.length),this.sm3c3.blockUpdate(e,0,e.length),this.sm3keybase.blockUpdate(t,0,t.length),this.ct=1,this.nextKey()}},{key:"nextKey",value:function(){var e=new a(this.sm3keybase);e.update(this.ct>>24&255),e.update(this.ct>>16&255),e.update(this.ct>>8&255),e.update(255&this.ct),e.doFinal(this.key,0),this.keyOff=0,this.ct++}},{key:"initEncipher",value:function(e){var t=s.generateKeyPairHex(),n=new o(t.privateKey,16),r=t.publicKey;return this.p2=e.multiply(n),this.reset(),r.length>128&&(r=r.substr(r.length-128)),r}},{key:"encryptBlock",value:function(e){this.sm3c3.blockUpdate(e,0,e.length);for(var t=0;t<e.length;t++)this.keyOff===this.key.length&&this.nextKey(),e[t]^=this.key[this.keyOff++]}},{key:"initDecipher",value:function(e,t){this.p2=t.multiply(e),this.reset()}},{key:"decryptBlock",value:function(e){for(var t=0;t<e.length;t++)this.keyOff===this.key.length&&this.nextKey(),e[t]^=this.key[this.keyOff++];this.sm3c3.blockUpdate(e,0,e.length)}},{key:"doFinal",value:function(e){var t=s.hexToArray(this.p2.getY().toBigInteger().toRadix(16));this.sm3c3.blockUpdate(t,0,t.length),this.sm3c3.doFinal(e,0),this.reset()}},{key:"createPoint",value:function(e,t){var n="04"+e+t;return i.decodeFromHex(s.generateEcparam().curve,n)}}]),e}();e.exports=u},function(e,t,n){"use strict";function r(e,t){return e.length>=t?e:new Array(t-e.length+1).join("0")+e}function o(e){for(var t="",n=0;n<e.length/2;n++)t+=r(parseInt(e.substr(2n,2),16).toString(2),8);return t}function i(e,t){return e.substring(t%e.length)+e.substr(0,t%e.length)}function a(e,t,n){for(var r=e||"",o=t||"",i=[],a=void 0,s=r.length-1;s>=0;s--)a=n(r[s],o[s],a),i[s]=a[0];return i.join("")}function s(e,t){return a(e,t,function(e,t){return[e===t?"0":"1"]})}function u(e,t){return a(e,t,function(e,t){return["1"===e&&"1"===t?"1":"0"]})}function l(e,t){return a(e,t,function(e,t){return["1"===e||"1"===t?"1":"0"]})}function c(e,t){return a(e,t,function(e,t,n){var r=n?n[1]:"0";return e!==t?["0"===r?"1":"0",r]:[r,e]})}function f(e){return function(){for(var t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];return n.reduce(function(t,n){return e(t,n)})}}function d(e){return f(s)(e,i(e,9),i(e,17))}function h(e,t,n,r){return r>=0&&r<=15?f(s)(e,t,n):f(l)(u(e,t),u(e,n),u(t,n))}function p(e,t,n,r){return r>=0&&r<=15?f(s)(e,t,n):l(u(e,t),u(a(e,void 0,function(e){return["1"===e?"0":"1"]}),n))}function m(e){return o(e>=0&&e<=15?"79cc4519":"7a879d8a")}function y(e,t){for(var n,r=[],o=[],a=0;a<16;a++)r.push(t.substr(32a,32));for(var u=16;u<68;u++)r.push(f(s)((n=f(s)(r[u-16],r[u-9],i(r[u-3],15)),f(s)(n,i(n,15),i(n,23))),i(r[u-13],7),r[u-6]));for(var l=0;l<64;l++)o.push(s(r[l],r[l+4]));for(var y=[],v=0;v<8;v++)y.push(e.substr(32v,32));for(var g=y[0],b=y[1],=y[2],w=y[3],S=y[4],E=y[5],k=y[6],x=y[7],T=void 0,O=void 0,M=void 0,C=void 0,P=0;P<64;P++)O=s(T=i(f(c)(i(g,12),S,i(m(P),P)),7),i(g,12)),M=f(c)(h(g,b,,P),w,O,o[P]),C=f(c)(p(S,E,k,P),x,T,r[P]),w=,=i(b,9),b=g,g=M,x=k,k=i(E,19),E=S,S=d(C);return s([g,b,,w,S,E,k,x].join(""),e)}e.exports=function(e){for(var t=function(e){var t="",n=!0,o=!1,i=void 0;try{for(var a,s=eSymbol.iterator;!(n=(a=s.next()).done);n=!0)t+=r(a.value.codePointAt(0).toString(2),8)}catch(e){o=!0,i=e}finally{try{!n&&s.return&&s.return()}finally{if(o)throw i}}return t}(e),n=t.length,i=n%512,a=(t+"1"+r("",i=i>=448?512-i%448-1:448-i-1)+r(n.toString(2),64)).toString(),s=(n+i+65)/512,u=o("7380166f4914b2b9172442d7da8a0600a96f30bc163138aae38dee4db0fb0e4e"),l=0;l<=s-1;l++){u=y(u,a.substr(512l,512))}return function(e){for(var t="",n=0;n<e.length/8;n++)t+=r(parseInt(e.substr(8n,8),2).toString(16),2);return t}(u)}},function(e,t,n){"use strict";var r=0,o=32,i=16,a=[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],s=[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 u(e,t){return e<<t|e>>>32-t}function l(e){return(255&a[e>>>24&255])<<24|(255&a[e>>>16&255])<<16|(255&a[e>>>8&255])<<8|255&a[255&e]}function c(e){return e^u(e,2)^u(e,10)^u(e,18)^u(e,24)}function f(e){return e^u(e,13)^u(e,23)}function d(e,t,n){for(var r=void 0,o=void 0,i=new Array(4),a=new Array(4),s=0;s<4;s++)a[0]=255&e[0+4s],a[1]=255&e[1+4s],a[2]=255&e[2+4s],a[3]=255&e[3+4s],i[s]=a[0]<<24|a[1]<<16|a[2]<<8|a[3];for(r=0;r<32;r+=4)o=l(o=i[1]^i[2]^i[3]^n[r+0]),i[0]=i[0]^c(o),o=l(o=i[2]^i[3]^i[0]^n[r+1]),i[1]=i[1]^c(o),o=l(o=i[3]^i[0]^i[1]^n[r+2]),i[2]=i[2]^c(o),o=l(o=i[0]^i[1]^i[2]^n[r+3]),i[3]=i[3]^c(o);for(var u=0;u<16;u+=4)t[u]=i[3-u/4]>>>24&255,t[u+1]=i[3-u/4]>>>16&255,t[u+2]=i[3-u/4]>>>8&255,t[u+3]=255&i[3-u/4]}function h(e,t,n){var a=[],u=0,c=new Array(o);!function(e,t,n){for(var o=void 0,i=void 0,a=new Array(4),u=new Array(4),c=0;c<4;c++)u[0]=255&e[0+4c],u[1]=255&e[1+4c],u[2]=255&e[2+4c],u[3]=255&e[3+4c],a[c]=u[0]<<24|u[1]<<16|u[2]<<8|u[3];for(a[0]^=2746333894,a[1]^=1453994832,a[2]^=1736282519,a[3]^=2993693404,o=0;o<32;o+=4)i=l(i=a[1]^a[2]^a[3]^s[o+0]),t[o+0]=a[0]^=f(i),i=l(i=a[2]^a[3]^a[0]^s[o+1]),t[o+1]=a[1]^=f(i),i=l(i=a[3]^a[0]^a[1]^s[o+2]),t[o+2]=a[2]^=f(i),i=l(i=a[0]^a[1]^a[2]^s[o+3]),t[o+3]=a[3]^=f(i);if(n===r)for(o=0;o<16;o++)i=t[o],t[o]=t[31-o],t[31-o]=i}(t,c,n);new Array(16);for(var h=new Array(16),p=e.length;p>=i;){d(e.slice(u,u+16),h,c);for(var m=0;m<i;m++)a[u+m]=h[m];p-=i,u+=i}return a}e.exports={encrypt:function(e,t){return h(e,t,1)},decrypt:function(e,t){return h(e,t,0)}}},function(e,t,n){"use strict";var r,o,i,a,s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};a=function(e){return e},"object"===s(t)?e.exports=t=a(n(0),n(32),n(133),n(134),n(20),n(21),n(39),n(60),n(135),n(61),n(136),n(137),n(138),n(40),n(139),n(14),n(2),n(140),n(141),n(142),n(143),n(144),n(145),n(146),n(147),n(148),n(149),n(150),n(151),n(152),n(153),n(154),n(155)):(o=[n(0),n(32),n(133),n(134),n(20),n(21),n(39),n(60),n(135),n(61),n(136),n(137),n(138),n(40),n(139),n(14),n(2),n(140),n(141),n(142),n(143),n(144),n(145),n(146),n(147),n(148),n(149),n(150),n(151),n(152),n(153),n(154),n(155)],void 0===(i="function"==typeof(r=a)?r.apply(t,o):r)||(e.exports=i))},function(e,t,n){"use strict";var r=n(313),o=n(314),i=n(157);e.exports={formats:i,parse:o,stringify:r}},function(e,t,n){"use strict";var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o=n(156),i=n(157),a={brackets:function(e){return e+"[]"},indices:function(e,t){return e+"["+t+"]"},repeat:function(e){return e}},s=Date.prototype.toISOString,u={delimiter:"&",encode:!0,encoder:o.encode,encodeValuesOnly:!1,serializeDate:function(e){return s.call(e)},skipNulls:!1,strictNullHandling:!1},l=function e(t,n,r,i,a,s,l,c,f,d,h,p){var m=t;if("function"==typeof l)m=l(n,m);else if(m instanceof Date)m=d(m);else if(null===m){if(i)return s&&!p?s(n,u.encoder):n;m=""}if("string"==typeof m||"number"==typeof m||"boolean"==typeof m||o.isBuffer(m))return s?[h(p?n:s(n,u.encoder))+"="+h(s(m,u.encoder))]:[h(n)+"="+h(String(m))];var y,v=[];if(void 0===m)return v;if(Array.isArray(l))y=l;else{var g=Object.keys(m);y=c?g.sort(c):g}for(var b=0;b<y.length;++b){var =y[b];a&&null===m[]||(v=Array.isArray(m)?v.concat(e(m[],r(n,),r,i,a,s,l,c,f,d,h,p)):v.concat(e(m[],n+(f?"."+:"["++"]"),r,i,a,s,l,c,f,d,h,p)))}return v};e.exports=function(e,t){var n=e,s=t?o.assign({},t):{};if(null!==s.encoder&&void 0!==s.encoder&&"function"!=typeof s.encoder)throw new TypeError("Encoder has to be a function.");var c=void 0===s.delimiter?u.delimiter:s.delimiter,f="boolean"==typeof s.strictNullHandling?s.strictNullHandling:u.strictNullHandling,d="boolean"==typeof s.skipNulls?s.skipNulls:u.skipNulls,h="boolean"==typeof s.encode?s.encode:u.encode,p="function"==typeof s.encoder?s.encoder:u.encoder,m="function"==typeof s.sort?s.sort:null,y=void 0!==s.allowDots&&s.allowDots,v="function"==typeof s.serializeDate?s.serializeDate:u.serializeDate,g="boolean"==typeof s.encodeValuesOnly?s.encodeValuesOnly:u.encodeValuesOnly;if(void 0===s.format)s.format=i.default;else if(!Object.prototype.hasOwnProperty.call(i.formatters,s.format))throw new TypeError("Unknown format option provided.");var b,,w=i.formatters[s.format];"function"==typeof s.filter?n=(=s.filter)("",n):Array.isArray(s.filter)&&(b==s.filter);var S,E=[];if("object"!==(void 0===n?"undefined":r(n))||null===n)return"";S=s.arrayFormat in a?s.arrayFormat:"indices"in s?s.indices?"indices":"repeat":"indices";var k=a[S];b||(b=Object.keys(n)),m&&b.sort(m);for(var x=0;x<b.length;++x){var T=b[x];d&&null===n[T]||(E=E.concat(l(n[T],T,k,f,d,h?p:null,,m,y,v,w,g)))}var O=E.join(c),M=!0===s.addQueryPrefix?"?":"";return O.length>0?M+O:""}},function(e,t,n){"use strict";var r=n(156),o=Object.prototype.hasOwnProperty,i={allowDots:!1,allowPrototypes:!1,arrayLimit:20,decoder:r.decode,delimiter:"&",depth:5,parameterLimit:1e3,plainObjects:!1,strictNullHandling:!1},a=function(e,t,n){if(e){var r=n.allowDots?e.replace(/.([^.[]+)/g,"[$1]"):e,i=/(\[[^[\]]*])/g,a=/(\[[^[\]]*])/.exec(r),s=a?r.slice(0,a.index):r,u=[];if(s){if(!n.plainObjects&&o.call(Object.prototype,s)&&!n.allowPrototypes)return;u.push(s)}for(var l=0;null!==(a=i.exec(r))&&l<n.depth;){if(l+=1,!n.plainObjects&&o.call(Object.prototype,a[1].slice(1,-1))&&!n.allowPrototypes)return;u.push(a[1])}return a&&u.push("["+r.slice(a.index)+"]"),function(e,t,n){for(var r=t,o=e.length-1;o>=0;--o){var i,a=e[o];if("[]"===a)i=(i=[]).concat(r);else{i=n.plainObjects?Object.create(null):{};var s="["===a.charAt(0)&&"]"===a.charAt(a.length-1)?a.slice(1,-1):a,u=parseInt(s,10);!isNaN(u)&&a!==s&&String(u)===s&&u>=0&&n.parseArrays&&u<=n.arrayLimit?(i=[])[u]=r:i[s]=r}r=i}return r}(u,t,n)}};e.exports=function(e,t){var n=t?r.assign({},t):{};if(null!==n.decoder&&void 0!==n.decoder&&"function"!=typeof n.decoder)throw new TypeError("Decoder has to be a function.");if(n.ignoreQueryPrefix=!0===n.ignoreQueryPrefix,n.delimiter="string"==typeof n.delimiter||r.isRegExp(n.delimiter)?n.delimiter:i.delimiter,n.depth="number"==typeof n.depth?n.depth:i.depth,n.arrayLimit="number"==typeof n.arrayLimit?n.arrayLimit:i.arrayLimit,n.parseArrays=!1!==n.parseArrays,n.decoder="function"==typeof n.decoder?n.decoder:i.decoder,n.allowDots="boolean"==typeof n.allowDots?n.allowDots:i.allowDots,n.plainObjects="boolean"==typeof n.plainObjects?n.plainObjects:i.plainObjects,n.allowPrototypes="boolean"==typeof n.allowPrototypes?n.allowPrototypes:i.allowPrototypes,n.parameterLimit="number"==typeof n.parameterLimit?n.parameterLimit:i.parameterLimit,n.strictNullHandling="boolean"==typeof n.strictNullHandling?n.strictNullHandling:i.strictNullHandling,""===e||null==e)return n.plainObjects?Object.create(null):{};for(var s="string"==typeof e?function(e,t){for(var n={},r=t.ignoreQueryPrefix?e.replace(/^\?/,""):e,a=t.parameterLimit===1/0?void 0:t.parameterLimit,s=r.split(t.delimiter,a),u=0;u<s.length;++u){var l,c,f=s[u],d=f.indexOf("]="),h=-1===d?f.indexOf("="):d+1;-1===h?(l=t.decoder(f,i.decoder),c=t.strictNullHandling?null:""):(l=t.decoder(f.slice(0,h),i.decoder),c=t.decoder(f.slice(h+1),i.decoder)),o.call(n,l)?n[l]=[].concat(n[l]).concat(c):n[l]=c}return n}(e,n):e,u=n.plainObjects?Object.create(null):{},l=Object.keys(s),c=0;c<l.length;++c){var f=l[c],d=a(f,s[f],n);u=r.merge(u,d,n)}return r.compact(u)}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=c(n(11)),o=c(n(3)),i=c(n(4)),a=c(n(5)),s=c(n(6)),u=c(n(7)),l=c(n(1));function c(e){return e&&e.__esModule?e:{default:e}}var f=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&(n[r[o]]=e[r[o]])}return n},d=function(e){function t(){return(0,o.default)(this,t),(0,a.default)(this,(t.proto||Object.getPrototypeOf(t)).apply(this,arguments))}return(0,s.default)(t,e),(0,i.default)(t,[{key:"render",value:function(){var e=this.props,t=e.prefixCls,n=e.className,o=e.children,i=e.mode,a=e.icon,s=e.onLeftClick,c=e.leftContent,d=e.rightContent,h=f(e,["prefixCls","className","children","mode","icon","onLeftClick","leftContent","rightContent"]);return l.default.createElement("div",(0,r.default)({},h,{className:(0,u.default)(n,t,t+"-"+i)}),l.default.createElement("div",{className:t+"-left",role:"button",onClick:s},a?l.default.createElement("span",{className:t+"-left-icon","aria-hidden":"true"},a):null,c),l.default.createElement("div",{className:t+"-title"},o),l.default.createElement("div",{className:t+"-right"},d))}}]),t}(l.default.Component);t.default=d,d.defaultProps={prefixCls:"am-navbar",mode:"dark",onLeftClick:function(){}},e.exports=t.default},function(e,t,n){"use strict";n(30),n(317)},function(e,t,n){},,function(e,t,n){},,function(e,t,n){e.exports=n.p+"3Q-Az0gCDO.png"},function(e,t,n){},,,function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=n(1),i=d(o),a=n(23),s=n(24),u=d(n(15)),l=d(n(7)),c=d(n(8)),f=d(n(44));function d(e){return e&&e.__esModule?e:{default:e}}function h(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}n(326);var p=function(e){function t(){var e,n,r;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);for(var o=arguments.length,i=Array(o),a=0;a<o;a++)i[a]=arguments[a];return n=r=h(this,(e=t.proto||Object.getPrototypeOf(t)).call.apply(e,[this].concat(i))),r.initDatas=function(){var e=[],t=[];if(r.props.location.query){console.log("query is ",r.props.location.query);for(var n=0;n<r.props.location.query.length;n++)for(var o=0;o<c.default.customRouters.length;o++)if(r.props.location.query[n]===c.default.customRouters[o].routeName){e.push(c.default.customRouters[o]);break}}else for(n=0;n<c.default.pagesStore.searchTicket.searchResults.length;n++)for(o=0;o<c.default.customRouters.length;o++)if(c.default.pagesStore.searchTicket.searchResults[n]===c.default.customRouters[o].routeName){e.push(c.default.customRouters[o]);break}for(n=0;n<e.length;n++)for(o=0;o<e[n].stationCount;o++){if(c.default.pagesStore.indexPage.startStationRecord===e[n].stations[o].stationName){t.push(!1);break}if(c.default.pagesStore.indexPage.endStationRecord.stationName===e[n].stations[o].stationName){t.push(!0);break}}r.setState({searchResults:e,reverselist:t})},r.goToRouterMapPage=function(e,t){console.log("routeItem is ",t)},r.getRouterInfo=function(e,t){r.getRouterIndex=t,(0,s.postMethod)("/Controller/Csbs/Route/Query/findTripByRouteId",{routeCode:e.routeNumber,periodDays:30},r.getRouterInfoSuccess,r.getRouterInfoFail)},r.getRouterInfoSuccess=function(e){console.log("get router info success");var t={router:e,reverse:r.state.reverselist[r.getRouterIndex]};c.default.routerInfo=t,r.props.history.push({pathname:"./router-map",query:t})},r.getRouterInfoFail=function(e){console.log("get router info fail")},h(r,n)}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.proto=t)}(t,o.Component),r(t,[{key:"componentWillMount",value:function(){this.initDatas()}},{key:"componentDidMount",value:function(){}},{key:"render",value:function(){var e=this,t=this.state,n=t.searchResults,r=t.reverselist;return i.default.createElement("div",null,i.default.createElement(u.default,{title:"線路列表"}),i.default.createElement("div",{className:"tickets-all-div"},i.default.createElement("div",{className:"search-tickets-scrollview"},n.map(function(t,o){return i.default.createElement("div",{className:(0,l.default)("router-info-view",{"end-margin":o!==n.length-1}),key:"router-"+o,onClick:function(){e.getRouterInfo(t,o)}},i.default.createElement("div",{className:"router-info-row-1-view"},i.default.createElement("div",{className:"router-info-row-1-left-all-view"},i.default.createElement("div",{className:"router-info-row-1-left-router-text-view"},"網約公交"),i.default.createElement("div",{className:"router-info-row-1-left-router-view"},t.routeName+"路線")),i.default.createElement("div",{className:"router-info-row-1-first-time-view"},""+(r[o]?t.negFirstTripTime:t.firstTripTime))),i.default.createElement("div",{className:"router-info-row-2-view"},i.default.createElement("div",{className:"router-info-row-2-start-view"},""+(r[o]?t.finalStation.stationName:t.firstStation.stationName)),i.default.createElement("div",{className:"router-info-row-2-middle-view"},i.default.createElement("img",{src:f.default})),i.default.createElement("div",{className:"router-info-row-2-start-view"},""+(r[o]?t.firstStation.stationName:t.finalStation.stationName))),i.default.createElement("div",{className:"router-info-row-3-view"},i.default.createElement("div",{className:"left"},i.default.createElement("div",{className:"router-info-row-3-text-view"},"途徑"+t.stationCount+"站"),i.default.createElement("div",{className:"router-info-row-3-round-view"}),i.default.createElement("div",{className:"router-info-row-3-text-view"},"票價 MOP "+(t.routePrice/10).toFixed(1)),i.default.createElement("div",{className:"router-info-row-3-round-view"}),i.default.createElement("div",{className:"router-info-row-3-text-view"},"路程 約"+t.consumingTime+"分鐘")),i.default.createElement("div",{className:"right"},"一人一座")),i.default.createElement("div",{className:"router-info-row-4-view"},i.default.createElement("div",{className:"router-info-row-check-button",onClick:function(n){e.getRouterInfo(t,o)}},"查看")))}))))}}]),t}();t.default=(0,a.withRouter)(p)},function(e,t,n){},,function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=h(n(12)),o=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();n(13);var i=n(1),a=h(i),s=n(23),u=n(31),l=n(24),c=(n(41),h(n(15))),f=h(n(329)),d=h(n(8));function h(e){return e&&e.__esModule?e:{default:e}}n(342);r.default.alert;var p=function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),console.log("RouterMap constructor, ",e.location.query);var n=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.proto||Object.getPrototypeOf(t)).call(this,e));return n.checkTicketInfo=function(e){(0,l.postMethod)("/Controller/Csbs/Ticket/Biz/Query/findByTripId",{tripId:e},n.getTripTicketInfoSuccess)},n.getTripTicketInfoSuccess=function(e){e.length&&(console.log("getTripTicketInfoSuccess data ",e),d.default.routerTripTicketInfo=e,n.props.history.push({pathname:"./buy-ticket",query:!0}))},n.props.location.query?(n.routerInfo=n.props.location.query,n.routeNumber=n.routerInfo.router.routeNumber,n.title="網約公交-"+n.routerInfo.router.trip.routeName+"路線",n.mapCenter={longitude:113.320148,latitude:23.12256},console.log("this.routerInfo.router ",n.routerInfo.router)):(console.log("enter constructor else ",n.props.history),n.props.history.replace("./index-page")),n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.proto=t)}(t,i.Component),o(t,[{key:"componentWillMount",value:function(){this.offsetTop=515,this.paidOrders=[]}},{key:"componentDidMount",value:function(){var e=window.AMap,t=document.getElementById("map-container"),n=document.getElementById("draw-up-content-view");this.offsetTop=n.offsetTop,t.style.height=this.offsetTop-45+"px";var r=d.default.routeStations,o=this.getMapCenter(r),i=new e.Map("map-container",{resizeEnable:!0,dragEnable:!0,zoomEnable:!0,lang:"zh_hk",center:[o.longitude,o.latitude],zoom:13});if(i.plugin(["AMap.ToolBar"],function(){var t=new e.ToolBar(i);i.addControl(t)}),r&&r.length>0){var a=void 0,s=void 0,l=[];r.forEach(function(t,n){var o=(0,u.gps84ToGcj02)(t.latitude,t.longitude),c=t.stationName,f="

"+(n+1)+"
",d=new e.Text({text:f,textAlign:"center",verticalAlign:"middle",draggable:!1,raiseOnDrag:!1,cursor:"pointer",style:{background:"transparent",border:"none"},position:new e.LngLat(o.lng,o.lat)});if(d.setMap(i),d.on("click",function(){var t="
"+c+"
";new e.InfoWindow({content:t}).open(i,d.getPosition())}),0==n)a=new e.LngLat(o.lng,o.lat);else if(n==r.length-1)s=new e.LngLat(o.lng,o.lat);else if(n==r.length-2)s=new e.LngLat(o.lng,o.lat);else{var h=new e.LngLat(o.lng,o.lat);l.push(h)}}),new e.Driving({map:i}).search(a,s,{waypoints:l})}}},{key:"getMapCenter",value:function(e){var t={longitude:113.320148,latitude:23.12256};if(e&&e.length>0){var n=Math.ceil(e.length/2),r={lat:e[n].latitude,lng:e[n].longitude},o=(0,u.gps84ToGcj02)(r.lat,r.lng);t={longitude:o.lng,latitude:o.lat}}return t}},{key:"getLength",value:function(e){for(var t=0,n=e.length,r=-1,o=0;o<n;o++)t+=(r=e.charCodeAt(o))>=0&&r<=128?1:2;return t}},{key:"render",value:function(){return a.default.createElement("div",{className:"draw-up-view"},a.default.createElement(c.default,{title:this.title}),a.default.createElement("div",{id:"map-container",style:{position:"absolute",top:45,width:"100%",height:589}}),a.default.createElement(f.default,{onBuyTicket:this.checkTicketInfo}))}}]),t}();t.default=(0,s.withRouter)(p)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=d(n(107)),o=d(n(330)),i=d(n(12)),a=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();n(125),n(337),n(13);var s=n(1),u=d(s),l=d(n(8)),c=d(n(9)),f=d(n(44));function d(e){return e&&e.__esModule?e:{default:e}}n(340);var h=i.default.alert,p=function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var n=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.proto||Object.getPrototypeOf(t)).call(this,e));return n.initViewOffset=function(){for(var e=document.getElementsByClassName("station-col-line"),t=document.getElementsByClassName("round-icon"),n=0;n<e.length;n++)e[n].style.top=t[n].offsetTop+t[n].offsetHeight-1+"px",e[n].style.left=t[n].offsetLeft+t[n].offsetHeight/2-1+"px"},n.touchStart=function(e){if(!n.isAnimationMoving){console.log(e.touches[0].target.className);var t=document.getElementById("draw-up-content-view");n.clickDistance=e.touches[0].clientY-t.offsetTop,n.lastY=e.touches[0].clientY,n.lastDragTimestamp=e.timeStamp,n.dragSpeed=0}},n.touchMove=function(e){if(!n.isAnimationMoving){var t=document.getElementById("draw-up-content-view"),r=e.touches[0].clientY-n.clickDistance;r<n.maxDragTop&&(r=n.maxDragTop),r>n.initTop&&(r=n.initTop),t.style.top=r+"px",n.dragSpeed=e.touches[0].clientY-n.lastY,n.dragSpeed<0?n.dragDirction="up":n.dragSpeed>0&&(n.dragDirction="down"),n.lastY=e.touches[0].clientY}},n.touchEnd=function(e){if(!n.isAnimationMoving){var t=document.getElementById("draw-up-content-view"),r=n.dragSpeed/(e.timeStamp-n.lastDragTimestamp==0?.1:e.timeStamp-n.lastDragTimestamp);n.checkTouchBarHight(),n.moveAnimation(t.offsetTop,r,t)}},n.moveAnimation=function(e,t,r){if(console.log("startY ",e),0!==e)return n.count=0,Math.abs(t)>.3?(n.isAnimationMoving=!0,"up"===n.dragDirction?n.animationSpeed=(n.maxDragTop-e)/n.animationStep:n.animationSpeed=(n.initTop-e)/n.animationStep,void n.startAnimation(e,r)):e<=n.middleLine&&e!=n.maxDragTop?(n.isAnimationMoving=!0,n.animationSpeed=(n.maxDragTop-e)/n.animationStep,void n.startAnimation(e,r)):e>=n.middleLine&&e!=n.initTop?(n.isAnimationMoving=!0,n.animationSpeed=(n.initTop-e)/n.animationStep,void n.startAnimation(e,r)):void 0},n.startAnimation=function(e,t){n.counting=window.setInterval(function(){t.style.top=e+(n.count+1)n.animationSpeed+"px",n.count++,n.count>=n.animationStep&&(n.isAnimationMoving=!1,n.checkTouchBarHight(),window.clearInterval(n.counting))},n.animationFrameTime)},n.checkTouchBarHight=function(){var e=document.getElementsByClassName("draw-up-info-control-view")[0];0!=e.offsetTop&&(console.log("found touch div not on the top"),e.style.top="0px");var t=document.getElementsByClassName("draw-up-toolbar-view")[0],n=document.getElementsByClassName("draw-up-timeline-view")[0];console.log(n.offsetTop+" and "+t.offsetTop+" and "+n.parentNode.offsetTop),console.log("time schedule bottom - pay top ",n.offsetHeight-(n.offsetTop+n.offsetHeight-t.offsetTop)),n.style.height!=t.offsetTop-(n.offsetTop+n.parentNode.offsetTop)&&(n.style.height=t.offsetTop-(n.offsetTop+n.parentNode.offsetTop)+"px")},n.initRouterInfo=function(e){if(l.default.routerInfo.router){var t=e?l.default.routerInfo.router.returnTrip:l.default.routerInfo.router.trip;if(n.showReturn=l.default.routerInfo.router.returnTrip.timeLines.length>0&&l.default.routerInfo.router.trip.timeLines.length>0,0==t.timeLines.length)return n.setState({isReverse:e,routerStations:null,startTimes:[],eachStationInfo:[]}),void h("溫馨提示","沒有該線路數據",[{text:"確認",onPress:function(){return window.history.back()}}]);n.tripIndex=0;for(var r=[],o=[],i=0;i<t.timeLines.length;i++)i%n.timeScheduleLengthOnePage==0&&0!==i&&(r.push(o),o=[]),o.push(t.timeLines[i].routeTime);r.push(o);var a=n.initRouterStationTime(t,r,0,0);n.setState({isReverse:e,routerStations:t,startTimes:r,eachStationInfo:a})}else n.setState({isReverse:e,routerStations:null,startTimes:[],eachStationInfo:[]})},n.initRouterStationTime=function(e,t,n,r){console.log("row "+n+" col "+r);for(var o=t[n][r],i=0,a=[],s=0;s<e.stations.length;s++){var u={};u.stationName=e.stations[s].stationName,i+=e.stations[s].shiftTime,u.stationTime=(0,c.default)(o,"HH:mm").add(i,"minutes").format("HH:mm"),a.push(u)}return a},n.reverseStataions=function(){var e=!n.state.isReverse;n.initRouterInfo(e)},n.showRouterTime=function(){var e=document.getElementById("draw-up-content-view");console.log("dragView.offsetTop ",e.offsetTop),e.offsetTop-n.maxDragTop>2&&(n.count=0,n.isAnimationMoving=!0,n.animationSpeed=(n.maxDragTop-e.offsetTop)/n.animationStep,n.startAnimation(e.offsetTop,e))},n.buyTicket=function(){console.log(n.props);var e=n.state.routerStations;console.log("routerStations ",e),0!=e.timeLines[n.tripIndex].unsoldTickets?(l.default.buyTicketRouterInfo={routeName:e.routeName,routeNumber:e.routeNumber,routePrice:e.routePrice,firstStation:e.firstStation,finalStation:e.finalStation,routeTime:e.timeLines[n.tripIndex].routeTime,tripId:e.timeLines[n.tripIndex].tripId,consumingTime:e.consumingTime,stationCount:e.stationCount},console.log("tripId is ",e.timeLines[n.tripIndex].tripId),n.props.onBuyTicket(e.timeLines[n.tripIndex].tripId)):h("溫馨提示","該班次車票已售光,請選擇其他班次",[{text:"確認",onPress:function(){return console.log("ok")}}])},n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.proto=t)}(t,s.Component),a(t,[{key:"componentWillMount",value:function(){this.clickDistance=0,this.lastY=0,this.initTop=0,this.maxDragTop=0,this.middleLine=0,this.count=0,this.isAnimationMoving=!1,this.animationStep=20,this.animationCount=0,this.animationSpeed=0,this.animationFrameTime=15,this.lastDragTimestamp=0,this.dragSpeed=0,this.dragDirction="",this.tripIndex=0,this.timeScheduleLengthOnePage=5,this.initRouterInfo(l.default.routerInfo.reverse)}},{key:"componentDidMount",value:function(){var e=document.getElementById("draw-up-content-view");this.initTop=e.offsetTop,this.maxDragTop=e.offsetHeight/.84-e.offsetHeight,this.middleLine=(this.initTop-this.maxDragTop)/2+this.maxDragTop,console.log("this.initTop "+this.initTop+" this.maxDragTop "+this.maxDragTop),console.log("this.middleline ",this.middleLine),this.initViewOffset()}},{key:"selectTimeSchedule",value:function(e,t,n){console.log(e,t,n);var r=document.querySelectorAll("a[id^=item]");console.log("all items is ",r);for(var o=document.querySelector("#item"+t+n),i=0;i<r.length;i++)r[i].className="time-item";o.className="time-item checked";var a=this.state,s=a.routerStations,u=a.startTimes,l=this.initRouterStationTime(s,u,t,n);this.tripIndex=tthis.timeScheduleLengthOnePage+n,this.setState({eachStationInfo:l})}},{key:"render",value:function(){var e=this,t=this.state,n=t.routerStations,i=t.startTimes,a=t.eachStationInfo;return console.log("eachStationInfo in render is ",a),l.default.routerInfo.router&&null!=n?u.default.createElement("div",null,u.default.createElement("div",{id:"draw-up-content-view",className:"draw-up-info-view"},u.default.createElement("div",{className:"draw-up-info-control-view",onTouchStart:function(t){return e.touchStart(t)},onTouchMove:function(t){return e.touchMove(t)},onTouchEnd:function(t){return e.touchEnd(t)}},u.default.createElement("div",{className:"draw-up-bar"})),u.default.createElement("div",{className:"draw-up-stations-view"},u.default.createElement("div",{className:"start-station"},n.firstStation.stationName),u.default.createElement("div",{className:"exchange-icon"},u.default.createElement("img",{src:f.default})),u.default.createElement("div",{className:"end-station"},n.finalStation.stationName)),u.default.createElement("div",{className:"draw-up-action-view"},u.default.createElement("div",null,u.default.createElement("div",{className:"router-name"},"網約公交-",n.routeName,"線路"),this.showReturn?u.default.createElement("div",{className:"router-direction",onClick:this.reverseStataions},"回程"):""),u.default.createElement("div",{className:"show-schedule",onClick:this.showRouterTime},"查看發車時間")),u.default.createElement("div",{className:"draw-up-schedule-view"},u.default.createElement("div",{className:"send-car"},"發車班次"),u.default.createElement(r.default,{className:"time-schedules"},u.default.createElement(o.default,{autoplay:!1,dots:!1,infinite:!0,afterChange:function(e){return console.log("slide to",e)}},i.map(function(t,n){return u.default.createElement("div",{className:"time-list",key:n},t.map(function(t,r){return u.default.createElement("a",{key:n+r,id:"item"+n+r,className:e.tripIndex/e.timeScheduleLengthOnePage==n&&e.tripIndex%e.timeScheduleLengthOnePage==r?"time-item checked":"time-item",onClick:function(t){e.selectTimeSchedule(t,n,r)}},t)}))})))),u.default.createElement("div",{className:"draw-up-timeline-view"},u.default.createElement("div",{className:"start-time-text"},"發車時間"),a.map(function(e,t){return u.default.createElement("div",{className:"each-line",key:"each-line-"+t},u.default.createElement("div",{className:"round-icon"}),u.default.createElement("div",{className:t==a.length-1?"":"station-col-line"}),u.default.createElement("div",{className:"station-time"},e.stationTime),u.default.createElement("div",{className:"station-name"},e.stationName))}))),u.default.createElement("div",{className:"draw-up-toolbar-view"},u.default.createElement("div",{className:"price-text"},"票價:"),u.default.createElement("div",{className:"price"},"MOP ",(n.routePrice/10).toFixed(1)),u.default.createElement("div",{className:"btn-buy-ticket"},u.default.createElement("button",{onClick:this.buyTicket},"立即購票")))):u.default.createElement("div",{id:"draw-up-content-view",className:"draw-up-info-view"},u.default.createElement("div",{className:"draw-up-info-control-view"},u.default.createElement("div",{className:"draw-up-bar"})))}}]),t}();t.default=p},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=d(n(28)),o=d(n(11)),i=d(n(3)),a=d(n(4)),s=d(n(5)),u=d(n(6)),l=d(n(7)),c=d(n(1)),f=d(n(331));function d(e){return e&&e.__esModule?e:{default:e}}var h=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&(n[r[o]]=e[r[o]])}return n},p=function(e){function t(e){(0,i.default)(this,t);var n=(0,s.default)(this,(t.proto||Object.getPrototypeOf(t)).call(this,e));return n.onChange=function(e){n.setState({selectedIndex:e},function(){n.props.afterChange&&n.props.afterChange(e)})},n.state={selectedIndex:n.props.selectedIndex},n}return(0,u.default)(t,e),(0,a.default)(t,[{key:"render",value:function(){var e=this.props,t=e.infinite,n=e.selectedIndex,i=e.beforeChange,a=(e.afterChange,e.dots),s=h(e,["infinite","selectedIndex","beforeChange","afterChange","dots"]),u=s.prefixCls,d=s.dotActiveStyle,p=s.dotStyle,m=s.className,y=s.vertical,v=(0,o.default)({},s,{wrapAround:t,slideIndex:n,beforeSlide:i}),g=[];a&&(g=[{component:function(e){for(var t=e.slideCount,n=e.slidesToScroll,o=e.currentSlide,i=[],a=0;a<t;a+=n)i.push(a);var s=i.map(function(e){var t=(0,l.default)(u+"-wrap-dot",(0,r.default)({},u+"-wrap-dot-active",e===o)),n=e===o?d:p;return c.default.createElement("div",{className:t,key:e},c.default.createElement("span",{style:n}))});return c.default.createElement("div",{className:u+"-wrap"},s)},position:"BottomCenter"}]);var b=(0,l.default)(u,m,(0,r.default)({},u+"-vertical",y));return c.default.createElement(f.default,(0,o.default)({},v,{className:b,decorators:g,afterSlide:this.onChange}))}}]),t}(c.default.Component);t.default=p,p.defaultProps={prefixCls:"am-carousel",dots:!0,arrows:!1,autoplay:!1,infinite:!1,cellAlign:"center",selectedIndex:0,dotStyle:{},dotActiveStyle:{}},e.exports=t.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(332);Object.defineProperty(t,"default",{enumerable:!0,get:function(){return(e=r,e&&e.__esModule?e:{default:e}).default;var e}})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=d(n(11)),o=d(n(3)),i=d(n(4)),a=d(n(5)),s=d(n(6)),u=d(n(1)),l=d(n(333)),c=d(n(334)),f=d(n(335));function d(e){return e&&e.__esModule?e:{default:e}}var h={ADDITIVE:"ADDITIVE",DESTRUCTIVE:"DESTRUCTIVE"},p=function(e,t,n){null!=e&&(e.addEventListener?e.addEventListener(t,n,!1):e.attachEvent?e.attachEvent("on"+t,n):e["on"+t]=n)},m=function(e,t,n){null!=e&&(e.removeEventListener?e.removeEventListener(t,n,!1):e.detachEvent?e.detachEvent("on"+t,n):e["on"+t]=null)},y=function(e){function t(e){(0,o.default)(this,t);var n=(0,a.default)(this,(t.proto||Object.getPrototypeOf(t)).call(this,e));return n._rafCb=function(){var e=n.state;if(0!==e.tweenQueue.length){for(var t=Date.now(),r=[],o=0;o<e.tweenQueue.length;o++){var i=e.tweenQueue[o],a=i.initTime,s=i.config;t-a<s.duration?r.push(i):s.onEnd&&s.onEnd()}-1!==n._rafID&&(n.setState({tweenQueue:r}),n._rafID=(0,f.default)(n._rafCb))}},n.handleClick=function(e){!0===n.clickSafe&&(e.preventDefault(),e.stopPropagation(),e.nativeEvent&&e.nativeEvent.stopPropagation())},n.autoplayIterator=function(){if(n.props.wrapAround)return n.nextSlide();n.state.currentSlide!==n.state.slideCount-n.state.slidesToShow?n.nextSlide():n.stopAutoplay()},n.goToSlide=function(e){var t=n.props,r=t.beforeSlide,o=t.afterSlide;if(e>=u.default.Children.count(n.props.children)||e<0){if(!n.props.wrapAround)return;if(e>=u.default.Children.count(n.props.children))return r(n.state.currentSlide,0),n.setState({currentSlide:0},function(){n.animateSlide(null,null,n.getTargetLeft(null,e),function(){n.animateSlide(null,.01),o(0),n.resetAutoplay(),n.setExternalData()})});var i=u.default.Children.count(n.props.children)-n.state.slidesToScroll;return r(n.state.currentSlide,i),n.setState({currentSlide:i},function(){n.animateSlide(null,null,n.getTargetLeft(null,e),function(){n.animateSlide(null,.01),o(i),n.resetAutoplay(),n.setExternalData()})})}r(n.state.currentSlide,e),n.setState({currentSlide:e},function(){n.animateSlide(),n.props.afterSlide(e),n.resetAutoplay(),n.setExternalData()})},n.nextSlide=function(){var e=u.default.Children.count(n.props.children),t=n.props.slidesToShow;if("auto"===n.props.slidesToScroll&&(t=n.state.slidesToScroll),!(n.state.currentSlide>=e-t)||n.props.wrapAround)if(n.props.wrapAround)n.goToSlide(n.state.currentSlide+n.state.slidesToScroll);else{if(1!==n.props.slideWidth)return n.goToSlide(n.state.currentSlide+n.state.slidesToScroll);n.goToSlide(Math.min(n.state.currentSlide+n.state.slidesToScroll,e-t))}},n.previousSlide=function(){n.state.currentSlide<=0&&!n.props.wrapAround||(n.props.wrapAround?n.goToSlide(n.state.currentSlide-n.state.slidesToScroll):n.goToSlide(Math.max(0,n.state.currentSlide-n.state.slidesToScroll)))},n.onResize=function(){n.setDimensions()},n.onReadyStateChange=function(){n.setDimensions()},n.state={currentSlide:n.props.slideIndex,dragging:!1,frameWidth:0,left:0,slideCount:0,slidesToScroll:n.props.slidesToScroll,slideWidth:0,top:0,tweenQueue:[]},n.touchObject={},n.clickSafe=!0,n}return(0,s.default)(t,e),(0,i.default)(t,[{key:"componentWillMount",value:function(){this.setInitialDimensions()}},{key:"componentDidMount",value:function(){this.setDimensions(),this.bindEvents(),this.setExternalData(),this.props.autoplay&&this.startAutoplay()}},{key:"componentWillReceiveProps",value:function(e){this.setState({slideCount:e.children.length}),this.setDimensions(e),this.props.slideIndex!==e.slideIndex&&e.slideIndex!==this.state.currentSlide&&this.goToSlide(e.slideIndex),this.props.autoplay!==e.autoplay&&(e.autoplay?this.startAutoplay():this.stopAutoplay())}},{key:"componentWillUnmount",value:function(){this.unbindEvents(),this.stopAutoplay(),f.default.cancel(this._rafID),this._rafID=-1}},{key:"tweenState",value:function(e,t){var n=this,r=t.easing,o=t.duration,i=t.delay,a=t.beginValue,s=t.endValue,u=t.onEnd,l=t.stackBehavior;this.setState(function(t){var c=t,d=void 0,p=void 0;if("string"==typeof e)d=e,p=e;else{for(var m=0;m<e.length-1;m++)c=c[e[m]];d=e[e.length-1],p=e.join("|")}var y={easing:r,duration:null==o?300:o,delay:null==i?0:i,beginValue:null==a?c[d]:a,endValue:s,onEnd:u,stackBehavior:l||"ADDITIVE"},v=t.tweenQueue;return y.stackBehavior===h.DESTRUCTIVE&&(v=t.tweenQueue.filter(function(e){return e.pathHash!==p})),v.push({pathHash:p,config:y,initTime:Date.now()+y.delay}),c[d]=y.endValue,1===v.length&&(n._rafID=(0,f.default)(n._rafCb)),{tweenQueue:v}})}},{key:"getTweeningValue",value:function(e){var t=this.state,n=void 0,r=void 0;if("string"==typeof e)n=t[e],r=e;else{n=t;for(var o=0;o<e.length;o++)n=n[e[o]];r=e.join("|")}for(var i=Date.now(),a=0;a<t.tweenQueue.length;a++){var s=t.tweenQueue[a],u=s.pathHash,l=s.initTime,c=s.config;if(u===r){var f=i-l>c.duration?c.duration:Math.max(0,i-l);n+=(0===c.duration?c.endValue:c.easing(f,c.beginValue,c.endValue,c.duration))-c.endValue}}return n}},{key:"render",value:function(){var e=this,t=u.default.Children.count(this.props.children)>1?this.formatChildren(this.props.children):this.props.children;return u.default.createElement("div",{className:["slider",this.props.className||""].join(" "),ref:"slider",style:(0,r.default)({},this.getSliderStyles(),this.props.style)},u.default.createElement("div",(0,r.default)({className:"slider-frame",ref:"frame",style:this.getFrameStyles()},this.getTouchEvents(),this.getMouseEvents(),{onClick:this.handleClick}),u.default.createElement("ul",{className:"slider-list",ref:"list",style:this.getListStyles()},t)),this.props.decorators?this.props.decorators.map(function(t,n){return u.default.createElement("div",{style:(0,r.default)({},e.getDecoratorStyles(t.position),t.style||{}),className:"slider-decorator-"+n,key:n},u.default.createElement(t.component,{currentSlide:e.state.currentSlide,slideCount:e.state.slideCount,frameWidth:e.state.frameWidth,slideWidth:e.state.slideWidth,slidesToScroll:e.state.slidesToScroll,cellSpacing:e.props.cellSpacing,slidesToShow:e.props.slidesToShow,wrapAround:e.props.wrapAround,nextSlide:e.nextSlide,previousSlide:e.previousSlide,goToSlide:e.goToSlide}))}):null,u.default.createElement("style",{type:"text/css",dangerouslySetInnerHTML:{__html:this.getStyleTagStyles()}}))}},{key:"getTouchEvents",value:function(){var e=this;return!1===this.props.swiping?null:{onTouchStart:function(t){e.touchObject={startX:t.touches[0].pageX,startY:t.touches[0].pageY},e.handleMouseOver()},onTouchMove:function(t){var n=e.swipeDirection(e.touchObject.startX,t.touches[0].pageX,e.touchObject.startY,t.touches[0].pageY);0!==n&&t.preventDefault();var r=e.props.vertical?Math.round(Math.sqrt(Math.pow(t.touches[0].pageY-e.touchObject.startY,2))):Math.round(Math.sqrt(Math.pow(t.touches[0].pageX-e.touchObject.startX,2)));e.touchObject={startX:e.touchObject.startX,startY:e.touchObject.startY,endX:t.touches[0].pageX,endY:t.touches[0].pageY,length:r,direction:n},e.setState({left:e.props.vertical?0:e.getTargetLeft(e.touchObject.lengthe.touchObject.direction),top:e.props.vertical?e.getTargetLeft(e.touchObject.lengthe.touchObject.direction):0})},onTouchEnd:function(t){e.handleSwipe(t),e.handleMouseOut()},onTouchCancel:function(t){e.handleSwipe(t)}}}},{key:"getMouseEvents",value:function(){var e=this;return!1===this.props.dragging?null:{onMouseOver:function(){e.handleMouseOver()},onMouseOut:function(){e.handleMouseOut()},onMouseDown:function(t){e.touchObject={startX:t.clientX,startY:t.clientY},e.setState({dragging:!0})},onMouseMove:function(t){if(e.state.dragging){var n=e.swipeDirection(e.touchObject.startX,t.clientX,e.touchObject.startY,t.clientY);0!==n&&t.preventDefault();var r=e.props.vertical?Math.round(Math.sqrt(Math.pow(t.clientY-e.touchObject.startY,2))):Math.round(Math.sqrt(Math.pow(t.clientX-e.touchObject.startX,2)));e.touchObject={startX:e.touchObject.startX,startY:e.touchObject.startY,endX:t.clientX,endY:t.clientY,length:r,direction:n},e.setState({left:e.props.vertical?0:e.getTargetLeft(e.touchObject.lengthe.touchObject.direction),top:e.props.vertical?e.getTargetLeft(e.touchObject.lengthe.touchObject.direction):0})}},onMouseUp:function(t){e.state.dragging&&e.handleSwipe(t)},onMouseLeave:function(t){e.state.dragging&&e.handleSwipe(t)}}}},{key:"handleMouseOver",value:function(){this.props.autoplay&&(this.autoplayPaused=!0,this.stopAutoplay())}},{key:"handleMouseOut",value:function(){this.props.autoplay&&this.autoplayPaused&&(this.startAutoplay(),this.autoplayPaused=null)}},{key:"handleSwipe",value:function(e){void 0!==this.touchObject.length&&this.touchObject.length>44?this.clickSafe=!0:this.clickSafe=!1;var t=this.props,n=t.slidesToShow,r=t.slidesToScroll,o=t.swipeSpeed;"auto"===r&&(n=this.state.slidesToScroll),u.default.Children.count(this.props.children)>1&&this.touchObject.length>this.state.slideWidth/n/o?1===this.touchObject.direction?this.state.currentSlide>=u.default.Children.count(this.props.children)-n&&!this.props.wrapAround?this.animateSlide(this.props.edgeEasing):this.nextSlide():-1===this.touchObject.direction&&(this.state.currentSlide<=0&&!this.props.wrapAround?this.animateSlide(this.props.edgeEasing):this.previousSlide()):this.goToSlide(this.state.currentSlide),this.touchObject={},this.setState({dragging:!1})}},{key:"swipeDirection",value:function(e,t,n,r){var o=e-t,i=n-r,a=Math.atan2(i,o),s=Math.round(180a/Math.PI);return s<0&&(s=360-Math.abs(s)),s<=45&&s>=0?1:s<=360&&s>=315?1:s>=135&&s<=225?-1:!0===this.props.vertical?s>=35&&s<=135?1:-1:0}},{key:"startAutoplay",value:function(){u.default.Children.count(this.props.children)<=1||(this.autoplayID=setInterval(this.autoplayIterator,this.props.autoplayInterval))}},{key:"resetAutoplay",value:function(){this.props.resetAutoplay&&this.props.autoplay&&!this.autoplayPaused&&(this.stopAutoplay(),this.startAutoplay())}},{key:"stopAutoplay",value:function(){this.autoplayID&&clearInterval(this.autoplayID)}},{key:"animateSlide",value:function(e,t,n,r){this.tweenState(this.props.vertical?"top":"left",{easing:e||this.props.easing,duration:t||this.props.speed,endValue:n||this.getTargetLeft(),delay:null,beginValue:null,onEnd:r||null,stackBehavior:h})}},{key:"getTargetLeft",value:function(e,t){var n=void 0,r=t||this.state.currentSlide,o=this.props.cellSpacing;switch(this.props.cellAlign){case"left":n=0,n-=or;break;case"center":n=(this.state.frameWidth-this.state.slideWidth)/2,n-=or;break;case"right":n=this.state.frameWidth-this.state.slideWidth,n-=or}var i=this.state.slideWidthr;return this.state.currentSlide>0&&r+this.state.slidesToScroll>=this.state.slideCount&&1!==this.props.slideWidth&&!this.props.wrapAround&&"auto"===this.props.slidesToScroll&&(i=this.state.slideWidththis.state.slideCount-this.state.frameWidth,n=0,n-=o*(this.state.slideCount-1)),-1*(i-(n-=e||0))}},{key:"bindEvents",value:function(){c.default.canUseDOM&&(p(window,"resize",this.onResize),p(document,"readystatechange",this.onReadyStateChange))}},{key:"unbindEvents",value:function(){c.default.canUseDOM&&(m(window,"resize",this.onResize),m(document,"readystatechange",this.onReadyStateChange))}},{key:"formatChildren",value:function(e){var t=this,n=this.props.vertical?this.getTweeningValue("top"):this.getTweeningValue("left");return u.default.Children.map(e,function(e,r){return u.default.createElement("li",{className:"slider-slide",style:t.getSlideStyles(r,n),key:r},e)})}},{key:"setInitialDimensions",value:function(){var e=this,t=this.props,n=t.vertical,r=t.initialSlideHeight,o=t.initialSlideWidth,i=t.slidesToShow,a=t.cellSpacing,s=t.children,l=n?r||0:o||0,c=r?ri:0,f=c+a(i-1);this.setState({slideHeight:c,frameWidth:n?f:"100%",slideCount:u.default.Children.count(s),slideWidth:l},function(){e.setLeft(),e.setExternalData()})}},{key:"setDimensions",value:function(e){var t,n,r=this,o=void 0,i=void 0,a=(e=e||this.props).slidesToScroll,s=this.refs.frame,u=s.childNodes[0].childNodes[0];u?(u.style.height="auto",o=this.props.vertical?u.offsetHeighte.slidesToShow:u.offsetHeight):o=100,i="number"!=typeof e.slideWidth?parseInt(e.slideWidth,10):e.vertical?o/e.slidesToShowe.slideWidth:s.offsetWidth/e.slidesToShowe.slideWidth,e.vertical||(i-=e.cellSpacing((100-100/e.slidesToShow)/100)),n=o+e.cellSpacing*(e.slidesToShow-1),t=e.vertical?n:s.offsetWidth,"auto"===e.slidesToScroll&&(a=Math.floor(t/(i+e.cellSpacing))),this.setState({slideHeight:o,frameWidth:t,slideWidth:i,slidesToScroll:a,left:e.vertical?0:this.getTargetLeft(),top:e.vertical?this.getTargetLeft():0},function(){r.setLeft()})}},{key:"setLeft",value:function(){this.setState({left:this.props.vertical?0:this.getTargetLeft(),top:this.props.vertical?this.getTargetLeft():0})}},{key:"setExternalData",value:function(){this.props.data&&this.props.data()}},{key:"getListStyles",value:function(){var e=this.state.slideWidthu.default.Children.count(this.props.children),t=this.props.cellSpacing,n=tu.default.Children.count(this.props.children),r="translate3d("+this.getTweeningValue("left")+"px, "+this.getTweeningValue("top")+"px, 0)";return{transform:r,WebkitTransform:r,msTransform:"translate("+this.getTweeningValue("left")+"px, "+this.getTweeningValue("top")+"px)",position:"relative",display:"block",margin:this.props.vertical?t/2*-1+"px 0px":"0px "+t/2*-1+"px",padding:0,height:this.props.vertical?e+n:this.state.slideHeight,width:this.props.vertical?"auto":e+n,cursor:!0===this.state.dragging?"pointer":"inherit",boxSizing:"border-box",MozBoxSizing:"border-box"}}},{key:"getFrameStyles",value:function(){return{position:"relative",display:"block",overflow:this.props.frameOverflow,height:this.props.vertical?this.state.frameWidth||"initial":"auto",margin:this.props.framePadding,padding:0,transform:"translate3d(0, 0, 0)",WebkitTransform:"translate3d(0, 0, 0)",msTransform:"translate(0, 0)",boxSizing:"border-box",MozBoxSizing:"border-box"}}},{key:"getSlideStyles",value:function(e,t){var n=this.getSlideTargetPosition(e,t),r=this.props.cellSpacing;return{position:"absolute",left:this.props.vertical?0:n,top:this.props.vertical?n:0,display:this.props.vertical?"block":"inline-block",listStyleType:"none",verticalAlign:"top",width:this.props.vertical?"100%":this.state.slideWidth,height:"auto",boxSizing:"border-box",MozBoxSizing:"border-box",marginLeft:this.props.vertical?"auto":r/2,marginRight:this.props.vertical?"auto":r/2,marginTop:this.props.vertical?r/2:"auto",marginBottom:this.props.vertical?r/2:"auto"}}},{key:"getSlideTargetPosition",value:function(e,t){var n=this.state.frameWidth/this.state.slideWidth,r=(this.state.slideWidth+this.props.cellSpacing)e,o=(this.state.slideWidth+this.props.cellSpacing)n-1;if(this.props.wrapAround){var i=Math.ceil(t/this.state.slideWidth);if(this.state.slideCount-i<=e)return(this.state.slideWidth+this.props.cellSpacing)(this.state.slideCount-e)-1;var a=Math.ceil((Math.abs(t)-Math.abs(o))/this.state.slideWidth);if(1!==this.state.slideWidth&&(a=Math.ceil((Math.abs(t)-this.state.slideWidth)/this.state.slideWidth)),e<=a-1)return(this.state.slideWidth+this.props.cellSpacing)(this.state.slideCount+e)}return r}},{key:"getSliderStyles",value:function(){return{position:"relative",display:"block",width:this.props.width,height:"auto",boxSizing:"border-box",MozBoxSizing:"border-box",visibility:this.state.slideWidth?"visible":"hidden"}}},{key:"getStyleTagStyles",value:function(){return".slider-slide > img {width: 100%; display: block;}"}},{key:"getDecoratorStyles",value:function(e){switch(e){case"TopLeft":return{position:"absolute",top:0,left:0};case"TopCenter":return{position:"absolute",top:0,left:"50%",transform:"translateX(-50%)",WebkitTransform:"translateX(-50%)",msTransform:"translateX(-50%)"};case"TopRight":return{position:"absolute",top:0,right:0};case"CenterLeft":return{position:"absolute",top:"50%",left:0,transform:"translateY(-50%)",WebkitTransform:"translateY(-50%)",msTransform:"translateY(-50%)"};case"CenterCenter":return{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%,-50%)",WebkitTransform:"translate(-50%, -50%)",msTransform:"translate(-50%, -50%)"};case"CenterRight":return{position:"absolute",top:"50%",right:0,transform:"translateY(-50%)",WebkitTransform:"translateY(-50%)",msTransform:"translateY(-50%)"};case"BottomLeft":return{position:"absolute",bottom:0,left:0};case"BottomCenter":return{position:"absolute",bottom:0,width:"100%",textAlign:"center"};case"BottomRight":return{position:"absolute",bottom:0,right:0};default:return{position:"absolute",top:0,left:0}}}}]),t}(u.default.Component);y.defaultProps={afterSlide:function(){},autoplay:!1,resetAutoplay:!0,swipeSpeed:12,autoplayInterval:3e3,beforeSlide:function(){},cellAlign:"left",cellSpacing:0,data:function(){},decorators:l.default,dragging:!0,easing:function(e,t,n,r){return(n-t)*Math.sqrt(1-(e=e/r-1)*e)+t},edgeEasing:function(e,t,n,r){return(n-t)*e/r+t},framePadding:"0px",frameOverflow:"hidden",slideIndex:0,slidesToScroll:1,slidesToShow:1,slideWidth:1,speed:500,swiping:!0,vertical:!1,width:"100%",wrapAround:!1,style:{}},t.default=y},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=u(n(3)),o=u(n(4)),i=u(n(5)),a=u(n(6)),s=u(n(1));function u(e){return e&&e.__esModule?e:{default:e}}var l=[{component:function(e){function t(){(0,r.default)(this,t);var e=(0,i.default)(this,(t.proto||Object.getPrototypeOf(t)).apply(this,arguments));return e.handleClick=function(t){t.preventDefault(),e.props.previousSlide()},e}return(0,a.default)(t,e),(0,o.default)(t,[{key:"render",value:function(){return s.default.createElement("button",{style:this.getButtonStyles(0===this.props.currentSlide&&!this.props.wrapAround),onClick:this.handleClick},"PREV")}},{key:"getButtonStyles",value:function(e){return{border:0,background:"rgba(0,0,0,0.4)",color:"white",padding:10,outline:0,opacity:e?.3:1,cursor:"pointer"}}}]),t}(s.default.Component),position:"CenterLeft"},{component:function(e){function t(){(0,r.default)(this,t);var e=(0,i.default)(this,(t.proto||Object.getPrototypeOf(t)).apply(this,arguments));return e.handleClick=function(t){t.preventDefault(),e.props.nextSlide&&e.props.nextSlide()},e}return(0,a.default)(t,e),(0,o.default)(t,[{key:"render",value:function(){return s.default.createElement("button",{style:this.getButtonStyles(this.props.currentSlide+this.props.slidesToScroll>=this.props.slideCount&&!this.props.wrapAround),onClick:this.handleClick},"NEXT")}},{key:"getButtonStyles",value:function(e){return{border:0,background:"rgba(0,0,0,0.4)",color:"white",padding:10,outline:0,opacity:e?.3:1,cursor:"pointer"}}}]),t}(s.default.Component),position:"CenterRight"},{component:function(e){function t(){return(0,r.default)(this,t),(0,i.default)(this,(t.proto||Object.getPrototypeOf(t)).apply(this,arguments))}return(0,a.default)(t,e),(0,o.default)(t,[{key:"render",value:function(){var e=this,t=this.getIndexes(this.props.slideCount,this.props.slidesToScroll);return s.default.createElement("ul",{style:this.getListStyles()},t.map(function(t){return s.default.createElement("li",{style:e.getListItemStyles(),key:t},s.default.createElement("button",{style:e.getButtonStyles(e.props.currentSlide===t),onClick:e.props.goToSlide&&e.props.goToSlide.bind(null,t)},"•"))}))}},{key:"getIndexes",value:function(e,t){for(var n=[],r=0;r<e;r+=t)n.push(r);return n}},{key:"getListStyles",value:function(){return{position:"relative",margin:0,top:-10,padding:0}}},{key:"getListItemStyles",value:function(){return{listStyleType:"none",display:"inline-block"}}},{key:"getButtonStyles",value:function(e){return{border:0,background:"transparent",color:"black",cursor:"pointer",padding:10,outline:0,fontSize:24,opacity:e?1:.5}}}]),t}(s.default.Component),position:"BottomCenter"}];t.default=l},function(e,t,n){"use strict";var r,o,i,a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};

SM4 的 key 和 加解密字符串都必须是 16 位长度的吗?

测试发现 key 不是 16 位的长度直接会无法加解密, 待解加密字符串低于16位也无法加解密,大于16位仅加密16 位

测试代码:

const sm4key = [0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10]
// const sm4OriginData = [0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10]
const sm4OriginData = 'abcdefghijklmnopqrstuvwxyz'.split('').map(x => x.charCodeAt(0))
let sm4EncData = sm4.encrypt(sm4OriginData, sm4key)
console.log(sm4EncData)

let sm4DecData = sm4.decrypt(sm4EncData, sm4key)
console.log(sm4DecData.map(x => String.fromCharCode(x)).join(''))

output:

[
    5,  96, 145,
   84, 199, 170,
   36, 101, 198,
  106, 212,  61,
    8, 117, 167,
   14
]
abcdefghijklmnop

[feature request] SM4 需要支持 cbc 加解密模式

bouncycastle 实现的加解密(SM2/SM4-cbc)和本项目实现的加解密不兼容,互相无法解密另一方加密的内容。
目前的 SM4 加解密模式是 ecb 模式,实际上很多其他语言都是用cbc 模式来做…希望能支持cbc模式

前端sm2加密对接后端其他语言时有概率出现解密失败

经过多方面测试, 发现js在处理数据时有可能出现数据位数对不上的BUG, 以下是经修改后的代码片段, 经测试可与java、C#、C++等其他语言正常对接10万次以上

var SM2Cipher = function () {
function SM2Cipher() {
_classCallCheck(this, SM2Cipher);

                this.ct = 1;
                this.p2 = null;
                this.sm3keybase = null;
                this.sm3c3 = null;
                this.key = new Array(32);
                this.keyOff = 0;
            }

            
            SM2Cipher.prototype.GetHexString64 = function GetHexString64(h) {
                if (h.length == 64) {
                    return h;
                } else {
                    // console.log(h);
                    for (var i = h.length; i < 64; i++) {
                        h = "0" + h;
                    }
                    return h;
                }
            },

            SM2Cipher.prototype.reset = function reset() {
                this.sm3keybase = new SM3Digest();
                this.sm3c3 = new SM3Digest();
                // var xWords = _.hexToArray(this.p2.getX().toBigInteger().toRadix(16));
                // var yWords = _.hexToArray(this.p2.getY().toBigInteger().toRadix(16));
                var xWords = _.hexToArray(this.GetHexString64(this.p2.getX().toBigInteger().toRadix(16)));
                var yWords = _.hexToArray(this.GetHexString64(this.p2.getY().toBigInteger().toRadix(16)));
                // var xWords = this.GetWords(this.GetHexString64(this.p2.getX().toBigInteger().toRadix(16)));
                // var yWords = this.GetWords(this.GetHexString64(this.p2.getY().toBigInteger().toRadix(16)));
                this.sm3keybase.blockUpdate(xWords, 0, xWords.length);
                this.sm3c3.blockUpdate(xWords, 0, xWords.length);
                this.sm3keybase.blockUpdate(yWords, 0, yWords.length);
                this.ct = 1;
                this.nextKey();
            };

            SM2Cipher.prototype.doFinal = function doFinal(c3) {
                // var yWords = _.hexToArray(this.p2.getY().toBigInteger().toRadix(16));
                var yWords = _.hexToArray(this.GetHexString64(this.p2.getY().toBigInteger().toRadix(16)));
                // var yWords = this.GetWords(this.GetHexString64(this.p2.getY().toBigInteger().toRadix(16)));
                this.sm3c3.blockUpdate(yWords, 0, yWords.length);
                this.sm3c3.doFinal(c3, 0);
                this.reset();
            };

            SM2Cipher.prototype.nextKey = function nextKey() {
                var sm3keycur = new SM3Digest(this.sm3keybase);
                sm3keycur.update(this.ct >> 24 & 0x00ff);
                sm3keycur.update(this.ct >> 16 & 0x00ff);
                sm3keycur.update(this.ct >> 8 & 0x00ff);
                sm3keycur.update(this.ct & 0x00ff);
                sm3keycur.doFinal(this.key, 0);
                for (var i = 0; i < this.key.length; i++) {
                    this.key[i] = this.key[i] & 255
                }
                this.keyOff = 0;
                this.ct++;
            };

            SM2Cipher.prototype.initEncipher = function initEncipher(userKey) {
                var keypair = _.generateKeyPairHex();
                var k = new BigInteger(keypair.privateKey, 16);
                var publicKey = keypair.publicKey;

                this.p2 = userKey.multiply(k); // [k](Pb)
                this.reset();

                if (publicKey.length > 128) {
                    publicKey = publicKey.substr(publicKey.length - 128);
                }

                return publicKey;
            };

            SM2Cipher.prototype.encryptBlock = function encryptBlock(data) {
                this.sm3c3.blockUpdate(data, 0, data.length);
                for (var i = 0; i < data.length; i++) {
                    if (this.keyOff === this.key.length) {
                        this.nextKey();
                    }
                    data[i] ^= this.key[this.keyOff++] & 0xff;
                }
            };

            SM2Cipher.prototype.initDecipher = function initDecipher(userD, c1) {
                this.p2 = c1.multiply(userD);
                this.reset();
            };

            SM2Cipher.prototype.decryptBlock = function decryptBlock(data) {
                for (var i = 0; i < data.length; i++) {
                    if (this.keyOff === this.key.length) {
                        this.nextKey();
                    }
                    data[i] ^= this.key[this.keyOff++] & 0xff;
                }
                this.sm3c3.blockUpdate(data, 0, data.length);
            };

            SM2Cipher.prototype.createPoint = function createPoint(x, y) {
                var publicKey = '04' + x + y;
                var point = _.getGlobalCurve().decodePointHex(publicKey);
                return point;
            };

            return SM2Cipher;
        }();

        module.exports = SM2Cipher;

        /***/
    })

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.