aes.js 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917
  1. var t =
  2. t ||
  3. (function (t, e) {
  4. var r = {};
  5. var i = (r.lib = {});
  6. var n = function () {};
  7. var o = (i.Base = {
  8. extend: function (t) {
  9. n.prototype = this;
  10. var e = new n();
  11. if (t) {
  12. e.mixIn(t);
  13. }
  14. e.hasOwnProperty('init') ||
  15. (e.init = function () {
  16. e.$super.init.apply(this, arguments);
  17. });
  18. e.init.prototype = e;
  19. e.$super = this;
  20. return e;
  21. },
  22. create: function () {
  23. var t = this.extend();
  24. t.init.apply(t, arguments);
  25. return t;
  26. },
  27. init: function () {},
  28. mixIn: function (t) {
  29. for (var e in t) {
  30. if (t.hasOwnProperty(e)) {
  31. this[e] = t[e];
  32. }
  33. }
  34. if (t.hasOwnProperty('toString')) {
  35. this.toString = t.toString;
  36. }
  37. },
  38. clone: function () {
  39. return this.init.prototype.extend(this);
  40. }
  41. });
  42. var s = (i.WordArray = o.extend({
  43. init: function (t, e) {
  44. t = this.words = t || [];
  45. this.sigBytes = void 0 != e ? e : 4 * t.length;
  46. },
  47. toString: function (t) {
  48. return (t || a).stringify(this);
  49. },
  50. concat: function (t) {
  51. var e = this.words;
  52. var r = t.words;
  53. var i = this.sigBytes;
  54. t = t.sigBytes;
  55. this.clamp();
  56. if (i % 4)
  57. for (var n = 0; n < t; n++) {
  58. e[(i + n) >>> 2] |= ((r[n >>> 2] >>> (24 - (n % 4) * 8)) & 255) << (24 - ((i + n) % 4) * 8);
  59. }
  60. else if (65535 < r.length) {
  61. for (n = 0; n < t; n += 4) {
  62. e[(i + n) >>> 2] = r[n >>> 2];
  63. }
  64. } else {
  65. e.push.apply(e, r);
  66. }
  67. this.sigBytes += t;
  68. return this;
  69. },
  70. clamp: function () {
  71. var e = this.words;
  72. var r = this.sigBytes;
  73. e[r >>> 2] &= 4294967295 << (32 - (r % 4) * 8);
  74. e.length = t.ceil(r / 4);
  75. },
  76. clone: function () {
  77. var t = o.clone.call(this);
  78. t.words = this.words.slice(0);
  79. return t;
  80. },
  81. random: function (e) {
  82. for (var r = [], i = 0; i < e; i += 4) {
  83. r.push((4294967296 * t.random()) | 0);
  84. }
  85. return new s.init(r, e);
  86. }
  87. }));
  88. var c = (r.enc = {});
  89. var a = (c.Hex = {
  90. stringify: function (t) {
  91. var e = t.words;
  92. t = t.sigBytes;
  93. for (var r = [], i = 0; i < t; i++) {
  94. var n = (e[i >>> 2] >>> (24 - (i % 4) * 8)) & 255;
  95. r.push((n >>> 4).toString(16));
  96. r.push((15 & n).toString(16));
  97. }
  98. return r.join('');
  99. },
  100. parse: function (t) {
  101. for (var e = t.length, r = [], i = 0; i < e; i += 2) {
  102. r[i >>> 3] |= parseInt(t.substr(i, 2), 16) << (24 - (i % 8) * 4);
  103. }
  104. return new s.init(r, e / 2);
  105. }
  106. });
  107. var f = (c.Latin1 = {
  108. stringify: function (t) {
  109. var e = t.words;
  110. t = t.sigBytes;
  111. for (var r = [], i = 0; i < t; i++) {
  112. r.push(String.fromCharCode((e[i >>> 2] >>> (24 - (i % 4) * 8)) & 255));
  113. }
  114. return r.join('');
  115. },
  116. parse: function (t) {
  117. for (var e = t.length, r = [], i = 0; i < e; i++) {
  118. r[i >>> 2] |= (255 & t.charCodeAt(i)) << (24 - (i % 4) * 8);
  119. }
  120. return new s.init(r, e);
  121. }
  122. });
  123. var h = (c.Utf8 = {
  124. stringify: function (t) {
  125. try {
  126. return decodeURIComponent(escape(f.stringify(t)));
  127. } catch (t) {
  128. console.log('CatchClause', t);
  129. console.log('CatchClause', t);
  130. throw Error('Malformed UTF-8 data');
  131. }
  132. },
  133. parse: function (t) {
  134. return f.parse(unescape(encodeURIComponent(t)));
  135. }
  136. });
  137. var u = (i.BufferedBlockAlgorithm = o.extend({
  138. reset: function () {
  139. this._data = new s.init();
  140. this._nDataBytes = 0;
  141. },
  142. _append: function (t) {
  143. if ('string' == typeof t) {
  144. t = h.parse(t);
  145. }
  146. this._data.concat(t);
  147. this._nDataBytes += t.sigBytes;
  148. },
  149. _process: function (e) {
  150. var r = this._data;
  151. var i = r.words;
  152. var n = r.sigBytes;
  153. var o = this.blockSize;
  154. var c = n / (4 * o);
  155. e = (c = e ? t.ceil(c) : t.max((0 | c) - this._minBufferSize, 0)) * o;
  156. n = t.min(4 * e, n);
  157. if (e) {
  158. for (var a = 0; a < e; a += o) {
  159. this._doProcessBlock(i, a);
  160. }
  161. a = i.splice(0, e);
  162. r.sigBytes -= n;
  163. }
  164. return new s.init(a, n);
  165. },
  166. clone: function () {
  167. var t = o.clone.call(this);
  168. t._data = this._data.clone();
  169. return t;
  170. },
  171. _minBufferSize: 0
  172. }));
  173. i.Hasher = u.extend({
  174. cfg: o.extend(),
  175. init: function (t) {
  176. this.cfg = this.cfg.extend(t);
  177. this.reset();
  178. },
  179. reset: function () {
  180. u.reset.call(this);
  181. this._doReset();
  182. },
  183. update: function (t) {
  184. this._append(t);
  185. this._process();
  186. return this;
  187. },
  188. finalize: function (t) {
  189. if (t) {
  190. this._append(t);
  191. }
  192. return this._doFinalize();
  193. },
  194. blockSize: 16,
  195. _createHelper: function (t) {
  196. return function (e, r) {
  197. return new t.init(r).finalize(e);
  198. };
  199. },
  200. _createHmacHelper: function (t) {
  201. return function (e, r) {
  202. return new p.HMAC.init(t, r).finalize(e);
  203. };
  204. }
  205. });
  206. var p = (r.algo = {});
  207. return r;
  208. })(Math);
  209. !(function () {
  210. var e = t;
  211. var r = e.lib.WordArray;
  212. e.enc.Base64 = {
  213. stringify: function (t) {
  214. var e = t.words;
  215. var r = t.sigBytes;
  216. var i = this._map;
  217. t.clamp();
  218. t = [];
  219. for (var n = 0; n < r; n += 3) {
  220. for (
  221. var o =
  222. (((e[n >>> 2] >>> (24 - (n % 4) * 8)) & 255) << 16) |
  223. (((e[(n + 1) >>> 2] >>> (24 - ((n + 1) % 4) * 8)) & 255) << 8) |
  224. ((e[(n + 2) >>> 2] >>> (24 - ((n + 2) % 4) * 8)) & 255),
  225. s = 0;
  226. 4 > s && n + 0.75 * s < r;
  227. s++
  228. ) {
  229. t.push(i.charAt((o >>> (6 * (3 - s))) & 63));
  230. }
  231. }
  232. if ((e = i.charAt(64))) {
  233. for (; t.length % 4; ) {
  234. t.push(e);
  235. }
  236. }
  237. return t.join('');
  238. },
  239. parse: function (t) {
  240. var e = t.length;
  241. var i = this._map;
  242. if ((n = i.charAt(64)) && -1 != (n = t.indexOf(n))) {
  243. e = n;
  244. }
  245. for (var n = [], o = 0, s = 0; s < e; s++) {
  246. if (s % 4) {
  247. var c = i.indexOf(t.charAt(s - 1)) << ((s % 4) * 2);
  248. var a = i.indexOf(t.charAt(s)) >>> (6 - (s % 4) * 2);
  249. n[o >>> 2] |= (c | a) << (24 - (o % 4) * 8);
  250. o++;
  251. }
  252. }
  253. return r.create(n, o);
  254. },
  255. _map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='
  256. };
  257. })();
  258. (function (e) {
  259. function r(t, e, r, i, n, o, s) {
  260. return (((t = t + ((e & r) | (~e & i)) + n + s) << o) | (t >>> (32 - o))) + e;
  261. }
  262. function i(t, e, r, i, n, o, s) {
  263. return (((t = t + ((e & i) | (r & ~i)) + n + s) << o) | (t >>> (32 - o))) + e;
  264. }
  265. function n(t, e, r, i, n, o, s) {
  266. return (((t = t + (e ^ r ^ i) + n + s) << o) | (t >>> (32 - o))) + e;
  267. }
  268. function o(t, e, r, i, n, o, s) {
  269. return (((t = t + (r ^ (e | ~i)) + n + s) << o) | (t >>> (32 - o))) + e;
  270. }
  271. for (var s = t, c = (f = s.lib).WordArray, a = f.Hasher, f = s.algo, h = [], u = 0; 64 > u; u++) {
  272. h[u] = (4294967296 * e.abs(e.sin(u + 1))) | 0;
  273. }
  274. f = f.MD5 = a.extend({
  275. _doReset: function () {
  276. this._hash = new c.init([1732584193, 4023233417, 2562383102, 271733878]);
  277. },
  278. _doProcessBlock: function (t, e) {
  279. for (s = 0; 16 > s; s++) {
  280. a = t[(c = e + s)];
  281. t[c] = (16711935 & ((a << 8) | (a >>> 24))) | (4278255360 & ((a << 24) | (a >>> 8)));
  282. }
  283. var s = this._hash.words;
  284. var c = t[e + 0];
  285. var a = t[e + 1];
  286. var f = t[e + 2];
  287. var u = t[e + 3];
  288. var p = t[e + 4];
  289. var d = t[e + 5];
  290. var l = t[e + 6];
  291. var y = t[e + 7];
  292. var v = t[e + 8];
  293. var _ = t[e + 9];
  294. var g = t[e + 10];
  295. var B = t[e + 11];
  296. var k = t[e + 12];
  297. var x = t[e + 13];
  298. var m = t[e + 14];
  299. var S = t[e + 15];
  300. var w = s[0];
  301. var z = s[1];
  302. var C = s[2];
  303. var E = s[3];
  304. var z = o(
  305. (z = o(
  306. (z = o(
  307. (z = o(
  308. (z = n(
  309. (z = n(
  310. (z = n(
  311. (z = n(
  312. (z = i(
  313. (z = i(
  314. (z = i(
  315. (z = i(
  316. (z = r(
  317. (z = r(
  318. (z = r(
  319. (z = r(
  320. z,
  321. (C = r(C, (E = r(E, (w = r(w, z, C, E, c, 7, h[0])), z, C, a, 12, h[1])), w, z, f, 17, h[2])),
  322. E,
  323. w,
  324. u,
  325. 22,
  326. h[3]
  327. )),
  328. (C = r(C, (E = r(E, (w = r(w, z, C, E, p, 7, h[4])), z, C, d, 12, h[5])), w, z, l, 17, h[6])),
  329. E,
  330. w,
  331. y,
  332. 22,
  333. h[7]
  334. )),
  335. (C = r(C, (E = r(E, (w = r(w, z, C, E, v, 7, h[8])), z, C, _, 12, h[9])), w, z, g, 17, h[10])),
  336. E,
  337. w,
  338. B,
  339. 22,
  340. h[11]
  341. )),
  342. (C = r(C, (E = r(E, (w = r(w, z, C, E, k, 7, h[12])), z, C, x, 12, h[13])), w, z, m, 17, h[14])),
  343. E,
  344. w,
  345. S,
  346. 22,
  347. h[15]
  348. )),
  349. (C = i(C, (E = i(E, (w = i(w, z, C, E, a, 5, h[16])), z, C, l, 9, h[17])), w, z, B, 14, h[18])),
  350. E,
  351. w,
  352. c,
  353. 20,
  354. h[19]
  355. )),
  356. (C = i(C, (E = i(E, (w = i(w, z, C, E, d, 5, h[20])), z, C, g, 9, h[21])), w, z, S, 14, h[22])),
  357. E,
  358. w,
  359. p,
  360. 20,
  361. h[23]
  362. )),
  363. (C = i(C, (E = i(E, (w = i(w, z, C, E, _, 5, h[24])), z, C, m, 9, h[25])), w, z, u, 14, h[26])),
  364. E,
  365. w,
  366. v,
  367. 20,
  368. h[27]
  369. )),
  370. (C = i(C, (E = i(E, (w = i(w, z, C, E, x, 5, h[28])), z, C, f, 9, h[29])), w, z, y, 14, h[30])),
  371. E,
  372. w,
  373. k,
  374. 20,
  375. h[31]
  376. )),
  377. (C = n(C, (E = n(E, (w = n(w, z, C, E, d, 4, h[32])), z, C, v, 11, h[33])), w, z, B, 16, h[34])),
  378. E,
  379. w,
  380. m,
  381. 23,
  382. h[35]
  383. )),
  384. (C = n(C, (E = n(E, (w = n(w, z, C, E, a, 4, h[36])), z, C, p, 11, h[37])), w, z, y, 16, h[38])),
  385. E,
  386. w,
  387. g,
  388. 23,
  389. h[39]
  390. )),
  391. (C = n(C, (E = n(E, (w = n(w, z, C, E, x, 4, h[40])), z, C, c, 11, h[41])), w, z, u, 16, h[42])),
  392. E,
  393. w,
  394. l,
  395. 23,
  396. h[43]
  397. )),
  398. (C = n(C, (E = n(E, (w = n(w, z, C, E, _, 4, h[44])), z, C, k, 11, h[45])), w, z, S, 16, h[46])),
  399. E,
  400. w,
  401. f,
  402. 23,
  403. h[47]
  404. )),
  405. (C = o(C, (E = o(E, (w = o(w, z, C, E, c, 6, h[48])), z, C, y, 10, h[49])), w, z, m, 15, h[50])),
  406. E,
  407. w,
  408. d,
  409. 21,
  410. h[51]
  411. )),
  412. (C = o(C, (E = o(E, (w = o(w, z, C, E, k, 6, h[52])), z, C, u, 10, h[53])), w, z, g, 15, h[54])),
  413. E,
  414. w,
  415. a,
  416. 21,
  417. h[55]
  418. )),
  419. (C = o(C, (E = o(E, (w = o(w, z, C, E, v, 6, h[56])), z, C, S, 10, h[57])), w, z, l, 15, h[58])),
  420. E,
  421. w,
  422. x,
  423. 21,
  424. h[59]
  425. )),
  426. (C = o(C, (E = o(E, (w = o(w, z, C, E, p, 6, h[60])), z, C, B, 10, h[61])), w, z, f, 15, h[62])),
  427. E,
  428. w,
  429. _,
  430. 21,
  431. h[63]
  432. );
  433. s[0] = (s[0] + w) | 0;
  434. s[1] = (s[1] + z) | 0;
  435. s[2] = (s[2] + C) | 0;
  436. s[3] = (s[3] + E) | 0;
  437. },
  438. _doFinalize: function () {
  439. var t = this._data;
  440. var r = t.words;
  441. var i = 8 * this._nDataBytes;
  442. var n = 8 * t.sigBytes;
  443. r[n >>> 5] |= 128 << (24 - (n % 32));
  444. var o = e.floor(i / 4294967296);
  445. for (
  446. r[15 + (((n + 64) >>> 9) << 4)] = (16711935 & ((o << 8) | (o >>> 24))) | (4278255360 & ((o << 24) | (o >>> 8))),
  447. r[14 + (((n + 64) >>> 9) << 4)] = (16711935 & ((i << 8) | (i >>> 24))) | (4278255360 & ((i << 24) | (i >>> 8))),
  448. t.sigBytes = 4 * (r.length + 1),
  449. this._process(),
  450. r = (t = this._hash).words,
  451. i = 0;
  452. 4 > i;
  453. i++
  454. ) {
  455. n = r[i];
  456. r[i] = (16711935 & ((n << 8) | (n >>> 24))) | (4278255360 & ((n << 24) | (n >>> 8)));
  457. }
  458. return t;
  459. },
  460. clone: function () {
  461. var t = a.clone.call(this);
  462. t._hash = this._hash.clone();
  463. return t;
  464. }
  465. });
  466. s.MD5 = a._createHelper(f);
  467. s.HmacMD5 = a._createHmacHelper(f);
  468. })(Math);
  469. (function () {
  470. var e = t;
  471. var r = e.lib;
  472. var i = r.Base;
  473. var n = r.WordArray;
  474. var o = ((r = e.algo).EvpKDF = i.extend({
  475. cfg: i.extend({
  476. keySize: 4,
  477. hasher: r.MD5,
  478. iterations: 1
  479. }),
  480. init: function (t) {
  481. this.cfg = this.cfg.extend(t);
  482. },
  483. compute: function (t, e) {
  484. for (var r = (c = this.cfg).hasher.create(), i = n.create(), o = i.words, s = c.keySize, c = c.iterations; o.length < s; ) {
  485. if (a) {
  486. r.update(a);
  487. }
  488. var a = r.update(t).finalize(e);
  489. r.reset();
  490. for (var f = 1; f < c; f++) {
  491. a = r.finalize(a);
  492. r.reset();
  493. }
  494. i.concat(a);
  495. }
  496. i.sigBytes = 4 * s;
  497. return i;
  498. }
  499. }));
  500. e.EvpKDF = function (t, e, r) {
  501. return o.create(r).compute(t, e);
  502. };
  503. })();
  504. t.lib.Cipher ||
  505. (function (e) {
  506. var r = (l = t).lib;
  507. var i = r.Base;
  508. var n = r.WordArray;
  509. var o = r.BufferedBlockAlgorithm;
  510. var s = l.enc.Base64;
  511. var c = l.algo.EvpKDF;
  512. var a = (r.Cipher = o.extend({
  513. cfg: i.extend(),
  514. createEncryptor: function (t, e) {
  515. return this.create(this._ENC_XFORM_MODE, t, e);
  516. },
  517. createDecryptor: function (t, e) {
  518. return this.create(this._DEC_XFORM_MODE, t, e);
  519. },
  520. init: function (t, e, r) {
  521. this.cfg = this.cfg.extend(r);
  522. this._xformMode = t;
  523. this._key = e;
  524. this.reset();
  525. },
  526. reset: function () {
  527. o.reset.call(this);
  528. this._doReset();
  529. },
  530. process: function (t) {
  531. this._append(t);
  532. return this._process();
  533. },
  534. finalize: function (t) {
  535. if (t) {
  536. this._append(t);
  537. }
  538. return this._doFinalize();
  539. },
  540. keySize: 4,
  541. ivSize: 4,
  542. _ENC_XFORM_MODE: 1,
  543. _DEC_XFORM_MODE: 2,
  544. _createHelper: function (t) {
  545. return {
  546. encrypt: function (e, r, i) {
  547. return ('string' == typeof r ? y : d).encrypt(t, e, r, i);
  548. },
  549. decrypt: function (e, r, i) {
  550. return ('string' == typeof r ? y : d).decrypt(t, e, r, i);
  551. }
  552. };
  553. }
  554. }));
  555. r.StreamCipher = a.extend({
  556. _doFinalize: function () {
  557. return this._process(true);
  558. },
  559. blockSize: 1
  560. });
  561. var f = (l.mode = {});
  562. var h = function (t, e, r) {
  563. var i = this._iv;
  564. i ? (this._iv = void 0) : (i = this._prevBlock);
  565. for (var n = 0; n < r; n++) {
  566. t[e + n] ^= i[n];
  567. }
  568. };
  569. var u = (r.BlockCipherMode = i.extend({
  570. createEncryptor: function (t, e) {
  571. return this.Encryptor.create(t, e);
  572. },
  573. createDecryptor: function (t, e) {
  574. return this.Decryptor.create(t, e);
  575. },
  576. init: function (t, e) {
  577. this._cipher = t;
  578. this._iv = e;
  579. }
  580. })).extend();
  581. u.Encryptor = u.extend({
  582. processBlock: function (t, e) {
  583. var r = this._cipher;
  584. var i = r.blockSize;
  585. h.call(this, t, e, i);
  586. r.encryptBlock(t, e);
  587. this._prevBlock = t.slice(e, e + i);
  588. }
  589. });
  590. u.Decryptor = u.extend({
  591. processBlock: function (t, e) {
  592. var r = this._cipher;
  593. var i = r.blockSize;
  594. var n = t.slice(e, e + i);
  595. r.decryptBlock(t, e);
  596. h.call(this, t, e, i);
  597. this._prevBlock = n;
  598. }
  599. });
  600. f = f.CBC = u;
  601. u = (l.pad = {}).Pkcs7 = {
  602. pad: function (t, e) {
  603. for (var r = 4 * e, i = ((r = r - (t.sigBytes % r)) << 24) | (r << 16) | (r << 8) | r, o = [], s = 0; s < r; s += 4) {
  604. o.push(i);
  605. }
  606. r = n.create(o, r);
  607. t.concat(r);
  608. },
  609. unpad: function (t) {
  610. t.sigBytes -= 255 & t.words[(t.sigBytes - 1) >>> 2];
  611. }
  612. };
  613. r.BlockCipher = a.extend({
  614. cfg: a.cfg.extend({
  615. mode: f,
  616. padding: u
  617. }),
  618. reset: function () {
  619. a.reset.call(this);
  620. var t = (e = this.cfg).iv;
  621. var e = e.mode;
  622. if (this._xformMode == this._ENC_XFORM_MODE) {
  623. var r = e.createEncryptor;
  624. } else {
  625. r = e.createDecryptor;
  626. this._minBufferSize = 1;
  627. }
  628. this._mode = r.call(e, this, t && t.words);
  629. },
  630. _doProcessBlock: function (t, e) {
  631. this._mode.processBlock(t, e);
  632. },
  633. _doFinalize: function () {
  634. var t = this.cfg.padding;
  635. if (this._xformMode == this._ENC_XFORM_MODE) {
  636. t.pad(this._data, this.blockSize);
  637. var e = this._process(true);
  638. } else {
  639. e = this._process(true);
  640. t.unpad(e);
  641. }
  642. return e;
  643. },
  644. blockSize: 4
  645. });
  646. var p = (r.CipherParams = i.extend({
  647. init: function (t) {
  648. this.mixIn(t);
  649. },
  650. toString: function (t) {
  651. return (t || this.formatter).stringify(this);
  652. }
  653. }));
  654. var f = ((l.format = {}).OpenSSL = {
  655. stringify: function (t) {
  656. var e = t.ciphertext;
  657. return ((t = t.salt) ? n.create([1398893684, 1701076831]).concat(t).concat(e) : e).toString(s);
  658. },
  659. parse: function (t) {
  660. var e = (t = s.parse(t)).words;
  661. if (1398893684 == e[0] && 1701076831 == e[1]) {
  662. var r = n.create(e.slice(2, 4));
  663. e.splice(0, 4);
  664. t.sigBytes -= 16;
  665. }
  666. return p.create({
  667. ciphertext: t,
  668. salt: r
  669. });
  670. }
  671. });
  672. var d = (r.SerializableCipher = i.extend({
  673. cfg: i.extend({
  674. format: f
  675. }),
  676. encrypt: function (t, e, r, i) {
  677. i = this.cfg.extend(i);
  678. var n = t.createEncryptor(r, i);
  679. e = n.finalize(e);
  680. n = n.cfg;
  681. return p.create({
  682. ciphertext: e,
  683. key: r,
  684. iv: n.iv,
  685. algorithm: t,
  686. mode: n.mode,
  687. padding: n.padding,
  688. blockSize: t.blockSize,
  689. formatter: i.format
  690. });
  691. },
  692. decrypt: function (t, e, r, i) {
  693. i = this.cfg.extend(i);
  694. e = this._parse(e, i.format);
  695. return t.createDecryptor(r, i).finalize(e.ciphertext);
  696. },
  697. _parse: function (t, e) {
  698. return 'string' == typeof t ? e.parse(t, this) : t;
  699. }
  700. }));
  701. var l = ((l.kdf = {}).OpenSSL = {
  702. execute: function (t, e, r, i) {
  703. i || (i = n.random(8));
  704. t = c
  705. .create({
  706. keySize: e + r
  707. })
  708. .compute(t, i);
  709. r = n.create(t.words.slice(e), 4 * r);
  710. t.sigBytes = 4 * e;
  711. return p.create({
  712. key: t,
  713. iv: r,
  714. salt: i
  715. });
  716. }
  717. });
  718. var y = (r.PasswordBasedCipher = d.extend({
  719. cfg: d.cfg.extend({
  720. kdf: l
  721. }),
  722. encrypt: function (t, e, r, i) {
  723. i = this.cfg.extend(i);
  724. r = i.kdf.execute(r, t.keySize, t.ivSize);
  725. i.iv = r.iv;
  726. (t = d.encrypt.call(this, t, e, r.key, i)).mixIn(r);
  727. return t;
  728. },
  729. decrypt: function (t, e, r, i) {
  730. i = this.cfg.extend(i);
  731. e = this._parse(e, i.format);
  732. r = i.kdf.execute(r, t.keySize, t.ivSize, e.salt);
  733. i.iv = r.iv;
  734. return d.decrypt.call(this, t, e, r.key, i);
  735. }
  736. }));
  737. })();
  738. (function () {
  739. for (var e = t, r = e.lib.BlockCipher, i = e.algo, n = [], o = [], s = [], c = [], a = [], f = [], h = [], u = [], p = [], d = [], l = [], y = 0; 256 > y; y++) {
  740. l[y] = 128 > y ? y << 1 : (y << 1) ^ 283;
  741. }
  742. for (var v = 0, _ = 0, y = 0; 256 > y; y++) {
  743. var g = ((g = _ ^ (_ << 1) ^ (_ << 2) ^ (_ << 3) ^ (_ << 4)) >>> 8) ^ (255 & g) ^ 99;
  744. n[v] = g;
  745. o[g] = v;
  746. var B = l[v];
  747. var k = l[B];
  748. var x = l[k];
  749. var m = (257 * l[g]) ^ (16843008 * g);
  750. s[v] = (m << 24) | (m >>> 8);
  751. c[v] = (m << 16) | (m >>> 16);
  752. a[v] = (m << 8) | (m >>> 24);
  753. f[v] = m;
  754. m = (16843009 * x) ^ (65537 * k) ^ (257 * B) ^ (16843008 * v);
  755. h[g] = (m << 24) | (m >>> 8);
  756. u[g] = (m << 16) | (m >>> 16);
  757. p[g] = (m << 8) | (m >>> 24);
  758. d[g] = m;
  759. v ? ((v = B ^ l[l[l[x ^ B]]]), (_ ^= l[l[_]])) : (v = _ = 1);
  760. }
  761. var S = [0, 1, 2, 4, 8, 16, 32, 64, 128, 27, 54];
  762. var i = (i.AES = r.extend({
  763. _doReset: function () {
  764. for (var t = (r = this._key).words, e = r.sigBytes / 4, r = 4 * ((this._nRounds = e + 6) + 1), i = (this._keySchedule = []), o = 0; o < r; o++) {
  765. if (o < e) {
  766. i[o] = t[o];
  767. } else {
  768. var s = i[o - 1];
  769. o % e
  770. ? 6 < e && 4 == o % e && (s = (n[s >>> 24] << 24) | (n[(s >>> 16) & 255] << 16) | (n[(s >>> 8) & 255] << 8) | n[255 & s])
  771. : ((s = (s << 8) | (s >>> 24)),
  772. (s = (n[s >>> 24] << 24) | (n[(s >>> 16) & 255] << 16) | (n[(s >>> 8) & 255] << 8) | n[255 & s]),
  773. (s ^= S[(o / e) | 0] << 24));
  774. i[o] = i[o - e] ^ s;
  775. }
  776. }
  777. for (t = this._invKeySchedule = [], e = 0; e < r; e++) {
  778. o = r - e;
  779. s = e % 4 ? i[o] : i[o - 4];
  780. t[e] = 4 > e || 4 >= o ? s : h[n[s >>> 24]] ^ u[n[(s >>> 16) & 255]] ^ p[n[(s >>> 8) & 255]] ^ d[n[255 & s]];
  781. }
  782. },
  783. encryptBlock: function (t, e) {
  784. this._doCryptBlock(t, e, this._keySchedule, s, c, a, f, n);
  785. },
  786. decryptBlock: function (t, e) {
  787. var r = t[e + 1];
  788. t[e + 1] = t[e + 3];
  789. t[e + 3] = r;
  790. this._doCryptBlock(t, e, this._invKeySchedule, h, u, p, d, o);
  791. r = t[e + 1];
  792. t[e + 1] = t[e + 3];
  793. t[e + 3] = r;
  794. },
  795. _doCryptBlock: function (t, e, r, i, n, o, s, c) {
  796. for (var a = this._nRounds, f = t[e] ^ r[0], h = t[e + 1] ^ r[1], u = t[e + 2] ^ r[2], p = t[e + 3] ^ r[3], d = 4, l = 1; l < a; l++) {
  797. var y = i[f >>> 24] ^ n[(h >>> 16) & 255] ^ o[(u >>> 8) & 255] ^ s[255 & p] ^ r[d++];
  798. var v = i[h >>> 24] ^ n[(u >>> 16) & 255] ^ o[(p >>> 8) & 255] ^ s[255 & f] ^ r[d++];
  799. var _ = i[u >>> 24] ^ n[(p >>> 16) & 255] ^ o[(f >>> 8) & 255] ^ s[255 & h] ^ r[d++];
  800. var p = i[p >>> 24] ^ n[(f >>> 16) & 255] ^ o[(h >>> 8) & 255] ^ s[255 & u] ^ r[d++];
  801. var f = y;
  802. var h = v;
  803. var u = _;
  804. }
  805. y = ((c[f >>> 24] << 24) | (c[(h >>> 16) & 255] << 16) | (c[(u >>> 8) & 255] << 8) | c[255 & p]) ^ r[d++];
  806. v = ((c[h >>> 24] << 24) | (c[(u >>> 16) & 255] << 16) | (c[(p >>> 8) & 255] << 8) | c[255 & f]) ^ r[d++];
  807. _ = ((c[u >>> 24] << 24) | (c[(p >>> 16) & 255] << 16) | (c[(f >>> 8) & 255] << 8) | c[255 & h]) ^ r[d++];
  808. p = ((c[p >>> 24] << 24) | (c[(f >>> 16) & 255] << 16) | (c[(h >>> 8) & 255] << 8) | c[255 & u]) ^ r[d++];
  809. t[e] = y;
  810. t[e + 1] = v;
  811. t[e + 2] = _;
  812. t[e + 3] = p;
  813. },
  814. keySize: 8
  815. }));
  816. e.AES = r._createHelper(i);
  817. })();
  818. t.enc.u8array = {
  819. stringify: function (t) {
  820. for (var e = t.words, r = t.sigBytes, i = new Uint8Array(r), n = 0; n < r; n++) {
  821. var o = (e[n >>> 2] >>> (24 - (n % 4) * 8)) & 255;
  822. i[n] = o;
  823. }
  824. return i;
  825. },
  826. parse: function (e) {
  827. for (var r = e.length, i = [], n = 0; n < r; n++) {
  828. i[n >>> 2] |= (255 & e[n]) << (24 - (n % 4) * 8);
  829. }
  830. return t.lib.WordArray.create(i, r);
  831. }
  832. };
  833. t.enc.int8array = {
  834. stringify: function (t) {
  835. for (var e = t.words, r = t.sigBytes, i = new Int8Array(r), n = 0; n < r; n++) {
  836. var o = (e[n >>> 2] >> (24 - (n % 4) * 8)) & 255;
  837. i[n] = o;
  838. }
  839. return i;
  840. },
  841. parse: function (e) {
  842. for (var r = e.length, i = [], n = 0; n < r; n++) {
  843. i[n >>> 2] |= (255 & e[n]) << (24 - (n % 4) * 8);
  844. }
  845. return t.lib.WordArray.create(i, r);
  846. }
  847. };
  848. t.enc.int16array = {
  849. stringify: function (t) {
  850. for (var e = t.words, r = t.sigBytes, i = new Uint8Array(r), n = 0; n < r; n++) {
  851. var o = (e[n >>> 2] >>> (24 - (n % 4) * 8)) & 255;
  852. i[n] = o;
  853. }
  854. return i;
  855. },
  856. parse: function (e) {
  857. for (var r = e.length, i = [], n = 0; n < r; n++) {
  858. i[n >>> 2] |= (255 & e[n]) << (24 - (n % 4) * 8);
  859. }
  860. return t.lib.WordArray.create(i, r);
  861. }
  862. };
  863. t.mode.CFB = (function () {
  864. function e(t, e, r, i) {
  865. var n = this._iv;
  866. if (n) {
  867. o = n.slice(0);
  868. this._iv = void 0;
  869. } else {
  870. var o = this._prevBlock;
  871. }
  872. i.encryptBlock(o, 0);
  873. for (var s = 0; s < r; s++) {
  874. t[e + s] ^= o[s];
  875. }
  876. }
  877. var r = t.lib.BlockCipherMode.extend();
  878. r.Encryptor = r.extend({
  879. processBlock: function (t, r) {
  880. var i = this._cipher;
  881. var n = i.blockSize;
  882. e.call(this, t, r, n, i);
  883. this._prevBlock = t.slice(r, r + n);
  884. }
  885. });
  886. r.Decryptor = r.extend({
  887. processBlock: function (t, r) {
  888. var i = this._cipher;
  889. var n = i.blockSize;
  890. var o = t.slice(r, r + n);
  891. e.call(this, t, r, n, i);
  892. this._prevBlock = o;
  893. }
  894. });
  895. return r;
  896. })();
  897. t.mode.ECB = (function () {
  898. var e = t.lib.BlockCipherMode.extend();
  899. e.Encryptor = e.extend({
  900. processBlock: function (t, e) {
  901. this._cipher.encryptBlock(t, e);
  902. }
  903. });
  904. e.Decryptor = e.extend({
  905. processBlock: function (t, e) {
  906. this._cipher.decryptBlock(t, e);
  907. }
  908. });
  909. return e;
  910. })();
  911. t.pad.NoPadding = {
  912. pad: function () {},
  913. unpad: function () {}
  914. };
  915. module.exports = {
  916. CryptoJS: t
  917. };