Commit 143939686153b2dd624cdf8bee151b937258b2f0

Authored by ww
1 parent 17a3a771

feat: add crypto-js

No preview for this file type
No preview for this file type
@@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
4 "main": "src/main/webapp/index.html", 4 "main": "src/main/webapp/index.html",
5 "scripts": { 5 "scripts": {
6 "start": "cd src/main/webapp && serve", 6 "start": "cd src/main/webapp && serve",
7 - "build": "cd etc/build && ant" 7 + "build": "cd etc/build && ant war"
8 }, 8 },
9 "license": "MIT", 9 "license": "MIT",
10 "dependencies": { 10 "dependencies": {
No preview for this file type
No preview for this file type
@@ -2,7 +2,8 @@ @@ -2,7 +2,8 @@
2 <!DOCTYPE html> 2 <!DOCTYPE html>
3 <html> 3 <html>
4 <head> 4 <head>
5 - <title>Flowchart Maker &amp; Online Diagram Software</title> 5 +<!-- <title>Flowchart Maker &amp; Online Diagram Software</title>-->
  6 + <title>thingskit 云组态</title>
6 <meta charset="utf-8"> 7 <meta charset="utf-8">
7 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 8 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
8 <meta name="Description" content="diagrams.net is free online diagram software for making flowcharts, process diagrams, org charts, UML, ER and network diagrams"> 9 <meta name="Description" content="diagrams.net is free online diagram software for making flowcharts, process diagrams, org charts, UML, ER and network diagrams">
@@ -16,6 +17,15 @@ @@ -16,6 +17,15 @@
16 <meta name="msapplication-config" content="images/browserconfig.xml"> 17 <meta name="msapplication-config" content="images/browserconfig.xml">
17 <meta name="mobile-web-app-capable" content="yes"> 18 <meta name="mobile-web-app-capable" content="yes">
18 <meta name="theme-color" content="#d89000"> 19 <meta name="theme-color" content="#d89000">
  20 + <!-- crypto-js -->
  21 + <script src="./js/plugin/crypto-js/crypto-js.js"></script>
  22 +<!-- <script src="./js/plugin/crypto-js/aes.js"></script>-->
  23 +<!-- <script src="./js/plugin/crypto-js/enc-utf8.js"></script>-->
  24 +<!-- <script src="./js/plugin/crypto-js/pad-pkcs7.js"></script>-->
  25 +<!-- <script src="./js/plugin/crypto-js/mode-ecb.js"></script>-->
  26 +<!-- <script src="./js/plugin/crypto-js/md5.js"></script>-->
  27 +<!-- <script src="./js/plugin/crypto-js/enc-utf8.js"></script>-->
  28 +<!-- <script src="./js/plugin/crypto-js/enc-base64.js"></script>-->
19 <!-- 全局变量 --> 29 <!-- 全局变量 -->
20 <script src="./js/const/const.js"></script> 30 <script src="./js/const/const.js"></script>
21 31
@@ -39,7 +49,7 @@ @@ -39,7 +49,7 @@
39 <!-- <script type="text/javascript" src="./js/jquery.select.zTree.v1.5.min.js"></script>--> 49 <!-- <script type="text/javascript" src="./js/jquery.select.zTree.v1.5.min.js"></script>-->
40 50
41 <!-- Axios --> 51 <!-- Axios -->
42 - <script src="./plugins/defHttp.js"></script> 52 + <script src="./plugins/DefHttp.js"></script>
43 53
44 <script src="./js/api/index.js"></script> 54 <script src="./js/api/index.js"></script>
45 55
@@ -386,15 +396,18 @@ @@ -386,15 +396,18 @@
386 </script> 396 </script>
387 <link rel="chrome-webstore-item" href="https://chrome.google.com/webstore/detail/plgmlhohecdddhbmmkncjdmlhcmaachm"> 397 <link rel="chrome-webstore-item" href="https://chrome.google.com/webstore/detail/plgmlhohecdddhbmmkncjdmlhcmaachm">
388 <link rel="apple-touch-icon" sizes="180x180" href="images/apple-touch-icon.png"> 398 <link rel="apple-touch-icon" sizes="180x180" href="images/apple-touch-icon.png">
389 - <link rel="icon" type="image/png" sizes="32x32" href="images/favicon-32x32.png"> 399 +<!-- <link rel="icon" type="image/png" sizes="32x32" href="images/favicon-32x32.png">-->
  400 + <link rel="icon" type="image/png" sizes="32x32" href="images/logo-32x32.png">
390 <link rel="icon" type="image/png" sizes="16x16" href="images/favicon-16x16.png"> 401 <link rel="icon" type="image/png" sizes="16x16" href="images/favicon-16x16.png">
  402 +<!-- <link rel="icon" type="image/png" sizes="16x16" href="images/favicon-16x16.png">-->
391 <link rel="mask-icon" href="images/safari-pinned-tab.svg" color="#d89000"> 403 <link rel="mask-icon" href="images/safari-pinned-tab.svg" color="#d89000">
392 <link rel="stylesheet" type="text/css" href="styles/grapheditor.css"> 404 <link rel="stylesheet" type="text/css" href="styles/grapheditor.css">
393 <link rel="stylesheet" type="text/css" href="styles/easyui.css"> 405 <link rel="stylesheet" type="text/css" href="styles/easyui.css">
394 <link rel="preconnect" href="https://storage.googleapis.com"> 406 <link rel="preconnect" href="https://storage.googleapis.com">
395 <link rel="canonical" href="https://app.diagrams.net"> 407 <link rel="canonical" href="https://app.diagrams.net">
396 <link rel="manifest" href="images/manifest.json"> 408 <link rel="manifest" href="images/manifest.json">
397 - <link rel="shortcut icon" href="favicon.ico"> 409 +<!-- <link rel="shortcut icon" href="favicon.ico">-->
  410 + <link rel="shortcut icon" href="images/logo-16x16.ico">
398 <style type="text/css"> 411 <style type="text/css">
399 body { overflow:hidden; } 412 body { overflow:hidden; }
400 div.picker { z-index: 10007; } 413 div.picker { z-index: 10007; }
No preview for this file type
1 -const GLOBAL_TOKEN = JSON.parse(localStorage.getItem("UNDEFINED__DEVELOPMENT__2.7.1__COMMON__LOCAL__KEY__")).value.JWT_TOKEN.value 1 +// const { encrypt, decrypt } = CryptoJS.AES
  2 +// const parse = CryptoJS.enc.Utf8;
  3 +// const pkcs7 = CryptoJS.pad.Pkcs7;
  4 +// const ECB = CryptoJS.mode.ECB;
  5 +// const UTF8 = CryptoJS.enc.Utf8;
  6 +//
  7 +// const cacheCipher = {
  8 +// key: '_11111000001111@',
  9 +// iv: '@11111000001111_',
  10 +// }
  11 +//
  12 +// const DEFAULT_CACHE_TIME = 60 * 60 * 24 * 7;
  13 +//
  14 +// const isNullOrUnDef = (val) => typeof val === 'undefined' || val === null
  15 +//
  16 +// class AesEncryption {
  17 +// key;
  18 +// iv;
  19 +//
  20 +// constructor(opt = {}) {
  21 +// const { key, iv } = opt;
  22 +// if (key) {
  23 +// this.key = parse(key);
  24 +// }
  25 +// if (iv) {
  26 +// this.iv = parse(iv);
  27 +// }
  28 +// }
  29 +//
  30 +// get getOptions() {
  31 +// return {
  32 +// mode: ECB,
  33 +// padding: pkcs7,
  34 +// iv: this.iv,
  35 +// };
  36 +// }
  37 +//
  38 +// encryptByAES(cipherText) {
  39 +// return encrypt(cipherText, this.key, this.getOptions).toString();
  40 +// }
  41 +//
  42 +// decryptByAES(cipherText) {
  43 +// return decrypt(cipherText, this.key, this.getOptions).toString(UTF8);
  44 +// }
  45 +// }
  46 +//
  47 +//
  48 +// const createStorage = (
  49 +// {
  50 +// prefixKey = '',
  51 +// storage = sessionStorage,
  52 +// key = cacheCipher.key,
  53 +// iv = cacheCipher.iv,
  54 +// timeout = null,
  55 +// hasEncrypt = true,
  56 +// } = {}) => {
  57 +// if (hasEncrypt && [ key.length, iv.length ].some((item) => item !== 16)) {
  58 +// throw new Error('When hasEncrypt is true, the key or iv must be 16 bits!');
  59 +// }
  60 +//
  61 +// const encryption = new AesEncryption({ key, iv });
  62 +//
  63 +// /**
  64 +// *Cache class
  65 +// *Construction parameters can be passed into sessionStorage, localStorage,
  66 +// * @class Cache
  67 +// * @example
  68 +// */
  69 +// const WebStorage = class WebStorage {
  70 +// storage
  71 +// prefixKey
  72 +// encryption
  73 +// hasEncrypt
  74 +//
  75 +// /**
  76 +// *
  77 +// * @param {*} storage
  78 +// */
  79 +// constructor() {
  80 +// this.storage = storage;
  81 +// this.prefixKey = prefixKey;
  82 +// this.encryption = encryption;
  83 +// this.hasEncrypt = hasEncrypt;
  84 +// }
  85 +//
  86 +// getKey(key) {
  87 +// return `${ this.prefixKey }${ key }`.toUpperCase();
  88 +// }
  89 +//
  90 +// /**
  91 +// *
  92 +// * Set cache
  93 +// * @param {string} key
  94 +// * @param {*} value
  95 +// * @param {*} expire
  96 +// * @expire Expiration time in seconds
  97 +// * @memberof Cache
  98 +// */
  99 +// set(key, value, expire = timeout) {
  100 +// const stringData = JSON.stringify({
  101 +// value,
  102 +// time: Date.now(),
  103 +// expire: !isNullOrUnDef(expire) ? new Date().getTime() + expire * 1000 : null,
  104 +// });
  105 +// const stringifyValue = this.hasEncrypt
  106 +// ? this.encryption.encryptByAES(stringData)
  107 +// : stringData;
  108 +// this.storage.setItem(this.getKey(key), stringifyValue);
  109 +// }
  110 +//
  111 +// /**
  112 +// *Read cache
  113 +// * @param {string} key
  114 +// * @param {any} [def=null] def
  115 +// * @memberof Cache
  116 +// */
  117 +// get(key, def = null) {
  118 +// const val = this.storage.getItem(this.getKey(key));
  119 +// if (!val) return def;
  120 +//
  121 +// try {
  122 +// const decVal = this.hasEncrypt ? this.encryption.decryptByAES(val) : val;
  123 +// const data = JSON.parse(decVal);
  124 +// const { value, expire } = data;
  125 +// if (isNullOrUnDef(expire) || expire >= new Date().getTime()) {
  126 +// return value;
  127 +// }
  128 +// this.remove(key);
  129 +// } catch (e) {
  130 +// return def;
  131 +// }
  132 +// }
  133 +//
  134 +// /**
  135 +// * Delete cache based on key
  136 +// * @param {string} key
  137 +// * @memberof Cache
  138 +// */
  139 +// remove(key) {
  140 +// this.storage.removeItem(this.getKey(key));
  141 +// }
  142 +//
  143 +// /**
  144 +// * Delete all caches of this instance
  145 +// */
  146 +// clear() {
  147 +// this.storage.clear();
  148 +// }
  149 +// };
  150 +// return new WebStorage();
  151 +// }
2 152
3 -const GLOBAL_WS_URL = (() => {  
4 - const { host, href } = location  
5 - const reg = /^https/  
6 - return `${ reg.test(href) ? 'wss' : 'ws' }://${ host }/api/ws/plugins/telemetry?token=${GLOBAL_TOKEN}` 153 +const GLOBAL_STORAGE_KEY = (() => {
  154 + const isDev = location.href.includes('dev=1')
  155 + const DEVELOPMENT = 'DEVELOPMENT'
  156 + const PRODUCTION = 'PRODUCTION'
  157 + return `UNDEFINED__${ isDev ? DEVELOPMENT : PRODUCTION }__2.7.1__COMMON__LOCAL__KEY__`
  158 +})()
  159 +
  160 +const GLOBAL_TOKEN = (() => {
  161 + return JSON.parse(localStorage.getItem(GLOBAL_STORAGE_KEY)).value.JWT_TOKEN.value
7 })() 162 })()
8 163
9 -// const GLOBAL_WS_URL = `ws://47.99.141.212:8080/api/ws/plugins/telemetry?token=${ GLOBAL_TOKEN }`  
  164 +const GLOBAL_WS_URL = (() => {
  165 + const { host, href } = location
  166 + const reg = /^https/
  167 + return `${ reg.test(href) ? 'wss' : 'ws' }://${ host }/api/ws/plugins/telemetry?token=${ GLOBAL_TOKEN }`
  168 +})()
No preview for this file type
@@ -11170,7 +11170,6 @@ class DispatchCenter { @@ -11170,7 +11170,6 @@ class DispatchCenter {
11170 * @description 建立socket连接 11170 * @description 建立socket连接
11171 */ 11171 */
11172 connectSocket() { 11172 connectSocket() {
11173 - const GLOBAL_TOKEN = JSON.parse(localStorage.getItem("UNDEFINED__DEVELOPMENT__2.7.1__COMMON__LOCAL__KEY__")).value.JWT_TOKEN.value  
11174 this.socket = Ws.getInstance({ url: GLOBAL_WS_URL, onmessageCallback: this.socketOnmessage }) 11173 this.socket = Ws.getInstance({ url: GLOBAL_WS_URL, onmessageCallback: this.socketOnmessage })
11175 } 11174 }
11176 11175
No preview for this file type
No preview for this file type
  1 +;(function (root, factory) {
  2 + if (typeof exports === "object") {
  3 + // CommonJS
  4 + module.exports = exports = factory();
  5 + }
  6 + else if (typeof define === "function" && define.amd) {
  7 + // AMD
  8 + define([], factory);
  9 + }
  10 + else {
  11 + // Global (browser)
  12 + root.CryptoJS = factory();
  13 + }
  14 +}(this, function () {
  15 +
  16 + /*globals window, global, require*/
  17 +
  18 + /**
  19 + * CryptoJS core components.
  20 + */
  21 + var CryptoJS = CryptoJS || (function (Math, undefined) {
  22 +
  23 + var crypto;
  24 +
  25 + // Native crypto from window (Browser)
  26 + if (typeof window !== 'undefined' && window.crypto) {
  27 + crypto = window.crypto;
  28 + }
  29 +
  30 + // Native crypto in web worker (Browser)
  31 + if (typeof self !== 'undefined' && self.crypto) {
  32 + crypto = self.crypto;
  33 + }
  34 +
  35 + // Native crypto from worker
  36 + if (typeof globalThis !== 'undefined' && globalThis.crypto) {
  37 + crypto = globalThis.crypto;
  38 + }
  39 +
  40 + // Native (experimental IE 11) crypto from window (Browser)
  41 + if (!crypto && typeof window !== 'undefined' && window.msCrypto) {
  42 + crypto = window.msCrypto;
  43 + }
  44 +
  45 + // Native crypto from global (NodeJS)
  46 + if (!crypto && typeof global !== 'undefined' && global.crypto) {
  47 + crypto = global.crypto;
  48 + }
  49 +
  50 + // Native crypto import via require (NodeJS)
  51 + if (!crypto && typeof require === 'function') {
  52 + try {
  53 + crypto = require('crypto');
  54 + } catch (err) {}
  55 + }
  56 +
  57 + /*
  58 + * Cryptographically secure pseudorandom number generator
  59 + *
  60 + * As Math.random() is cryptographically not safe to use
  61 + */
  62 + var cryptoSecureRandomInt = function () {
  63 + if (crypto) {
  64 + // Use getRandomValues method (Browser)
  65 + if (typeof crypto.getRandomValues === 'function') {
  66 + try {
  67 + return crypto.getRandomValues(new Uint32Array(1))[0];
  68 + } catch (err) {}
  69 + }
  70 +
  71 + // Use randomBytes method (NodeJS)
  72 + if (typeof crypto.randomBytes === 'function') {
  73 + try {
  74 + return crypto.randomBytes(4).readInt32LE();
  75 + } catch (err) {}
  76 + }
  77 + }
  78 +
  79 + throw new Error('Native crypto module could not be used to get secure random number.');
  80 + };
  81 +
  82 + /*
  83 + * Local polyfill of Object.create
  84 +
  85 + */
  86 + var create = Object.create || (function () {
  87 + function F() {}
  88 +
  89 + return function (obj) {
  90 + var subtype;
  91 +
  92 + F.prototype = obj;
  93 +
  94 + subtype = new F();
  95 +
  96 + F.prototype = null;
  97 +
  98 + return subtype;
  99 + };
  100 + }());
  101 +
  102 + /**
  103 + * CryptoJS namespace.
  104 + */
  105 + var C = {};
  106 +
  107 + /**
  108 + * Library namespace.
  109 + */
  110 + var C_lib = C.lib = {};
  111 +
  112 + /**
  113 + * Base object for prototypal inheritance.
  114 + */
  115 + var Base = C_lib.Base = (function () {
  116 +
  117 +
  118 + return {
  119 + /**
  120 + * Creates a new object that inherits from this object.
  121 + *
  122 + * @param {Object} overrides Properties to copy into the new object.
  123 + *
  124 + * @return {Object} The new object.
  125 + *
  126 + * @static
  127 + *
  128 + * @example
  129 + *
  130 + * var MyType = CryptoJS.lib.Base.extend({
  131 + * field: 'value',
  132 + *
  133 + * method: function () {
  134 + * }
  135 + * });
  136 + */
  137 + extend: function (overrides) {
  138 + // Spawn
  139 + var subtype = create(this);
  140 +
  141 + // Augment
  142 + if (overrides) {
  143 + subtype.mixIn(overrides);
  144 + }
  145 +
  146 + // Create default initializer
  147 + if (!subtype.hasOwnProperty('init') || this.init === subtype.init) {
  148 + subtype.init = function () {
  149 + subtype.$super.init.apply(this, arguments);
  150 + };
  151 + }
  152 +
  153 + // Initializer's prototype is the subtype object
  154 + subtype.init.prototype = subtype;
  155 +
  156 + // Reference supertype
  157 + subtype.$super = this;
  158 +
  159 + return subtype;
  160 + },
  161 +
  162 + /**
  163 + * Extends this object and runs the init method.
  164 + * Arguments to create() will be passed to init().
  165 + *
  166 + * @return {Object} The new object.
  167 + *
  168 + * @static
  169 + *
  170 + * @example
  171 + *
  172 + * var instance = MyType.create();
  173 + */
  174 + create: function () {
  175 + var instance = this.extend();
  176 + instance.init.apply(instance, arguments);
  177 +
  178 + return instance;
  179 + },
  180 +
  181 + /**
  182 + * Initializes a newly created object.
  183 + * Override this method to add some logic when your objects are created.
  184 + *
  185 + * @example
  186 + *
  187 + * var MyType = CryptoJS.lib.Base.extend({
  188 + * init: function () {
  189 + * // ...
  190 + * }
  191 + * });
  192 + */
  193 + init: function () {
  194 + },
  195 +
  196 + /**
  197 + * Copies properties into this object.
  198 + *
  199 + * @param {Object} properties The properties to mix in.
  200 + *
  201 + * @example
  202 + *
  203 + * MyType.mixIn({
  204 + * field: 'value'
  205 + * });
  206 + */
  207 + mixIn: function (properties) {
  208 + for (var propertyName in properties) {
  209 + if (properties.hasOwnProperty(propertyName)) {
  210 + this[propertyName] = properties[propertyName];
  211 + }
  212 + }
  213 +
  214 + // IE won't copy toString using the loop above
  215 + if (properties.hasOwnProperty('toString')) {
  216 + this.toString = properties.toString;
  217 + }
  218 + },
  219 +
  220 + /**
  221 + * Creates a copy of this object.
  222 + *
  223 + * @return {Object} The clone.
  224 + *
  225 + * @example
  226 + *
  227 + * var clone = instance.clone();
  228 + */
  229 + clone: function () {
  230 + return this.init.prototype.extend(this);
  231 + }
  232 + };
  233 + }());
  234 +
  235 + /**
  236 + * An array of 32-bit words.
  237 + *
  238 + * @property {Array} words The array of 32-bit words.
  239 + * @property {number} sigBytes The number of significant bytes in this word array.
  240 + */
  241 + var WordArray = C_lib.WordArray = Base.extend({
  242 + /**
  243 + * Initializes a newly created word array.
  244 + *
  245 + * @param {Array} words (Optional) An array of 32-bit words.
  246 + * @param {number} sigBytes (Optional) The number of significant bytes in the words.
  247 + *
  248 + * @example
  249 + *
  250 + * var wordArray = CryptoJS.lib.WordArray.create();
  251 + * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]);
  252 + * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6);
  253 + */
  254 + init: function (words, sigBytes) {
  255 + words = this.words = words || [];
  256 +
  257 + if (sigBytes != undefined) {
  258 + this.sigBytes = sigBytes;
  259 + } else {
  260 + this.sigBytes = words.length * 4;
  261 + }
  262 + },
  263 +
  264 + /**
  265 + * Converts this word array to a string.
  266 + *
  267 + * @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex
  268 + *
  269 + * @return {string} The stringified word array.
  270 + *
  271 + * @example
  272 + *
  273 + * var string = wordArray + '';
  274 + * var string = wordArray.toString();
  275 + * var string = wordArray.toString(CryptoJS.enc.Utf8);
  276 + */
  277 + toString: function (encoder) {
  278 + return (encoder || Hex).stringify(this);
  279 + },
  280 +
  281 + /**
  282 + * Concatenates a word array to this word array.
  283 + *
  284 + * @param {WordArray} wordArray The word array to append.
  285 + *
  286 + * @return {WordArray} This word array.
  287 + *
  288 + * @example
  289 + *
  290 + * wordArray1.concat(wordArray2);
  291 + */
  292 + concat: function (wordArray) {
  293 + // Shortcuts
  294 + var thisWords = this.words;
  295 + var thatWords = wordArray.words;
  296 + var thisSigBytes = this.sigBytes;
  297 + var thatSigBytes = wordArray.sigBytes;
  298 +
  299 + // Clamp excess bits
  300 + this.clamp();
  301 +
  302 + // Concat
  303 + if (thisSigBytes % 4) {
  304 + // Copy one byte at a time
  305 + for (var i = 0; i < thatSigBytes; i++) {
  306 + var thatByte = (thatWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
  307 + thisWords[(thisSigBytes + i) >>> 2] |= thatByte << (24 - ((thisSigBytes + i) % 4) * 8);
  308 + }
  309 + } else {
  310 + // Copy one word at a time
  311 + for (var j = 0; j < thatSigBytes; j += 4) {
  312 + thisWords[(thisSigBytes + j) >>> 2] = thatWords[j >>> 2];
  313 + }
  314 + }
  315 + this.sigBytes += thatSigBytes;
  316 +
  317 + // Chainable
  318 + return this;
  319 + },
  320 +
  321 + /**
  322 + * Removes insignificant bits.
  323 + *
  324 + * @example
  325 + *
  326 + * wordArray.clamp();
  327 + */
  328 + clamp: function () {
  329 + // Shortcuts
  330 + var words = this.words;
  331 + var sigBytes = this.sigBytes;
  332 +
  333 + // Clamp
  334 + words[sigBytes >>> 2] &= 0xffffffff << (32 - (sigBytes % 4) * 8);
  335 + words.length = Math.ceil(sigBytes / 4);
  336 + },
  337 +
  338 + /**
  339 + * Creates a copy of this word array.
  340 + *
  341 + * @return {WordArray} The clone.
  342 + *
  343 + * @example
  344 + *
  345 + * var clone = wordArray.clone();
  346 + */
  347 + clone: function () {
  348 + var clone = Base.clone.call(this);
  349 + clone.words = this.words.slice(0);
  350 +
  351 + return clone;
  352 + },
  353 +
  354 + /**
  355 + * Creates a word array filled with random bytes.
  356 + *
  357 + * @param {number} nBytes The number of random bytes to generate.
  358 + *
  359 + * @return {WordArray} The random word array.
  360 + *
  361 + * @static
  362 + *
  363 + * @example
  364 + *
  365 + * var wordArray = CryptoJS.lib.WordArray.random(16);
  366 + */
  367 + random: function (nBytes) {
  368 + var words = [];
  369 +
  370 + for (var i = 0; i < nBytes; i += 4) {
  371 + words.push(cryptoSecureRandomInt());
  372 + }
  373 +
  374 + return new WordArray.init(words, nBytes);
  375 + }
  376 + });
  377 +
  378 + /**
  379 + * Encoder namespace.
  380 + */
  381 + var C_enc = C.enc = {};
  382 +
  383 + /**
  384 + * Hex encoding strategy.
  385 + */
  386 + var Hex = C_enc.Hex = {
  387 + /**
  388 + * Converts a word array to a hex string.
  389 + *
  390 + * @param {WordArray} wordArray The word array.
  391 + *
  392 + * @return {string} The hex string.
  393 + *
  394 + * @static
  395 + *
  396 + * @example
  397 + *
  398 + * var hexString = CryptoJS.enc.Hex.stringify(wordArray);
  399 + */
  400 + stringify: function (wordArray) {
  401 + // Shortcuts
  402 + var words = wordArray.words;
  403 + var sigBytes = wordArray.sigBytes;
  404 +
  405 + // Convert
  406 + var hexChars = [];
  407 + for (var i = 0; i < sigBytes; i++) {
  408 + var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
  409 + hexChars.push((bite >>> 4).toString(16));
  410 + hexChars.push((bite & 0x0f).toString(16));
  411 + }
  412 +
  413 + return hexChars.join('');
  414 + },
  415 +
  416 + /**
  417 + * Converts a hex string to a word array.
  418 + *
  419 + * @param {string} hexStr The hex string.
  420 + *
  421 + * @return {WordArray} The word array.
  422 + *
  423 + * @static
  424 + *
  425 + * @example
  426 + *
  427 + * var wordArray = CryptoJS.enc.Hex.parse(hexString);
  428 + */
  429 + parse: function (hexStr) {
  430 + // Shortcut
  431 + var hexStrLength = hexStr.length;
  432 +
  433 + // Convert
  434 + var words = [];
  435 + for (var i = 0; i < hexStrLength; i += 2) {
  436 + words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << (24 - (i % 8) * 4);
  437 + }
  438 +
  439 + return new WordArray.init(words, hexStrLength / 2);
  440 + }
  441 + };
  442 +
  443 + /**
  444 + * Latin1 encoding strategy.
  445 + */
  446 + var Latin1 = C_enc.Latin1 = {
  447 + /**
  448 + * Converts a word array to a Latin1 string.
  449 + *
  450 + * @param {WordArray} wordArray The word array.
  451 + *
  452 + * @return {string} The Latin1 string.
  453 + *
  454 + * @static
  455 + *
  456 + * @example
  457 + *
  458 + * var latin1String = CryptoJS.enc.Latin1.stringify(wordArray);
  459 + */
  460 + stringify: function (wordArray) {
  461 + // Shortcuts
  462 + var words = wordArray.words;
  463 + var sigBytes = wordArray.sigBytes;
  464 +
  465 + // Convert
  466 + var latin1Chars = [];
  467 + for (var i = 0; i < sigBytes; i++) {
  468 + var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
  469 + latin1Chars.push(String.fromCharCode(bite));
  470 + }
  471 +
  472 + return latin1Chars.join('');
  473 + },
  474 +
  475 + /**
  476 + * Converts a Latin1 string to a word array.
  477 + *
  478 + * @param {string} latin1Str The Latin1 string.
  479 + *
  480 + * @return {WordArray} The word array.
  481 + *
  482 + * @static
  483 + *
  484 + * @example
  485 + *
  486 + * var wordArray = CryptoJS.enc.Latin1.parse(latin1String);
  487 + */
  488 + parse: function (latin1Str) {
  489 + // Shortcut
  490 + var latin1StrLength = latin1Str.length;
  491 +
  492 + // Convert
  493 + var words = [];
  494 + for (var i = 0; i < latin1StrLength; i++) {
  495 + words[i >>> 2] |= (latin1Str.charCodeAt(i) & 0xff) << (24 - (i % 4) * 8);
  496 + }
  497 +
  498 + return new WordArray.init(words, latin1StrLength);
  499 + }
  500 + };
  501 +
  502 + /**
  503 + * UTF-8 encoding strategy.
  504 + */
  505 + var Utf8 = C_enc.Utf8 = {
  506 + /**
  507 + * Converts a word array to a UTF-8 string.
  508 + *
  509 + * @param {WordArray} wordArray The word array.
  510 + *
  511 + * @return {string} The UTF-8 string.
  512 + *
  513 + * @static
  514 + *
  515 + * @example
  516 + *
  517 + * var utf8String = CryptoJS.enc.Utf8.stringify(wordArray);
  518 + */
  519 + stringify: function (wordArray) {
  520 + try {
  521 + return decodeURIComponent(escape(Latin1.stringify(wordArray)));
  522 + } catch (e) {
  523 + throw new Error('Malformed UTF-8 data');
  524 + }
  525 + },
  526 +
  527 + /**
  528 + * Converts a UTF-8 string to a word array.
  529 + *
  530 + * @param {string} utf8Str The UTF-8 string.
  531 + *
  532 + * @return {WordArray} The word array.
  533 + *
  534 + * @static
  535 + *
  536 + * @example
  537 + *
  538 + * var wordArray = CryptoJS.enc.Utf8.parse(utf8String);
  539 + */
  540 + parse: function (utf8Str) {
  541 + return Latin1.parse(unescape(encodeURIComponent(utf8Str)));
  542 + }
  543 + };
  544 +
  545 + /**
  546 + * Abstract buffered block algorithm template.
  547 + *
  548 + * The property blockSize must be implemented in a concrete subtype.
  549 + *
  550 + * @property {number} _minBufferSize The number of blocks that should be kept unprocessed in the buffer. Default: 0
  551 + */
  552 + var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({
  553 + /**
  554 + * Resets this block algorithm's data buffer to its initial state.
  555 + *
  556 + * @example
  557 + *
  558 + * bufferedBlockAlgorithm.reset();
  559 + */
  560 + reset: function () {
  561 + // Initial values
  562 + this._data = new WordArray.init();
  563 + this._nDataBytes = 0;
  564 + },
  565 +
  566 + /**
  567 + * Adds new data to this block algorithm's buffer.
  568 + *
  569 + * @param {WordArray|string} data The data to append. Strings are converted to a WordArray using UTF-8.
  570 + *
  571 + * @example
  572 + *
  573 + * bufferedBlockAlgorithm._append('data');
  574 + * bufferedBlockAlgorithm._append(wordArray);
  575 + */
  576 + _append: function (data) {
  577 + // Convert string to WordArray, else assume WordArray already
  578 + if (typeof data == 'string') {
  579 + data = Utf8.parse(data);
  580 + }
  581 +
  582 + // Append
  583 + this._data.concat(data);
  584 + this._nDataBytes += data.sigBytes;
  585 + },
  586 +
  587 + /**
  588 + * Processes available data blocks.
  589 + *
  590 + * This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype.
  591 + *
  592 + * @param {boolean} doFlush Whether all blocks and partial blocks should be processed.
  593 + *
  594 + * @return {WordArray} The processed data.
  595 + *
  596 + * @example
  597 + *
  598 + * var processedData = bufferedBlockAlgorithm._process();
  599 + * var processedData = bufferedBlockAlgorithm._process(!!'flush');
  600 + */
  601 + _process: function (doFlush) {
  602 + var processedWords;
  603 +
  604 + // Shortcuts
  605 + var data = this._data;
  606 + var dataWords = data.words;
  607 + var dataSigBytes = data.sigBytes;
  608 + var blockSize = this.blockSize;
  609 + var blockSizeBytes = blockSize * 4;
  610 +
  611 + // Count blocks ready
  612 + var nBlocksReady = dataSigBytes / blockSizeBytes;
  613 + if (doFlush) {
  614 + // Round up to include partial blocks
  615 + nBlocksReady = Math.ceil(nBlocksReady);
  616 + } else {
  617 + // Round down to include only full blocks,
  618 + // less the number of blocks that must remain in the buffer
  619 + nBlocksReady = Math.max((nBlocksReady | 0) - this._minBufferSize, 0);
  620 + }
  621 +
  622 + // Count words ready
  623 + var nWordsReady = nBlocksReady * blockSize;
  624 +
  625 + // Count bytes ready
  626 + var nBytesReady = Math.min(nWordsReady * 4, dataSigBytes);
  627 +
  628 + // Process blocks
  629 + if (nWordsReady) {
  630 + for (var offset = 0; offset < nWordsReady; offset += blockSize) {
  631 + // Perform concrete-algorithm logic
  632 + this._doProcessBlock(dataWords, offset);
  633 + }
  634 +
  635 + // Remove processed words
  636 + processedWords = dataWords.splice(0, nWordsReady);
  637 + data.sigBytes -= nBytesReady;
  638 + }
  639 +
  640 + // Return processed words
  641 + return new WordArray.init(processedWords, nBytesReady);
  642 + },
  643 +
  644 + /**
  645 + * Creates a copy of this object.
  646 + *
  647 + * @return {Object} The clone.
  648 + *
  649 + * @example
  650 + *
  651 + * var clone = bufferedBlockAlgorithm.clone();
  652 + */
  653 + clone: function () {
  654 + var clone = Base.clone.call(this);
  655 + clone._data = this._data.clone();
  656 +
  657 + return clone;
  658 + },
  659 +
  660 + _minBufferSize: 0
  661 + });
  662 +
  663 + /**
  664 + * Abstract hasher template.
  665 + *
  666 + * @property {number} blockSize The number of 32-bit words this hasher operates on. Default: 16 (512 bits)
  667 + */
  668 + var Hasher = C_lib.Hasher = BufferedBlockAlgorithm.extend({
  669 + /**
  670 + * Configuration options.
  671 + */
  672 + cfg: Base.extend(),
  673 +
  674 + /**
  675 + * Initializes a newly created hasher.
  676 + *
  677 + * @param {Object} cfg (Optional) The configuration options to use for this hash computation.
  678 + *
  679 + * @example
  680 + *
  681 + * var hasher = CryptoJS.algo.SHA256.create();
  682 + */
  683 + init: function (cfg) {
  684 + // Apply config defaults
  685 + this.cfg = this.cfg.extend(cfg);
  686 +
  687 + // Set initial values
  688 + this.reset();
  689 + },
  690 +
  691 + /**
  692 + * Resets this hasher to its initial state.
  693 + *
  694 + * @example
  695 + *
  696 + * hasher.reset();
  697 + */
  698 + reset: function () {
  699 + // Reset data buffer
  700 + BufferedBlockAlgorithm.reset.call(this);
  701 +
  702 + // Perform concrete-hasher logic
  703 + this._doReset();
  704 + },
  705 +
  706 + /**
  707 + * Updates this hasher with a message.
  708 + *
  709 + * @param {WordArray|string} messageUpdate The message to append.
  710 + *
  711 + * @return {Hasher} This hasher.
  712 + *
  713 + * @example
  714 + *
  715 + * hasher.update('message');
  716 + * hasher.update(wordArray);
  717 + */
  718 + update: function (messageUpdate) {
  719 + // Append
  720 + this._append(messageUpdate);
  721 +
  722 + // Update the hash
  723 + this._process();
  724 +
  725 + // Chainable
  726 + return this;
  727 + },
  728 +
  729 + /**
  730 + * Finalizes the hash computation.
  731 + * Note that the finalize operation is effectively a destructive, read-once operation.
  732 + *
  733 + * @param {WordArray|string} messageUpdate (Optional) A final message update.
  734 + *
  735 + * @return {WordArray} The hash.
  736 + *
  737 + * @example
  738 + *
  739 + * var hash = hasher.finalize();
  740 + * var hash = hasher.finalize('message');
  741 + * var hash = hasher.finalize(wordArray);
  742 + */
  743 + finalize: function (messageUpdate) {
  744 + // Final message update
  745 + if (messageUpdate) {
  746 + this._append(messageUpdate);
  747 + }
  748 +
  749 + // Perform concrete-hasher logic
  750 + var hash = this._doFinalize();
  751 +
  752 + return hash;
  753 + },
  754 +
  755 + blockSize: 512/32,
  756 +
  757 + /**
  758 + * Creates a shortcut function to a hasher's object interface.
  759 + *
  760 + * @param {Hasher} hasher The hasher to create a helper for.
  761 + *
  762 + * @return {Function} The shortcut function.
  763 + *
  764 + * @static
  765 + *
  766 + * @example
  767 + *
  768 + * var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256);
  769 + */
  770 + _createHelper: function (hasher) {
  771 + return function (message, cfg) {
  772 + return new hasher.init(cfg).finalize(message);
  773 + };
  774 + },
  775 +
  776 + /**
  777 + * Creates a shortcut function to the HMAC's object interface.
  778 + *
  779 + * @param {Hasher} hasher The hasher to use in this HMAC helper.
  780 + *
  781 + * @return {Function} The shortcut function.
  782 + *
  783 + * @static
  784 + *
  785 + * @example
  786 + *
  787 + * var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256);
  788 + */
  789 + _createHmacHelper: function (hasher) {
  790 + return function (message, key) {
  791 + return new C_algo.HMAC.init(hasher, key).finalize(message);
  792 + };
  793 + }
  794 + });
  795 +
  796 + /**
  797 + * Algorithm namespace.
  798 + */
  799 + var C_algo = C.algo = {};
  800 +
  801 + return C;
  802 + }(Math));
  803 +
  804 +
  805 + (function (undefined) {
  806 + // Shortcuts
  807 + var C = CryptoJS;
  808 + var C_lib = C.lib;
  809 + var Base = C_lib.Base;
  810 + var X32WordArray = C_lib.WordArray;
  811 +
  812 + /**
  813 + * x64 namespace.
  814 + */
  815 + var C_x64 = C.x64 = {};
  816 +
  817 + /**
  818 + * A 64-bit word.
  819 + */
  820 + var X64Word = C_x64.Word = Base.extend({
  821 + /**
  822 + * Initializes a newly created 64-bit word.
  823 + *
  824 + * @param {number} high The high 32 bits.
  825 + * @param {number} low The low 32 bits.
  826 + *
  827 + * @example
  828 + *
  829 + * var x64Word = CryptoJS.x64.Word.create(0x00010203, 0x04050607);
  830 + */
  831 + init: function (high, low) {
  832 + this.high = high;
  833 + this.low = low;
  834 + }
  835 +
  836 + /**
  837 + * Bitwise NOTs this word.
  838 + *
  839 + * @return {X64Word} A new x64-Word object after negating.
  840 + *
  841 + * @example
  842 + *
  843 + * var negated = x64Word.not();
  844 + */
  845 + // not: function () {
  846 + // var high = ~this.high;
  847 + // var low = ~this.low;
  848 +
  849 + // return X64Word.create(high, low);
  850 + // },
  851 +
  852 + /**
  853 + * Bitwise ANDs this word with the passed word.
  854 + *
  855 + * @param {X64Word} word The x64-Word to AND with this word.
  856 + *
  857 + * @return {X64Word} A new x64-Word object after ANDing.
  858 + *
  859 + * @example
  860 + *
  861 + * var anded = x64Word.and(anotherX64Word);
  862 + */
  863 + // and: function (word) {
  864 + // var high = this.high & word.high;
  865 + // var low = this.low & word.low;
  866 +
  867 + // return X64Word.create(high, low);
  868 + // },
  869 +
  870 + /**
  871 + * Bitwise ORs this word with the passed word.
  872 + *
  873 + * @param {X64Word} word The x64-Word to OR with this word.
  874 + *
  875 + * @return {X64Word} A new x64-Word object after ORing.
  876 + *
  877 + * @example
  878 + *
  879 + * var ored = x64Word.or(anotherX64Word);
  880 + */
  881 + // or: function (word) {
  882 + // var high = this.high | word.high;
  883 + // var low = this.low | word.low;
  884 +
  885 + // return X64Word.create(high, low);
  886 + // },
  887 +
  888 + /**
  889 + * Bitwise XORs this word with the passed word.
  890 + *
  891 + * @param {X64Word} word The x64-Word to XOR with this word.
  892 + *
  893 + * @return {X64Word} A new x64-Word object after XORing.
  894 + *
  895 + * @example
  896 + *
  897 + * var xored = x64Word.xor(anotherX64Word);
  898 + */
  899 + // xor: function (word) {
  900 + // var high = this.high ^ word.high;
  901 + // var low = this.low ^ word.low;
  902 +
  903 + // return X64Word.create(high, low);
  904 + // },
  905 +
  906 + /**
  907 + * Shifts this word n bits to the left.
  908 + *
  909 + * @param {number} n The number of bits to shift.
  910 + *
  911 + * @return {X64Word} A new x64-Word object after shifting.
  912 + *
  913 + * @example
  914 + *
  915 + * var shifted = x64Word.shiftL(25);
  916 + */
  917 + // shiftL: function (n) {
  918 + // if (n < 32) {
  919 + // var high = (this.high << n) | (this.low >>> (32 - n));
  920 + // var low = this.low << n;
  921 + // } else {
  922 + // var high = this.low << (n - 32);
  923 + // var low = 0;
  924 + // }
  925 +
  926 + // return X64Word.create(high, low);
  927 + // },
  928 +
  929 + /**
  930 + * Shifts this word n bits to the right.
  931 + *
  932 + * @param {number} n The number of bits to shift.
  933 + *
  934 + * @return {X64Word} A new x64-Word object after shifting.
  935 + *
  936 + * @example
  937 + *
  938 + * var shifted = x64Word.shiftR(7);
  939 + */
  940 + // shiftR: function (n) {
  941 + // if (n < 32) {
  942 + // var low = (this.low >>> n) | (this.high << (32 - n));
  943 + // var high = this.high >>> n;
  944 + // } else {
  945 + // var low = this.high >>> (n - 32);
  946 + // var high = 0;
  947 + // }
  948 +
  949 + // return X64Word.create(high, low);
  950 + // },
  951 +
  952 + /**
  953 + * Rotates this word n bits to the left.
  954 + *
  955 + * @param {number} n The number of bits to rotate.
  956 + *
  957 + * @return {X64Word} A new x64-Word object after rotating.
  958 + *
  959 + * @example
  960 + *
  961 + * var rotated = x64Word.rotL(25);
  962 + */
  963 + // rotL: function (n) {
  964 + // return this.shiftL(n).or(this.shiftR(64 - n));
  965 + // },
  966 +
  967 + /**
  968 + * Rotates this word n bits to the right.
  969 + *
  970 + * @param {number} n The number of bits to rotate.
  971 + *
  972 + * @return {X64Word} A new x64-Word object after rotating.
  973 + *
  974 + * @example
  975 + *
  976 + * var rotated = x64Word.rotR(7);
  977 + */
  978 + // rotR: function (n) {
  979 + // return this.shiftR(n).or(this.shiftL(64 - n));
  980 + // },
  981 +
  982 + /**
  983 + * Adds this word with the passed word.
  984 + *
  985 + * @param {X64Word} word The x64-Word to add with this word.
  986 + *
  987 + * @return {X64Word} A new x64-Word object after adding.
  988 + *
  989 + * @example
  990 + *
  991 + * var added = x64Word.add(anotherX64Word);
  992 + */
  993 + // add: function (word) {
  994 + // var low = (this.low + word.low) | 0;
  995 + // var carry = (low >>> 0) < (this.low >>> 0) ? 1 : 0;
  996 + // var high = (this.high + word.high + carry) | 0;
  997 +
  998 + // return X64Word.create(high, low);
  999 + // }
  1000 + });
  1001 +
  1002 + /**
  1003 + * An array of 64-bit words.
  1004 + *
  1005 + * @property {Array} words The array of CryptoJS.x64.Word objects.
  1006 + * @property {number} sigBytes The number of significant bytes in this word array.
  1007 + */
  1008 + var X64WordArray = C_x64.WordArray = Base.extend({
  1009 + /**
  1010 + * Initializes a newly created word array.
  1011 + *
  1012 + * @param {Array} words (Optional) An array of CryptoJS.x64.Word objects.
  1013 + * @param {number} sigBytes (Optional) The number of significant bytes in the words.
  1014 + *
  1015 + * @example
  1016 + *
  1017 + * var wordArray = CryptoJS.x64.WordArray.create();
  1018 + *
  1019 + * var wordArray = CryptoJS.x64.WordArray.create([
  1020 + * CryptoJS.x64.Word.create(0x00010203, 0x04050607),
  1021 + * CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f)
  1022 + * ]);
  1023 + *
  1024 + * var wordArray = CryptoJS.x64.WordArray.create([
  1025 + * CryptoJS.x64.Word.create(0x00010203, 0x04050607),
  1026 + * CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f)
  1027 + * ], 10);
  1028 + */
  1029 + init: function (words, sigBytes) {
  1030 + words = this.words = words || [];
  1031 +
  1032 + if (sigBytes != undefined) {
  1033 + this.sigBytes = sigBytes;
  1034 + } else {
  1035 + this.sigBytes = words.length * 8;
  1036 + }
  1037 + },
  1038 +
  1039 + /**
  1040 + * Converts this 64-bit word array to a 32-bit word array.
  1041 + *
  1042 + * @return {CryptoJS.lib.WordArray} This word array's data as a 32-bit word array.
  1043 + *
  1044 + * @example
  1045 + *
  1046 + * var x32WordArray = x64WordArray.toX32();
  1047 + */
  1048 + toX32: function () {
  1049 + // Shortcuts
  1050 + var x64Words = this.words;
  1051 + var x64WordsLength = x64Words.length;
  1052 +
  1053 + // Convert
  1054 + var x32Words = [];
  1055 + for (var i = 0; i < x64WordsLength; i++) {
  1056 + var x64Word = x64Words[i];
  1057 + x32Words.push(x64Word.high);
  1058 + x32Words.push(x64Word.low);
  1059 + }
  1060 +
  1061 + return X32WordArray.create(x32Words, this.sigBytes);
  1062 + },
  1063 +
  1064 + /**
  1065 + * Creates a copy of this word array.
  1066 + *
  1067 + * @return {X64WordArray} The clone.
  1068 + *
  1069 + * @example
  1070 + *
  1071 + * var clone = x64WordArray.clone();
  1072 + */
  1073 + clone: function () {
  1074 + var clone = Base.clone.call(this);
  1075 +
  1076 + // Clone "words" array
  1077 + var words = clone.words = this.words.slice(0);
  1078 +
  1079 + // Clone each X64Word object
  1080 + var wordsLength = words.length;
  1081 + for (var i = 0; i < wordsLength; i++) {
  1082 + words[i] = words[i].clone();
  1083 + }
  1084 +
  1085 + return clone;
  1086 + }
  1087 + });
  1088 + }());
  1089 +
  1090 +
  1091 + (function () {
  1092 + // Check if typed arrays are supported
  1093 + if (typeof ArrayBuffer != 'function') {
  1094 + return;
  1095 + }
  1096 +
  1097 + // Shortcuts
  1098 + var C = CryptoJS;
  1099 + var C_lib = C.lib;
  1100 + var WordArray = C_lib.WordArray;
  1101 +
  1102 + // Reference original init
  1103 + var superInit = WordArray.init;
  1104 +
  1105 + // Augment WordArray.init to handle typed arrays
  1106 + var subInit = WordArray.init = function (typedArray) {
  1107 + // Convert buffers to uint8
  1108 + if (typedArray instanceof ArrayBuffer) {
  1109 + typedArray = new Uint8Array(typedArray);
  1110 + }
  1111 +
  1112 + // Convert other array views to uint8
  1113 + if (
  1114 + typedArray instanceof Int8Array ||
  1115 + (typeof Uint8ClampedArray !== "undefined" && typedArray instanceof Uint8ClampedArray) ||
  1116 + typedArray instanceof Int16Array ||
  1117 + typedArray instanceof Uint16Array ||
  1118 + typedArray instanceof Int32Array ||
  1119 + typedArray instanceof Uint32Array ||
  1120 + typedArray instanceof Float32Array ||
  1121 + typedArray instanceof Float64Array
  1122 + ) {
  1123 + typedArray = new Uint8Array(typedArray.buffer, typedArray.byteOffset, typedArray.byteLength);
  1124 + }
  1125 +
  1126 + // Handle Uint8Array
  1127 + if (typedArray instanceof Uint8Array) {
  1128 + // Shortcut
  1129 + var typedArrayByteLength = typedArray.byteLength;
  1130 +
  1131 + // Extract bytes
  1132 + var words = [];
  1133 + for (var i = 0; i < typedArrayByteLength; i++) {
  1134 + words[i >>> 2] |= typedArray[i] << (24 - (i % 4) * 8);
  1135 + }
  1136 +
  1137 + // Initialize this word array
  1138 + superInit.call(this, words, typedArrayByteLength);
  1139 + } else {
  1140 + // Else call normal init
  1141 + superInit.apply(this, arguments);
  1142 + }
  1143 + };
  1144 +
  1145 + subInit.prototype = WordArray;
  1146 + }());
  1147 +
  1148 +
  1149 + (function () {
  1150 + // Shortcuts
  1151 + var C = CryptoJS;
  1152 + var C_lib = C.lib;
  1153 + var WordArray = C_lib.WordArray;
  1154 + var C_enc = C.enc;
  1155 +
  1156 + /**
  1157 + * UTF-16 BE encoding strategy.
  1158 + */
  1159 + var Utf16BE = C_enc.Utf16 = C_enc.Utf16BE = {
  1160 + /**
  1161 + * Converts a word array to a UTF-16 BE string.
  1162 + *
  1163 + * @param {WordArray} wordArray The word array.
  1164 + *
  1165 + * @return {string} The UTF-16 BE string.
  1166 + *
  1167 + * @static
  1168 + *
  1169 + * @example
  1170 + *
  1171 + * var utf16String = CryptoJS.enc.Utf16.stringify(wordArray);
  1172 + */
  1173 + stringify: function (wordArray) {
  1174 + // Shortcuts
  1175 + var words = wordArray.words;
  1176 + var sigBytes = wordArray.sigBytes;
  1177 +
  1178 + // Convert
  1179 + var utf16Chars = [];
  1180 + for (var i = 0; i < sigBytes; i += 2) {
  1181 + var codePoint = (words[i >>> 2] >>> (16 - (i % 4) * 8)) & 0xffff;
  1182 + utf16Chars.push(String.fromCharCode(codePoint));
  1183 + }
  1184 +
  1185 + return utf16Chars.join('');
  1186 + },
  1187 +
  1188 + /**
  1189 + * Converts a UTF-16 BE string to a word array.
  1190 + *
  1191 + * @param {string} utf16Str The UTF-16 BE string.
  1192 + *
  1193 + * @return {WordArray} The word array.
  1194 + *
  1195 + * @static
  1196 + *
  1197 + * @example
  1198 + *
  1199 + * var wordArray = CryptoJS.enc.Utf16.parse(utf16String);
  1200 + */
  1201 + parse: function (utf16Str) {
  1202 + // Shortcut
  1203 + var utf16StrLength = utf16Str.length;
  1204 +
  1205 + // Convert
  1206 + var words = [];
  1207 + for (var i = 0; i < utf16StrLength; i++) {
  1208 + words[i >>> 1] |= utf16Str.charCodeAt(i) << (16 - (i % 2) * 16);
  1209 + }
  1210 +
  1211 + return WordArray.create(words, utf16StrLength * 2);
  1212 + }
  1213 + };
  1214 +
  1215 + /**
  1216 + * UTF-16 LE encoding strategy.
  1217 + */
  1218 + C_enc.Utf16LE = {
  1219 + /**
  1220 + * Converts a word array to a UTF-16 LE string.
  1221 + *
  1222 + * @param {WordArray} wordArray The word array.
  1223 + *
  1224 + * @return {string} The UTF-16 LE string.
  1225 + *
  1226 + * @static
  1227 + *
  1228 + * @example
  1229 + *
  1230 + * var utf16Str = CryptoJS.enc.Utf16LE.stringify(wordArray);
  1231 + */
  1232 + stringify: function (wordArray) {
  1233 + // Shortcuts
  1234 + var words = wordArray.words;
  1235 + var sigBytes = wordArray.sigBytes;
  1236 +
  1237 + // Convert
  1238 + var utf16Chars = [];
  1239 + for (var i = 0; i < sigBytes; i += 2) {
  1240 + var codePoint = swapEndian((words[i >>> 2] >>> (16 - (i % 4) * 8)) & 0xffff);
  1241 + utf16Chars.push(String.fromCharCode(codePoint));
  1242 + }
  1243 +
  1244 + return utf16Chars.join('');
  1245 + },
  1246 +
  1247 + /**
  1248 + * Converts a UTF-16 LE string to a word array.
  1249 + *
  1250 + * @param {string} utf16Str The UTF-16 LE string.
  1251 + *
  1252 + * @return {WordArray} The word array.
  1253 + *
  1254 + * @static
  1255 + *
  1256 + * @example
  1257 + *
  1258 + * var wordArray = CryptoJS.enc.Utf16LE.parse(utf16Str);
  1259 + */
  1260 + parse: function (utf16Str) {
  1261 + // Shortcut
  1262 + var utf16StrLength = utf16Str.length;
  1263 +
  1264 + // Convert
  1265 + var words = [];
  1266 + for (var i = 0; i < utf16StrLength; i++) {
  1267 + words[i >>> 1] |= swapEndian(utf16Str.charCodeAt(i) << (16 - (i % 2) * 16));
  1268 + }
  1269 +
  1270 + return WordArray.create(words, utf16StrLength * 2);
  1271 + }
  1272 + };
  1273 +
  1274 + function swapEndian(word) {
  1275 + return ((word << 8) & 0xff00ff00) | ((word >>> 8) & 0x00ff00ff);
  1276 + }
  1277 + }());
  1278 +
  1279 +
  1280 + (function () {
  1281 + // Shortcuts
  1282 + var C = CryptoJS;
  1283 + var C_lib = C.lib;
  1284 + var WordArray = C_lib.WordArray;
  1285 + var C_enc = C.enc;
  1286 +
  1287 + /**
  1288 + * Base64 encoding strategy.
  1289 + */
  1290 + var Base64 = C_enc.Base64 = {
  1291 + /**
  1292 + * Converts a word array to a Base64 string.
  1293 + *
  1294 + * @param {WordArray} wordArray The word array.
  1295 + *
  1296 + * @return {string} The Base64 string.
  1297 + *
  1298 + * @static
  1299 + *
  1300 + * @example
  1301 + *
  1302 + * var base64String = CryptoJS.enc.Base64.stringify(wordArray);
  1303 + */
  1304 + stringify: function (wordArray) {
  1305 + // Shortcuts
  1306 + var words = wordArray.words;
  1307 + var sigBytes = wordArray.sigBytes;
  1308 + var map = this._map;
  1309 +
  1310 + // Clamp excess bits
  1311 + wordArray.clamp();
  1312 +
  1313 + // Convert
  1314 + var base64Chars = [];
  1315 + for (var i = 0; i < sigBytes; i += 3) {
  1316 + var byte1 = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
  1317 + var byte2 = (words[(i + 1) >>> 2] >>> (24 - ((i + 1) % 4) * 8)) & 0xff;
  1318 + var byte3 = (words[(i + 2) >>> 2] >>> (24 - ((i + 2) % 4) * 8)) & 0xff;
  1319 +
  1320 + var triplet = (byte1 << 16) | (byte2 << 8) | byte3;
  1321 +
  1322 + for (var j = 0; (j < 4) && (i + j * 0.75 < sigBytes); j++) {
  1323 + base64Chars.push(map.charAt((triplet >>> (6 * (3 - j))) & 0x3f));
  1324 + }
  1325 + }
  1326 +
  1327 + // Add padding
  1328 + var paddingChar = map.charAt(64);
  1329 + if (paddingChar) {
  1330 + while (base64Chars.length % 4) {
  1331 + base64Chars.push(paddingChar);
  1332 + }
  1333 + }
  1334 +
  1335 + return base64Chars.join('');
  1336 + },
  1337 +
  1338 + /**
  1339 + * Converts a Base64 string to a word array.
  1340 + *
  1341 + * @param {string} base64Str The Base64 string.
  1342 + *
  1343 + * @return {WordArray} The word array.
  1344 + *
  1345 + * @static
  1346 + *
  1347 + * @example
  1348 + *
  1349 + * var wordArray = CryptoJS.enc.Base64.parse(base64String);
  1350 + */
  1351 + parse: function (base64Str) {
  1352 + // Shortcuts
  1353 + var base64StrLength = base64Str.length;
  1354 + var map = this._map;
  1355 + var reverseMap = this._reverseMap;
  1356 +
  1357 + if (!reverseMap) {
  1358 + reverseMap = this._reverseMap = [];
  1359 + for (var j = 0; j < map.length; j++) {
  1360 + reverseMap[map.charCodeAt(j)] = j;
  1361 + }
  1362 + }
  1363 +
  1364 + // Ignore padding
  1365 + var paddingChar = map.charAt(64);
  1366 + if (paddingChar) {
  1367 + var paddingIndex = base64Str.indexOf(paddingChar);
  1368 + if (paddingIndex !== -1) {
  1369 + base64StrLength = paddingIndex;
  1370 + }
  1371 + }
  1372 +
  1373 + // Convert
  1374 + return parseLoop(base64Str, base64StrLength, reverseMap);
  1375 +
  1376 + },
  1377 +
  1378 + _map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='
  1379 + };
  1380 +
  1381 + function parseLoop(base64Str, base64StrLength, reverseMap) {
  1382 + var words = [];
  1383 + var nBytes = 0;
  1384 + for (var i = 0; i < base64StrLength; i++) {
  1385 + if (i % 4) {
  1386 + var bits1 = reverseMap[base64Str.charCodeAt(i - 1)] << ((i % 4) * 2);
  1387 + var bits2 = reverseMap[base64Str.charCodeAt(i)] >>> (6 - (i % 4) * 2);
  1388 + var bitsCombined = bits1 | bits2;
  1389 + words[nBytes >>> 2] |= bitsCombined << (24 - (nBytes % 4) * 8);
  1390 + nBytes++;
  1391 + }
  1392 + }
  1393 + return WordArray.create(words, nBytes);
  1394 + }
  1395 + }());
  1396 +
  1397 +
  1398 + (function () {
  1399 + // Shortcuts
  1400 + var C = CryptoJS;
  1401 + var C_lib = C.lib;
  1402 + var WordArray = C_lib.WordArray;
  1403 + var C_enc = C.enc;
  1404 +
  1405 + /**
  1406 + * Base64url encoding strategy.
  1407 + */
  1408 + var Base64url = C_enc.Base64url = {
  1409 + /**
  1410 + * Converts a word array to a Base64url string.
  1411 + *
  1412 + * @param {WordArray} wordArray The word array.
  1413 + *
  1414 + * @param {boolean} urlSafe Whether to use url safe
  1415 + *
  1416 + * @return {string} The Base64url string.
  1417 + *
  1418 + * @static
  1419 + *
  1420 + * @example
  1421 + *
  1422 + * var base64String = CryptoJS.enc.Base64url.stringify(wordArray);
  1423 + */
  1424 + stringify: function (wordArray, urlSafe=true) {
  1425 + // Shortcuts
  1426 + var words = wordArray.words;
  1427 + var sigBytes = wordArray.sigBytes;
  1428 + var map = urlSafe ? this._safe_map : this._map;
  1429 +
  1430 + // Clamp excess bits
  1431 + wordArray.clamp();
  1432 +
  1433 + // Convert
  1434 + var base64Chars = [];
  1435 + for (var i = 0; i < sigBytes; i += 3) {
  1436 + var byte1 = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
  1437 + var byte2 = (words[(i + 1) >>> 2] >>> (24 - ((i + 1) % 4) * 8)) & 0xff;
  1438 + var byte3 = (words[(i + 2) >>> 2] >>> (24 - ((i + 2) % 4) * 8)) & 0xff;
  1439 +
  1440 + var triplet = (byte1 << 16) | (byte2 << 8) | byte3;
  1441 +
  1442 + for (var j = 0; (j < 4) && (i + j * 0.75 < sigBytes); j++) {
  1443 + base64Chars.push(map.charAt((triplet >>> (6 * (3 - j))) & 0x3f));
  1444 + }
  1445 + }
  1446 +
  1447 + // Add padding
  1448 + var paddingChar = map.charAt(64);
  1449 + if (paddingChar) {
  1450 + while (base64Chars.length % 4) {
  1451 + base64Chars.push(paddingChar);
  1452 + }
  1453 + }
  1454 +
  1455 + return base64Chars.join('');
  1456 + },
  1457 +
  1458 + /**
  1459 + * Converts a Base64url string to a word array.
  1460 + *
  1461 + * @param {string} base64Str The Base64url string.
  1462 + *
  1463 + * @param {boolean} urlSafe Whether to use url safe
  1464 + *
  1465 + * @return {WordArray} The word array.
  1466 + *
  1467 + * @static
  1468 + *
  1469 + * @example
  1470 + *
  1471 + * var wordArray = CryptoJS.enc.Base64url.parse(base64String);
  1472 + */
  1473 + parse: function (base64Str, urlSafe=true) {
  1474 + // Shortcuts
  1475 + var base64StrLength = base64Str.length;
  1476 + var map = urlSafe ? this._safe_map : this._map;
  1477 + var reverseMap = this._reverseMap;
  1478 +
  1479 + if (!reverseMap) {
  1480 + reverseMap = this._reverseMap = [];
  1481 + for (var j = 0; j < map.length; j++) {
  1482 + reverseMap[map.charCodeAt(j)] = j;
  1483 + }
  1484 + }
  1485 +
  1486 + // Ignore padding
  1487 + var paddingChar = map.charAt(64);
  1488 + if (paddingChar) {
  1489 + var paddingIndex = base64Str.indexOf(paddingChar);
  1490 + if (paddingIndex !== -1) {
  1491 + base64StrLength = paddingIndex;
  1492 + }
  1493 + }
  1494 +
  1495 + // Convert
  1496 + return parseLoop(base64Str, base64StrLength, reverseMap);
  1497 +
  1498 + },
  1499 +
  1500 + _map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=',
  1501 + _safe_map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_',
  1502 + };
  1503 +
  1504 + function parseLoop(base64Str, base64StrLength, reverseMap) {
  1505 + var words = [];
  1506 + var nBytes = 0;
  1507 + for (var i = 0; i < base64StrLength; i++) {
  1508 + if (i % 4) {
  1509 + var bits1 = reverseMap[base64Str.charCodeAt(i - 1)] << ((i % 4) * 2);
  1510 + var bits2 = reverseMap[base64Str.charCodeAt(i)] >>> (6 - (i % 4) * 2);
  1511 + var bitsCombined = bits1 | bits2;
  1512 + words[nBytes >>> 2] |= bitsCombined << (24 - (nBytes % 4) * 8);
  1513 + nBytes++;
  1514 + }
  1515 + }
  1516 + return WordArray.create(words, nBytes);
  1517 + }
  1518 + }());
  1519 +
  1520 + (function (Math) {
  1521 + // Shortcuts
  1522 + var C = CryptoJS;
  1523 + var C_lib = C.lib;
  1524 + var WordArray = C_lib.WordArray;
  1525 + var Hasher = C_lib.Hasher;
  1526 + var C_algo = C.algo;
  1527 +
  1528 + // Constants table
  1529 + var T = [];
  1530 +
  1531 + // Compute constants
  1532 + (function () {
  1533 + for (var i = 0; i < 64; i++) {
  1534 + T[i] = (Math.abs(Math.sin(i + 1)) * 0x100000000) | 0;
  1535 + }
  1536 + }());
  1537 +
  1538 + /**
  1539 + * MD5 hash algorithm.
  1540 + */
  1541 + var MD5 = C_algo.MD5 = Hasher.extend({
  1542 + _doReset: function () {
  1543 + this._hash = new WordArray.init([
  1544 + 0x67452301, 0xefcdab89,
  1545 + 0x98badcfe, 0x10325476
  1546 + ]);
  1547 + },
  1548 +
  1549 + _doProcessBlock: function (M, offset) {
  1550 + // Swap endian
  1551 + for (var i = 0; i < 16; i++) {
  1552 + // Shortcuts
  1553 + var offset_i = offset + i;
  1554 + var M_offset_i = M[offset_i];
  1555 +
  1556 + M[offset_i] = (
  1557 + (((M_offset_i << 8) | (M_offset_i >>> 24)) & 0x00ff00ff) |
  1558 + (((M_offset_i << 24) | (M_offset_i >>> 8)) & 0xff00ff00)
  1559 + );
  1560 + }
  1561 +
  1562 + // Shortcuts
  1563 + var H = this._hash.words;
  1564 +
  1565 + var M_offset_0 = M[offset + 0];
  1566 + var M_offset_1 = M[offset + 1];
  1567 + var M_offset_2 = M[offset + 2];
  1568 + var M_offset_3 = M[offset + 3];
  1569 + var M_offset_4 = M[offset + 4];
  1570 + var M_offset_5 = M[offset + 5];
  1571 + var M_offset_6 = M[offset + 6];
  1572 + var M_offset_7 = M[offset + 7];
  1573 + var M_offset_8 = M[offset + 8];
  1574 + var M_offset_9 = M[offset + 9];
  1575 + var M_offset_10 = M[offset + 10];
  1576 + var M_offset_11 = M[offset + 11];
  1577 + var M_offset_12 = M[offset + 12];
  1578 + var M_offset_13 = M[offset + 13];
  1579 + var M_offset_14 = M[offset + 14];
  1580 + var M_offset_15 = M[offset + 15];
  1581 +
  1582 + // Working varialbes
  1583 + var a = H[0];
  1584 + var b = H[1];
  1585 + var c = H[2];
  1586 + var d = H[3];
  1587 +
  1588 + // Computation
  1589 + a = FF(a, b, c, d, M_offset_0, 7, T[0]);
  1590 + d = FF(d, a, b, c, M_offset_1, 12, T[1]);
  1591 + c = FF(c, d, a, b, M_offset_2, 17, T[2]);
  1592 + b = FF(b, c, d, a, M_offset_3, 22, T[3]);
  1593 + a = FF(a, b, c, d, M_offset_4, 7, T[4]);
  1594 + d = FF(d, a, b, c, M_offset_5, 12, T[5]);
  1595 + c = FF(c, d, a, b, M_offset_6, 17, T[6]);
  1596 + b = FF(b, c, d, a, M_offset_7, 22, T[7]);
  1597 + a = FF(a, b, c, d, M_offset_8, 7, T[8]);
  1598 + d = FF(d, a, b, c, M_offset_9, 12, T[9]);
  1599 + c = FF(c, d, a, b, M_offset_10, 17, T[10]);
  1600 + b = FF(b, c, d, a, M_offset_11, 22, T[11]);
  1601 + a = FF(a, b, c, d, M_offset_12, 7, T[12]);
  1602 + d = FF(d, a, b, c, M_offset_13, 12, T[13]);
  1603 + c = FF(c, d, a, b, M_offset_14, 17, T[14]);
  1604 + b = FF(b, c, d, a, M_offset_15, 22, T[15]);
  1605 +
  1606 + a = GG(a, b, c, d, M_offset_1, 5, T[16]);
  1607 + d = GG(d, a, b, c, M_offset_6, 9, T[17]);
  1608 + c = GG(c, d, a, b, M_offset_11, 14, T[18]);
  1609 + b = GG(b, c, d, a, M_offset_0, 20, T[19]);
  1610 + a = GG(a, b, c, d, M_offset_5, 5, T[20]);
  1611 + d = GG(d, a, b, c, M_offset_10, 9, T[21]);
  1612 + c = GG(c, d, a, b, M_offset_15, 14, T[22]);
  1613 + b = GG(b, c, d, a, M_offset_4, 20, T[23]);
  1614 + a = GG(a, b, c, d, M_offset_9, 5, T[24]);
  1615 + d = GG(d, a, b, c, M_offset_14, 9, T[25]);
  1616 + c = GG(c, d, a, b, M_offset_3, 14, T[26]);
  1617 + b = GG(b, c, d, a, M_offset_8, 20, T[27]);
  1618 + a = GG(a, b, c, d, M_offset_13, 5, T[28]);
  1619 + d = GG(d, a, b, c, M_offset_2, 9, T[29]);
  1620 + c = GG(c, d, a, b, M_offset_7, 14, T[30]);
  1621 + b = GG(b, c, d, a, M_offset_12, 20, T[31]);
  1622 +
  1623 + a = HH(a, b, c, d, M_offset_5, 4, T[32]);
  1624 + d = HH(d, a, b, c, M_offset_8, 11, T[33]);
  1625 + c = HH(c, d, a, b, M_offset_11, 16, T[34]);
  1626 + b = HH(b, c, d, a, M_offset_14, 23, T[35]);
  1627 + a = HH(a, b, c, d, M_offset_1, 4, T[36]);
  1628 + d = HH(d, a, b, c, M_offset_4, 11, T[37]);
  1629 + c = HH(c, d, a, b, M_offset_7, 16, T[38]);
  1630 + b = HH(b, c, d, a, M_offset_10, 23, T[39]);
  1631 + a = HH(a, b, c, d, M_offset_13, 4, T[40]);
  1632 + d = HH(d, a, b, c, M_offset_0, 11, T[41]);
  1633 + c = HH(c, d, a, b, M_offset_3, 16, T[42]);
  1634 + b = HH(b, c, d, a, M_offset_6, 23, T[43]);
  1635 + a = HH(a, b, c, d, M_offset_9, 4, T[44]);
  1636 + d = HH(d, a, b, c, M_offset_12, 11, T[45]);
  1637 + c = HH(c, d, a, b, M_offset_15, 16, T[46]);
  1638 + b = HH(b, c, d, a, M_offset_2, 23, T[47]);
  1639 +
  1640 + a = II(a, b, c, d, M_offset_0, 6, T[48]);
  1641 + d = II(d, a, b, c, M_offset_7, 10, T[49]);
  1642 + c = II(c, d, a, b, M_offset_14, 15, T[50]);
  1643 + b = II(b, c, d, a, M_offset_5, 21, T[51]);
  1644 + a = II(a, b, c, d, M_offset_12, 6, T[52]);
  1645 + d = II(d, a, b, c, M_offset_3, 10, T[53]);
  1646 + c = II(c, d, a, b, M_offset_10, 15, T[54]);
  1647 + b = II(b, c, d, a, M_offset_1, 21, T[55]);
  1648 + a = II(a, b, c, d, M_offset_8, 6, T[56]);
  1649 + d = II(d, a, b, c, M_offset_15, 10, T[57]);
  1650 + c = II(c, d, a, b, M_offset_6, 15, T[58]);
  1651 + b = II(b, c, d, a, M_offset_13, 21, T[59]);
  1652 + a = II(a, b, c, d, M_offset_4, 6, T[60]);
  1653 + d = II(d, a, b, c, M_offset_11, 10, T[61]);
  1654 + c = II(c, d, a, b, M_offset_2, 15, T[62]);
  1655 + b = II(b, c, d, a, M_offset_9, 21, T[63]);
  1656 +
  1657 + // Intermediate hash value
  1658 + H[0] = (H[0] + a) | 0;
  1659 + H[1] = (H[1] + b) | 0;
  1660 + H[2] = (H[2] + c) | 0;
  1661 + H[3] = (H[3] + d) | 0;
  1662 + },
  1663 +
  1664 + _doFinalize: function () {
  1665 + // Shortcuts
  1666 + var data = this._data;
  1667 + var dataWords = data.words;
  1668 +
  1669 + var nBitsTotal = this._nDataBytes * 8;
  1670 + var nBitsLeft = data.sigBytes * 8;
  1671 +
  1672 + // Add padding
  1673 + dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
  1674 +
  1675 + var nBitsTotalH = Math.floor(nBitsTotal / 0x100000000);
  1676 + var nBitsTotalL = nBitsTotal;
  1677 + dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = (
  1678 + (((nBitsTotalH << 8) | (nBitsTotalH >>> 24)) & 0x00ff00ff) |
  1679 + (((nBitsTotalH << 24) | (nBitsTotalH >>> 8)) & 0xff00ff00)
  1680 + );
  1681 + dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = (
  1682 + (((nBitsTotalL << 8) | (nBitsTotalL >>> 24)) & 0x00ff00ff) |
  1683 + (((nBitsTotalL << 24) | (nBitsTotalL >>> 8)) & 0xff00ff00)
  1684 + );
  1685 +
  1686 + data.sigBytes = (dataWords.length + 1) * 4;
  1687 +
  1688 + // Hash final blocks
  1689 + this._process();
  1690 +
  1691 + // Shortcuts
  1692 + var hash = this._hash;
  1693 + var H = hash.words;
  1694 +
  1695 + // Swap endian
  1696 + for (var i = 0; i < 4; i++) {
  1697 + // Shortcut
  1698 + var H_i = H[i];
  1699 +
  1700 + H[i] = (((H_i << 8) | (H_i >>> 24)) & 0x00ff00ff) |
  1701 + (((H_i << 24) | (H_i >>> 8)) & 0xff00ff00);
  1702 + }
  1703 +
  1704 + // Return final computed hash
  1705 + return hash;
  1706 + },
  1707 +
  1708 + clone: function () {
  1709 + var clone = Hasher.clone.call(this);
  1710 + clone._hash = this._hash.clone();
  1711 +
  1712 + return clone;
  1713 + }
  1714 + });
  1715 +
  1716 + function FF(a, b, c, d, x, s, t) {
  1717 + var n = a + ((b & c) | (~b & d)) + x + t;
  1718 + return ((n << s) | (n >>> (32 - s))) + b;
  1719 + }
  1720 +
  1721 + function GG(a, b, c, d, x, s, t) {
  1722 + var n = a + ((b & d) | (c & ~d)) + x + t;
  1723 + return ((n << s) | (n >>> (32 - s))) + b;
  1724 + }
  1725 +
  1726 + function HH(a, b, c, d, x, s, t) {
  1727 + var n = a + (b ^ c ^ d) + x + t;
  1728 + return ((n << s) | (n >>> (32 - s))) + b;
  1729 + }
  1730 +
  1731 + function II(a, b, c, d, x, s, t) {
  1732 + var n = a + (c ^ (b | ~d)) + x + t;
  1733 + return ((n << s) | (n >>> (32 - s))) + b;
  1734 + }
  1735 +
  1736 + /**
  1737 + * Shortcut function to the hasher's object interface.
  1738 + *
  1739 + * @param {WordArray|string} message The message to hash.
  1740 + *
  1741 + * @return {WordArray} The hash.
  1742 + *
  1743 + * @static
  1744 + *
  1745 + * @example
  1746 + *
  1747 + * var hash = CryptoJS.MD5('message');
  1748 + * var hash = CryptoJS.MD5(wordArray);
  1749 + */
  1750 + C.MD5 = Hasher._createHelper(MD5);
  1751 +
  1752 + /**
  1753 + * Shortcut function to the HMAC's object interface.
  1754 + *
  1755 + * @param {WordArray|string} message The message to hash.
  1756 + * @param {WordArray|string} key The secret key.
  1757 + *
  1758 + * @return {WordArray} The HMAC.
  1759 + *
  1760 + * @static
  1761 + *
  1762 + * @example
  1763 + *
  1764 + * var hmac = CryptoJS.HmacMD5(message, key);
  1765 + */
  1766 + C.HmacMD5 = Hasher._createHmacHelper(MD5);
  1767 + }(Math));
  1768 +
  1769 +
  1770 + (function () {
  1771 + // Shortcuts
  1772 + var C = CryptoJS;
  1773 + var C_lib = C.lib;
  1774 + var WordArray = C_lib.WordArray;
  1775 + var Hasher = C_lib.Hasher;
  1776 + var C_algo = C.algo;
  1777 +
  1778 + // Reusable object
  1779 + var W = [];
  1780 +
  1781 + /**
  1782 + * SHA-1 hash algorithm.
  1783 + */
  1784 + var SHA1 = C_algo.SHA1 = Hasher.extend({
  1785 + _doReset: function () {
  1786 + this._hash = new WordArray.init([
  1787 + 0x67452301, 0xefcdab89,
  1788 + 0x98badcfe, 0x10325476,
  1789 + 0xc3d2e1f0
  1790 + ]);
  1791 + },
  1792 +
  1793 + _doProcessBlock: function (M, offset) {
  1794 + // Shortcut
  1795 + var H = this._hash.words;
  1796 +
  1797 + // Working variables
  1798 + var a = H[0];
  1799 + var b = H[1];
  1800 + var c = H[2];
  1801 + var d = H[3];
  1802 + var e = H[4];
  1803 +
  1804 + // Computation
  1805 + for (var i = 0; i < 80; i++) {
  1806 + if (i < 16) {
  1807 + W[i] = M[offset + i] | 0;
  1808 + } else {
  1809 + var n = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16];
  1810 + W[i] = (n << 1) | (n >>> 31);
  1811 + }
  1812 +
  1813 + var t = ((a << 5) | (a >>> 27)) + e + W[i];
  1814 + if (i < 20) {
  1815 + t += ((b & c) | (~b & d)) + 0x5a827999;
  1816 + } else if (i < 40) {
  1817 + t += (b ^ c ^ d) + 0x6ed9eba1;
  1818 + } else if (i < 60) {
  1819 + t += ((b & c) | (b & d) | (c & d)) - 0x70e44324;
  1820 + } else /* if (i < 80) */ {
  1821 + t += (b ^ c ^ d) - 0x359d3e2a;
  1822 + }
  1823 +
  1824 + e = d;
  1825 + d = c;
  1826 + c = (b << 30) | (b >>> 2);
  1827 + b = a;
  1828 + a = t;
  1829 + }
  1830 +
  1831 + // Intermediate hash value
  1832 + H[0] = (H[0] + a) | 0;
  1833 + H[1] = (H[1] + b) | 0;
  1834 + H[2] = (H[2] + c) | 0;
  1835 + H[3] = (H[3] + d) | 0;
  1836 + H[4] = (H[4] + e) | 0;
  1837 + },
  1838 +
  1839 + _doFinalize: function () {
  1840 + // Shortcuts
  1841 + var data = this._data;
  1842 + var dataWords = data.words;
  1843 +
  1844 + var nBitsTotal = this._nDataBytes * 8;
  1845 + var nBitsLeft = data.sigBytes * 8;
  1846 +
  1847 + // Add padding
  1848 + dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
  1849 + dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000);
  1850 + dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal;
  1851 + data.sigBytes = dataWords.length * 4;
  1852 +
  1853 + // Hash final blocks
  1854 + this._process();
  1855 +
  1856 + // Return final computed hash
  1857 + return this._hash;
  1858 + },
  1859 +
  1860 + clone: function () {
  1861 + var clone = Hasher.clone.call(this);
  1862 + clone._hash = this._hash.clone();
  1863 +
  1864 + return clone;
  1865 + }
  1866 + });
  1867 +
  1868 + /**
  1869 + * Shortcut function to the hasher's object interface.
  1870 + *
  1871 + * @param {WordArray|string} message The message to hash.
  1872 + *
  1873 + * @return {WordArray} The hash.
  1874 + *
  1875 + * @static
  1876 + *
  1877 + * @example
  1878 + *
  1879 + * var hash = CryptoJS.SHA1('message');
  1880 + * var hash = CryptoJS.SHA1(wordArray);
  1881 + */
  1882 + C.SHA1 = Hasher._createHelper(SHA1);
  1883 +
  1884 + /**
  1885 + * Shortcut function to the HMAC's object interface.
  1886 + *
  1887 + * @param {WordArray|string} message The message to hash.
  1888 + * @param {WordArray|string} key The secret key.
  1889 + *
  1890 + * @return {WordArray} The HMAC.
  1891 + *
  1892 + * @static
  1893 + *
  1894 + * @example
  1895 + *
  1896 + * var hmac = CryptoJS.HmacSHA1(message, key);
  1897 + */
  1898 + C.HmacSHA1 = Hasher._createHmacHelper(SHA1);
  1899 + }());
  1900 +
  1901 +
  1902 + (function (Math) {
  1903 + // Shortcuts
  1904 + var C = CryptoJS;
  1905 + var C_lib = C.lib;
  1906 + var WordArray = C_lib.WordArray;
  1907 + var Hasher = C_lib.Hasher;
  1908 + var C_algo = C.algo;
  1909 +
  1910 + // Initialization and round constants tables
  1911 + var H = [];
  1912 + var K = [];
  1913 +
  1914 + // Compute constants
  1915 + (function () {
  1916 + function isPrime(n) {
  1917 + var sqrtN = Math.sqrt(n);
  1918 + for (var factor = 2; factor <= sqrtN; factor++) {
  1919 + if (!(n % factor)) {
  1920 + return false;
  1921 + }
  1922 + }
  1923 +
  1924 + return true;
  1925 + }
  1926 +
  1927 + function getFractionalBits(n) {
  1928 + return ((n - (n | 0)) * 0x100000000) | 0;
  1929 + }
  1930 +
  1931 + var n = 2;
  1932 + var nPrime = 0;
  1933 + while (nPrime < 64) {
  1934 + if (isPrime(n)) {
  1935 + if (nPrime < 8) {
  1936 + H[nPrime] = getFractionalBits(Math.pow(n, 1 / 2));
  1937 + }
  1938 + K[nPrime] = getFractionalBits(Math.pow(n, 1 / 3));
  1939 +
  1940 + nPrime++;
  1941 + }
  1942 +
  1943 + n++;
  1944 + }
  1945 + }());
  1946 +
  1947 + // Reusable object
  1948 + var W = [];
  1949 +
  1950 + /**
  1951 + * SHA-256 hash algorithm.
  1952 + */
  1953 + var SHA256 = C_algo.SHA256 = Hasher.extend({
  1954 + _doReset: function () {
  1955 + this._hash = new WordArray.init(H.slice(0));
  1956 + },
  1957 +
  1958 + _doProcessBlock: function (M, offset) {
  1959 + // Shortcut
  1960 + var H = this._hash.words;
  1961 +
  1962 + // Working variables
  1963 + var a = H[0];
  1964 + var b = H[1];
  1965 + var c = H[2];
  1966 + var d = H[3];
  1967 + var e = H[4];
  1968 + var f = H[5];
  1969 + var g = H[6];
  1970 + var h = H[7];
  1971 +
  1972 + // Computation
  1973 + for (var i = 0; i < 64; i++) {
  1974 + if (i < 16) {
  1975 + W[i] = M[offset + i] | 0;
  1976 + } else {
  1977 + var gamma0x = W[i - 15];
  1978 + var gamma0 = ((gamma0x << 25) | (gamma0x >>> 7)) ^
  1979 + ((gamma0x << 14) | (gamma0x >>> 18)) ^
  1980 + (gamma0x >>> 3);
  1981 +
  1982 + var gamma1x = W[i - 2];
  1983 + var gamma1 = ((gamma1x << 15) | (gamma1x >>> 17)) ^
  1984 + ((gamma1x << 13) | (gamma1x >>> 19)) ^
  1985 + (gamma1x >>> 10);
  1986 +
  1987 + W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16];
  1988 + }
  1989 +
  1990 + var ch = (e & f) ^ (~e & g);
  1991 + var maj = (a & b) ^ (a & c) ^ (b & c);
  1992 +
  1993 + var sigma0 = ((a << 30) | (a >>> 2)) ^ ((a << 19) | (a >>> 13)) ^ ((a << 10) | (a >>> 22));
  1994 + var sigma1 = ((e << 26) | (e >>> 6)) ^ ((e << 21) | (e >>> 11)) ^ ((e << 7) | (e >>> 25));
  1995 +
  1996 + var t1 = h + sigma1 + ch + K[i] + W[i];
  1997 + var t2 = sigma0 + maj;
  1998 +
  1999 + h = g;
  2000 + g = f;
  2001 + f = e;
  2002 + e = (d + t1) | 0;
  2003 + d = c;
  2004 + c = b;
  2005 + b = a;
  2006 + a = (t1 + t2) | 0;
  2007 + }
  2008 +
  2009 + // Intermediate hash value
  2010 + H[0] = (H[0] + a) | 0;
  2011 + H[1] = (H[1] + b) | 0;
  2012 + H[2] = (H[2] + c) | 0;
  2013 + H[3] = (H[3] + d) | 0;
  2014 + H[4] = (H[4] + e) | 0;
  2015 + H[5] = (H[5] + f) | 0;
  2016 + H[6] = (H[6] + g) | 0;
  2017 + H[7] = (H[7] + h) | 0;
  2018 + },
  2019 +
  2020 + _doFinalize: function () {
  2021 + // Shortcuts
  2022 + var data = this._data;
  2023 + var dataWords = data.words;
  2024 +
  2025 + var nBitsTotal = this._nDataBytes * 8;
  2026 + var nBitsLeft = data.sigBytes * 8;
  2027 +
  2028 + // Add padding
  2029 + dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
  2030 + dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000);
  2031 + dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal;
  2032 + data.sigBytes = dataWords.length * 4;
  2033 +
  2034 + // Hash final blocks
  2035 + this._process();
  2036 +
  2037 + // Return final computed hash
  2038 + return this._hash;
  2039 + },
  2040 +
  2041 + clone: function () {
  2042 + var clone = Hasher.clone.call(this);
  2043 + clone._hash = this._hash.clone();
  2044 +
  2045 + return clone;
  2046 + }
  2047 + });
  2048 +
  2049 + /**
  2050 + * Shortcut function to the hasher's object interface.
  2051 + *
  2052 + * @param {WordArray|string} message The message to hash.
  2053 + *
  2054 + * @return {WordArray} The hash.
  2055 + *
  2056 + * @static
  2057 + *
  2058 + * @example
  2059 + *
  2060 + * var hash = CryptoJS.SHA256('message');
  2061 + * var hash = CryptoJS.SHA256(wordArray);
  2062 + */
  2063 + C.SHA256 = Hasher._createHelper(SHA256);
  2064 +
  2065 + /**
  2066 + * Shortcut function to the HMAC's object interface.
  2067 + *
  2068 + * @param {WordArray|string} message The message to hash.
  2069 + * @param {WordArray|string} key The secret key.
  2070 + *
  2071 + * @return {WordArray} The HMAC.
  2072 + *
  2073 + * @static
  2074 + *
  2075 + * @example
  2076 + *
  2077 + * var hmac = CryptoJS.HmacSHA256(message, key);
  2078 + */
  2079 + C.HmacSHA256 = Hasher._createHmacHelper(SHA256);
  2080 + }(Math));
  2081 +
  2082 +
  2083 + (function () {
  2084 + // Shortcuts
  2085 + var C = CryptoJS;
  2086 + var C_lib = C.lib;
  2087 + var WordArray = C_lib.WordArray;
  2088 + var C_algo = C.algo;
  2089 + var SHA256 = C_algo.SHA256;
  2090 +
  2091 + /**
  2092 + * SHA-224 hash algorithm.
  2093 + */
  2094 + var SHA224 = C_algo.SHA224 = SHA256.extend({
  2095 + _doReset: function () {
  2096 + this._hash = new WordArray.init([
  2097 + 0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939,
  2098 + 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4
  2099 + ]);
  2100 + },
  2101 +
  2102 + _doFinalize: function () {
  2103 + var hash = SHA256._doFinalize.call(this);
  2104 +
  2105 + hash.sigBytes -= 4;
  2106 +
  2107 + return hash;
  2108 + }
  2109 + });
  2110 +
  2111 + /**
  2112 + * Shortcut function to the hasher's object interface.
  2113 + *
  2114 + * @param {WordArray|string} message The message to hash.
  2115 + *
  2116 + * @return {WordArray} The hash.
  2117 + *
  2118 + * @static
  2119 + *
  2120 + * @example
  2121 + *
  2122 + * var hash = CryptoJS.SHA224('message');
  2123 + * var hash = CryptoJS.SHA224(wordArray);
  2124 + */
  2125 + C.SHA224 = SHA256._createHelper(SHA224);
  2126 +
  2127 + /**
  2128 + * Shortcut function to the HMAC's object interface.
  2129 + *
  2130 + * @param {WordArray|string} message The message to hash.
  2131 + * @param {WordArray|string} key The secret key.
  2132 + *
  2133 + * @return {WordArray} The HMAC.
  2134 + *
  2135 + * @static
  2136 + *
  2137 + * @example
  2138 + *
  2139 + * var hmac = CryptoJS.HmacSHA224(message, key);
  2140 + */
  2141 + C.HmacSHA224 = SHA256._createHmacHelper(SHA224);
  2142 + }());
  2143 +
  2144 +
  2145 + (function () {
  2146 + // Shortcuts
  2147 + var C = CryptoJS;
  2148 + var C_lib = C.lib;
  2149 + var Hasher = C_lib.Hasher;
  2150 + var C_x64 = C.x64;
  2151 + var X64Word = C_x64.Word;
  2152 + var X64WordArray = C_x64.WordArray;
  2153 + var C_algo = C.algo;
  2154 +
  2155 + function X64Word_create() {
  2156 + return X64Word.create.apply(X64Word, arguments);
  2157 + }
  2158 +
  2159 + // Constants
  2160 + var K = [
  2161 + X64Word_create(0x428a2f98, 0xd728ae22), X64Word_create(0x71374491, 0x23ef65cd),
  2162 + X64Word_create(0xb5c0fbcf, 0xec4d3b2f), X64Word_create(0xe9b5dba5, 0x8189dbbc),
  2163 + X64Word_create(0x3956c25b, 0xf348b538), X64Word_create(0x59f111f1, 0xb605d019),
  2164 + X64Word_create(0x923f82a4, 0xaf194f9b), X64Word_create(0xab1c5ed5, 0xda6d8118),
  2165 + X64Word_create(0xd807aa98, 0xa3030242), X64Word_create(0x12835b01, 0x45706fbe),
  2166 + X64Word_create(0x243185be, 0x4ee4b28c), X64Word_create(0x550c7dc3, 0xd5ffb4e2),
  2167 + X64Word_create(0x72be5d74, 0xf27b896f), X64Word_create(0x80deb1fe, 0x3b1696b1),
  2168 + X64Word_create(0x9bdc06a7, 0x25c71235), X64Word_create(0xc19bf174, 0xcf692694),
  2169 + X64Word_create(0xe49b69c1, 0x9ef14ad2), X64Word_create(0xefbe4786, 0x384f25e3),
  2170 + X64Word_create(0x0fc19dc6, 0x8b8cd5b5), X64Word_create(0x240ca1cc, 0x77ac9c65),
  2171 + X64Word_create(0x2de92c6f, 0x592b0275), X64Word_create(0x4a7484aa, 0x6ea6e483),
  2172 + X64Word_create(0x5cb0a9dc, 0xbd41fbd4), X64Word_create(0x76f988da, 0x831153b5),
  2173 + X64Word_create(0x983e5152, 0xee66dfab), X64Word_create(0xa831c66d, 0x2db43210),
  2174 + X64Word_create(0xb00327c8, 0x98fb213f), X64Word_create(0xbf597fc7, 0xbeef0ee4),
  2175 + X64Word_create(0xc6e00bf3, 0x3da88fc2), X64Word_create(0xd5a79147, 0x930aa725),
  2176 + X64Word_create(0x06ca6351, 0xe003826f), X64Word_create(0x14292967, 0x0a0e6e70),
  2177 + X64Word_create(0x27b70a85, 0x46d22ffc), X64Word_create(0x2e1b2138, 0x5c26c926),
  2178 + X64Word_create(0x4d2c6dfc, 0x5ac42aed), X64Word_create(0x53380d13, 0x9d95b3df),
  2179 + X64Word_create(0x650a7354, 0x8baf63de), X64Word_create(0x766a0abb, 0x3c77b2a8),
  2180 + X64Word_create(0x81c2c92e, 0x47edaee6), X64Word_create(0x92722c85, 0x1482353b),
  2181 + X64Word_create(0xa2bfe8a1, 0x4cf10364), X64Word_create(0xa81a664b, 0xbc423001),
  2182 + X64Word_create(0xc24b8b70, 0xd0f89791), X64Word_create(0xc76c51a3, 0x0654be30),
  2183 + X64Word_create(0xd192e819, 0xd6ef5218), X64Word_create(0xd6990624, 0x5565a910),
  2184 + X64Word_create(0xf40e3585, 0x5771202a), X64Word_create(0x106aa070, 0x32bbd1b8),
  2185 + X64Word_create(0x19a4c116, 0xb8d2d0c8), X64Word_create(0x1e376c08, 0x5141ab53),
  2186 + X64Word_create(0x2748774c, 0xdf8eeb99), X64Word_create(0x34b0bcb5, 0xe19b48a8),
  2187 + X64Word_create(0x391c0cb3, 0xc5c95a63), X64Word_create(0x4ed8aa4a, 0xe3418acb),
  2188 + X64Word_create(0x5b9cca4f, 0x7763e373), X64Word_create(0x682e6ff3, 0xd6b2b8a3),
  2189 + X64Word_create(0x748f82ee, 0x5defb2fc), X64Word_create(0x78a5636f, 0x43172f60),
  2190 + X64Word_create(0x84c87814, 0xa1f0ab72), X64Word_create(0x8cc70208, 0x1a6439ec),
  2191 + X64Word_create(0x90befffa, 0x23631e28), X64Word_create(0xa4506ceb, 0xde82bde9),
  2192 + X64Word_create(0xbef9a3f7, 0xb2c67915), X64Word_create(0xc67178f2, 0xe372532b),
  2193 + X64Word_create(0xca273ece, 0xea26619c), X64Word_create(0xd186b8c7, 0x21c0c207),
  2194 + X64Word_create(0xeada7dd6, 0xcde0eb1e), X64Word_create(0xf57d4f7f, 0xee6ed178),
  2195 + X64Word_create(0x06f067aa, 0x72176fba), X64Word_create(0x0a637dc5, 0xa2c898a6),
  2196 + X64Word_create(0x113f9804, 0xbef90dae), X64Word_create(0x1b710b35, 0x131c471b),
  2197 + X64Word_create(0x28db77f5, 0x23047d84), X64Word_create(0x32caab7b, 0x40c72493),
  2198 + X64Word_create(0x3c9ebe0a, 0x15c9bebc), X64Word_create(0x431d67c4, 0x9c100d4c),
  2199 + X64Word_create(0x4cc5d4be, 0xcb3e42b6), X64Word_create(0x597f299c, 0xfc657e2a),
  2200 + X64Word_create(0x5fcb6fab, 0x3ad6faec), X64Word_create(0x6c44198c, 0x4a475817)
  2201 + ];
  2202 +
  2203 + // Reusable objects
  2204 + var W = [];
  2205 + (function () {
  2206 + for (var i = 0; i < 80; i++) {
  2207 + W[i] = X64Word_create();
  2208 + }
  2209 + }());
  2210 +
  2211 + /**
  2212 + * SHA-512 hash algorithm.
  2213 + */
  2214 + var SHA512 = C_algo.SHA512 = Hasher.extend({
  2215 + _doReset: function () {
  2216 + this._hash = new X64WordArray.init([
  2217 + new X64Word.init(0x6a09e667, 0xf3bcc908), new X64Word.init(0xbb67ae85, 0x84caa73b),
  2218 + new X64Word.init(0x3c6ef372, 0xfe94f82b), new X64Word.init(0xa54ff53a, 0x5f1d36f1),
  2219 + new X64Word.init(0x510e527f, 0xade682d1), new X64Word.init(0x9b05688c, 0x2b3e6c1f),
  2220 + new X64Word.init(0x1f83d9ab, 0xfb41bd6b), new X64Word.init(0x5be0cd19, 0x137e2179)
  2221 + ]);
  2222 + },
  2223 +
  2224 + _doProcessBlock: function (M, offset) {
  2225 + // Shortcuts
  2226 + var H = this._hash.words;
  2227 +
  2228 + var H0 = H[0];
  2229 + var H1 = H[1];
  2230 + var H2 = H[2];
  2231 + var H3 = H[3];
  2232 + var H4 = H[4];
  2233 + var H5 = H[5];
  2234 + var H6 = H[6];
  2235 + var H7 = H[7];
  2236 +
  2237 + var H0h = H0.high;
  2238 + var H0l = H0.low;
  2239 + var H1h = H1.high;
  2240 + var H1l = H1.low;
  2241 + var H2h = H2.high;
  2242 + var H2l = H2.low;
  2243 + var H3h = H3.high;
  2244 + var H3l = H3.low;
  2245 + var H4h = H4.high;
  2246 + var H4l = H4.low;
  2247 + var H5h = H5.high;
  2248 + var H5l = H5.low;
  2249 + var H6h = H6.high;
  2250 + var H6l = H6.low;
  2251 + var H7h = H7.high;
  2252 + var H7l = H7.low;
  2253 +
  2254 + // Working variables
  2255 + var ah = H0h;
  2256 + var al = H0l;
  2257 + var bh = H1h;
  2258 + var bl = H1l;
  2259 + var ch = H2h;
  2260 + var cl = H2l;
  2261 + var dh = H3h;
  2262 + var dl = H3l;
  2263 + var eh = H4h;
  2264 + var el = H4l;
  2265 + var fh = H5h;
  2266 + var fl = H5l;
  2267 + var gh = H6h;
  2268 + var gl = H6l;
  2269 + var hh = H7h;
  2270 + var hl = H7l;
  2271 +
  2272 + // Rounds
  2273 + for (var i = 0; i < 80; i++) {
  2274 + var Wil;
  2275 + var Wih;
  2276 +
  2277 + // Shortcut
  2278 + var Wi = W[i];
  2279 +
  2280 + // Extend message
  2281 + if (i < 16) {
  2282 + Wih = Wi.high = M[offset + i * 2] | 0;
  2283 + Wil = Wi.low = M[offset + i * 2 + 1] | 0;
  2284 + } else {
  2285 + // Gamma0
  2286 + var gamma0x = W[i - 15];
  2287 + var gamma0xh = gamma0x.high;
  2288 + var gamma0xl = gamma0x.low;
  2289 + var gamma0h = ((gamma0xh >>> 1) | (gamma0xl << 31)) ^ ((gamma0xh >>> 8) | (gamma0xl << 24)) ^ (gamma0xh >>> 7);
  2290 + var gamma0l = ((gamma0xl >>> 1) | (gamma0xh << 31)) ^ ((gamma0xl >>> 8) | (gamma0xh << 24)) ^ ((gamma0xl >>> 7) | (gamma0xh << 25));
  2291 +
  2292 + // Gamma1
  2293 + var gamma1x = W[i - 2];
  2294 + var gamma1xh = gamma1x.high;
  2295 + var gamma1xl = gamma1x.low;
  2296 + var gamma1h = ((gamma1xh >>> 19) | (gamma1xl << 13)) ^ ((gamma1xh << 3) | (gamma1xl >>> 29)) ^ (gamma1xh >>> 6);
  2297 + var gamma1l = ((gamma1xl >>> 19) | (gamma1xh << 13)) ^ ((gamma1xl << 3) | (gamma1xh >>> 29)) ^ ((gamma1xl >>> 6) | (gamma1xh << 26));
  2298 +
  2299 + // W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16]
  2300 + var Wi7 = W[i - 7];
  2301 + var Wi7h = Wi7.high;
  2302 + var Wi7l = Wi7.low;
  2303 +
  2304 + var Wi16 = W[i - 16];
  2305 + var Wi16h = Wi16.high;
  2306 + var Wi16l = Wi16.low;
  2307 +
  2308 + Wil = gamma0l + Wi7l;
  2309 + Wih = gamma0h + Wi7h + ((Wil >>> 0) < (gamma0l >>> 0) ? 1 : 0);
  2310 + Wil = Wil + gamma1l;
  2311 + Wih = Wih + gamma1h + ((Wil >>> 0) < (gamma1l >>> 0) ? 1 : 0);
  2312 + Wil = Wil + Wi16l;
  2313 + Wih = Wih + Wi16h + ((Wil >>> 0) < (Wi16l >>> 0) ? 1 : 0);
  2314 +
  2315 + Wi.high = Wih;
  2316 + Wi.low = Wil;
  2317 + }
  2318 +
  2319 + var chh = (eh & fh) ^ (~eh & gh);
  2320 + var chl = (el & fl) ^ (~el & gl);
  2321 + var majh = (ah & bh) ^ (ah & ch) ^ (bh & ch);
  2322 + var majl = (al & bl) ^ (al & cl) ^ (bl & cl);
  2323 +
  2324 + var sigma0h = ((ah >>> 28) | (al << 4)) ^ ((ah << 30) | (al >>> 2)) ^ ((ah << 25) | (al >>> 7));
  2325 + var sigma0l = ((al >>> 28) | (ah << 4)) ^ ((al << 30) | (ah >>> 2)) ^ ((al << 25) | (ah >>> 7));
  2326 + var sigma1h = ((eh >>> 14) | (el << 18)) ^ ((eh >>> 18) | (el << 14)) ^ ((eh << 23) | (el >>> 9));
  2327 + var sigma1l = ((el >>> 14) | (eh << 18)) ^ ((el >>> 18) | (eh << 14)) ^ ((el << 23) | (eh >>> 9));
  2328 +
  2329 + // t1 = h + sigma1 + ch + K[i] + W[i]
  2330 + var Ki = K[i];
  2331 + var Kih = Ki.high;
  2332 + var Kil = Ki.low;
  2333 +
  2334 + var t1l = hl + sigma1l;
  2335 + var t1h = hh + sigma1h + ((t1l >>> 0) < (hl >>> 0) ? 1 : 0);
  2336 + var t1l = t1l + chl;
  2337 + var t1h = t1h + chh + ((t1l >>> 0) < (chl >>> 0) ? 1 : 0);
  2338 + var t1l = t1l + Kil;
  2339 + var t1h = t1h + Kih + ((t1l >>> 0) < (Kil >>> 0) ? 1 : 0);
  2340 + var t1l = t1l + Wil;
  2341 + var t1h = t1h + Wih + ((t1l >>> 0) < (Wil >>> 0) ? 1 : 0);
  2342 +
  2343 + // t2 = sigma0 + maj
  2344 + var t2l = sigma0l + majl;
  2345 + var t2h = sigma0h + majh + ((t2l >>> 0) < (sigma0l >>> 0) ? 1 : 0);
  2346 +
  2347 + // Update working variables
  2348 + hh = gh;
  2349 + hl = gl;
  2350 + gh = fh;
  2351 + gl = fl;
  2352 + fh = eh;
  2353 + fl = el;
  2354 + el = (dl + t1l) | 0;
  2355 + eh = (dh + t1h + ((el >>> 0) < (dl >>> 0) ? 1 : 0)) | 0;
  2356 + dh = ch;
  2357 + dl = cl;
  2358 + ch = bh;
  2359 + cl = bl;
  2360 + bh = ah;
  2361 + bl = al;
  2362 + al = (t1l + t2l) | 0;
  2363 + ah = (t1h + t2h + ((al >>> 0) < (t1l >>> 0) ? 1 : 0)) | 0;
  2364 + }
  2365 +
  2366 + // Intermediate hash value
  2367 + H0l = H0.low = (H0l + al);
  2368 + H0.high = (H0h + ah + ((H0l >>> 0) < (al >>> 0) ? 1 : 0));
  2369 + H1l = H1.low = (H1l + bl);
  2370 + H1.high = (H1h + bh + ((H1l >>> 0) < (bl >>> 0) ? 1 : 0));
  2371 + H2l = H2.low = (H2l + cl);
  2372 + H2.high = (H2h + ch + ((H2l >>> 0) < (cl >>> 0) ? 1 : 0));
  2373 + H3l = H3.low = (H3l + dl);
  2374 + H3.high = (H3h + dh + ((H3l >>> 0) < (dl >>> 0) ? 1 : 0));
  2375 + H4l = H4.low = (H4l + el);
  2376 + H4.high = (H4h + eh + ((H4l >>> 0) < (el >>> 0) ? 1 : 0));
  2377 + H5l = H5.low = (H5l + fl);
  2378 + H5.high = (H5h + fh + ((H5l >>> 0) < (fl >>> 0) ? 1 : 0));
  2379 + H6l = H6.low = (H6l + gl);
  2380 + H6.high = (H6h + gh + ((H6l >>> 0) < (gl >>> 0) ? 1 : 0));
  2381 + H7l = H7.low = (H7l + hl);
  2382 + H7.high = (H7h + hh + ((H7l >>> 0) < (hl >>> 0) ? 1 : 0));
  2383 + },
  2384 +
  2385 + _doFinalize: function () {
  2386 + // Shortcuts
  2387 + var data = this._data;
  2388 + var dataWords = data.words;
  2389 +
  2390 + var nBitsTotal = this._nDataBytes * 8;
  2391 + var nBitsLeft = data.sigBytes * 8;
  2392 +
  2393 + // Add padding
  2394 + dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
  2395 + dataWords[(((nBitsLeft + 128) >>> 10) << 5) + 30] = Math.floor(nBitsTotal / 0x100000000);
  2396 + dataWords[(((nBitsLeft + 128) >>> 10) << 5) + 31] = nBitsTotal;
  2397 + data.sigBytes = dataWords.length * 4;
  2398 +
  2399 + // Hash final blocks
  2400 + this._process();
  2401 +
  2402 + // Convert hash to 32-bit word array before returning
  2403 + var hash = this._hash.toX32();
  2404 +
  2405 + // Return final computed hash
  2406 + return hash;
  2407 + },
  2408 +
  2409 + clone: function () {
  2410 + var clone = Hasher.clone.call(this);
  2411 + clone._hash = this._hash.clone();
  2412 +
  2413 + return clone;
  2414 + },
  2415 +
  2416 + blockSize: 1024/32
  2417 + });
  2418 +
  2419 + /**
  2420 + * Shortcut function to the hasher's object interface.
  2421 + *
  2422 + * @param {WordArray|string} message The message to hash.
  2423 + *
  2424 + * @return {WordArray} The hash.
  2425 + *
  2426 + * @static
  2427 + *
  2428 + * @example
  2429 + *
  2430 + * var hash = CryptoJS.SHA512('message');
  2431 + * var hash = CryptoJS.SHA512(wordArray);
  2432 + */
  2433 + C.SHA512 = Hasher._createHelper(SHA512);
  2434 +
  2435 + /**
  2436 + * Shortcut function to the HMAC's object interface.
  2437 + *
  2438 + * @param {WordArray|string} message The message to hash.
  2439 + * @param {WordArray|string} key The secret key.
  2440 + *
  2441 + * @return {WordArray} The HMAC.
  2442 + *
  2443 + * @static
  2444 + *
  2445 + * @example
  2446 + *
  2447 + * var hmac = CryptoJS.HmacSHA512(message, key);
  2448 + */
  2449 + C.HmacSHA512 = Hasher._createHmacHelper(SHA512);
  2450 + }());
  2451 +
  2452 +
  2453 + (function () {
  2454 + // Shortcuts
  2455 + var C = CryptoJS;
  2456 + var C_x64 = C.x64;
  2457 + var X64Word = C_x64.Word;
  2458 + var X64WordArray = C_x64.WordArray;
  2459 + var C_algo = C.algo;
  2460 + var SHA512 = C_algo.SHA512;
  2461 +
  2462 + /**
  2463 + * SHA-384 hash algorithm.
  2464 + */
  2465 + var SHA384 = C_algo.SHA384 = SHA512.extend({
  2466 + _doReset: function () {
  2467 + this._hash = new X64WordArray.init([
  2468 + new X64Word.init(0xcbbb9d5d, 0xc1059ed8), new X64Word.init(0x629a292a, 0x367cd507),
  2469 + new X64Word.init(0x9159015a, 0x3070dd17), new X64Word.init(0x152fecd8, 0xf70e5939),
  2470 + new X64Word.init(0x67332667, 0xffc00b31), new X64Word.init(0x8eb44a87, 0x68581511),
  2471 + new X64Word.init(0xdb0c2e0d, 0x64f98fa7), new X64Word.init(0x47b5481d, 0xbefa4fa4)
  2472 + ]);
  2473 + },
  2474 +
  2475 + _doFinalize: function () {
  2476 + var hash = SHA512._doFinalize.call(this);
  2477 +
  2478 + hash.sigBytes -= 16;
  2479 +
  2480 + return hash;
  2481 + }
  2482 + });
  2483 +
  2484 + /**
  2485 + * Shortcut function to the hasher's object interface.
  2486 + *
  2487 + * @param {WordArray|string} message The message to hash.
  2488 + *
  2489 + * @return {WordArray} The hash.
  2490 + *
  2491 + * @static
  2492 + *
  2493 + * @example
  2494 + *
  2495 + * var hash = CryptoJS.SHA384('message');
  2496 + * var hash = CryptoJS.SHA384(wordArray);
  2497 + */
  2498 + C.SHA384 = SHA512._createHelper(SHA384);
  2499 +
  2500 + /**
  2501 + * Shortcut function to the HMAC's object interface.
  2502 + *
  2503 + * @param {WordArray|string} message The message to hash.
  2504 + * @param {WordArray|string} key The secret key.
  2505 + *
  2506 + * @return {WordArray} The HMAC.
  2507 + *
  2508 + * @static
  2509 + *
  2510 + * @example
  2511 + *
  2512 + * var hmac = CryptoJS.HmacSHA384(message, key);
  2513 + */
  2514 + C.HmacSHA384 = SHA512._createHmacHelper(SHA384);
  2515 + }());
  2516 +
  2517 +
  2518 + (function (Math) {
  2519 + // Shortcuts
  2520 + var C = CryptoJS;
  2521 + var C_lib = C.lib;
  2522 + var WordArray = C_lib.WordArray;
  2523 + var Hasher = C_lib.Hasher;
  2524 + var C_x64 = C.x64;
  2525 + var X64Word = C_x64.Word;
  2526 + var C_algo = C.algo;
  2527 +
  2528 + // Constants tables
  2529 + var RHO_OFFSETS = [];
  2530 + var PI_INDEXES = [];
  2531 + var ROUND_CONSTANTS = [];
  2532 +
  2533 + // Compute Constants
  2534 + (function () {
  2535 + // Compute rho offset constants
  2536 + var x = 1, y = 0;
  2537 + for (var t = 0; t < 24; t++) {
  2538 + RHO_OFFSETS[x + 5 * y] = ((t + 1) * (t + 2) / 2) % 64;
  2539 +
  2540 + var newX = y % 5;
  2541 + var newY = (2 * x + 3 * y) % 5;
  2542 + x = newX;
  2543 + y = newY;
  2544 + }
  2545 +
  2546 + // Compute pi index constants
  2547 + for (var x = 0; x < 5; x++) {
  2548 + for (var y = 0; y < 5; y++) {
  2549 + PI_INDEXES[x + 5 * y] = y + ((2 * x + 3 * y) % 5) * 5;
  2550 + }
  2551 + }
  2552 +
  2553 + // Compute round constants
  2554 + var LFSR = 0x01;
  2555 + for (var i = 0; i < 24; i++) {
  2556 + var roundConstantMsw = 0;
  2557 + var roundConstantLsw = 0;
  2558 +
  2559 + for (var j = 0; j < 7; j++) {
  2560 + if (LFSR & 0x01) {
  2561 + var bitPosition = (1 << j) - 1;
  2562 + if (bitPosition < 32) {
  2563 + roundConstantLsw ^= 1 << bitPosition;
  2564 + } else /* if (bitPosition >= 32) */ {
  2565 + roundConstantMsw ^= 1 << (bitPosition - 32);
  2566 + }
  2567 + }
  2568 +
  2569 + // Compute next LFSR
  2570 + if (LFSR & 0x80) {
  2571 + // Primitive polynomial over GF(2): x^8 + x^6 + x^5 + x^4 + 1
  2572 + LFSR = (LFSR << 1) ^ 0x71;
  2573 + } else {
  2574 + LFSR <<= 1;
  2575 + }
  2576 + }
  2577 +
  2578 + ROUND_CONSTANTS[i] = X64Word.create(roundConstantMsw, roundConstantLsw);
  2579 + }
  2580 + }());
  2581 +
  2582 + // Reusable objects for temporary values
  2583 + var T = [];
  2584 + (function () {
  2585 + for (var i = 0; i < 25; i++) {
  2586 + T[i] = X64Word.create();
  2587 + }
  2588 + }());
  2589 +
  2590 + /**
  2591 + * SHA-3 hash algorithm.
  2592 + */
  2593 + var SHA3 = C_algo.SHA3 = Hasher.extend({
  2594 + /**
  2595 + * Configuration options.
  2596 + *
  2597 + * @property {number} outputLength
  2598 + * The desired number of bits in the output hash.
  2599 + * Only values permitted are: 224, 256, 384, 512.
  2600 + * Default: 512
  2601 + */
  2602 + cfg: Hasher.cfg.extend({
  2603 + outputLength: 512
  2604 + }),
  2605 +
  2606 + _doReset: function () {
  2607 + var state = this._state = []
  2608 + for (var i = 0; i < 25; i++) {
  2609 + state[i] = new X64Word.init();
  2610 + }
  2611 +
  2612 + this.blockSize = (1600 - 2 * this.cfg.outputLength) / 32;
  2613 + },
  2614 +
  2615 + _doProcessBlock: function (M, offset) {
  2616 + // Shortcuts
  2617 + var state = this._state;
  2618 + var nBlockSizeLanes = this.blockSize / 2;
  2619 +
  2620 + // Absorb
  2621 + for (var i = 0; i < nBlockSizeLanes; i++) {
  2622 + // Shortcuts
  2623 + var M2i = M[offset + 2 * i];
  2624 + var M2i1 = M[offset + 2 * i + 1];
  2625 +
  2626 + // Swap endian
  2627 + M2i = (
  2628 + (((M2i << 8) | (M2i >>> 24)) & 0x00ff00ff) |
  2629 + (((M2i << 24) | (M2i >>> 8)) & 0xff00ff00)
  2630 + );
  2631 + M2i1 = (
  2632 + (((M2i1 << 8) | (M2i1 >>> 24)) & 0x00ff00ff) |
  2633 + (((M2i1 << 24) | (M2i1 >>> 8)) & 0xff00ff00)
  2634 + );
  2635 +
  2636 + // Absorb message into state
  2637 + var lane = state[i];
  2638 + lane.high ^= M2i1;
  2639 + lane.low ^= M2i;
  2640 + }
  2641 +
  2642 + // Rounds
  2643 + for (var round = 0; round < 24; round++) {
  2644 + // Theta
  2645 + for (var x = 0; x < 5; x++) {
  2646 + // Mix column lanes
  2647 + var tMsw = 0, tLsw = 0;
  2648 + for (var y = 0; y < 5; y++) {
  2649 + var lane = state[x + 5 * y];
  2650 + tMsw ^= lane.high;
  2651 + tLsw ^= lane.low;
  2652 + }
  2653 +
  2654 + // Temporary values
  2655 + var Tx = T[x];
  2656 + Tx.high = tMsw;
  2657 + Tx.low = tLsw;
  2658 + }
  2659 + for (var x = 0; x < 5; x++) {
  2660 + // Shortcuts
  2661 + var Tx4 = T[(x + 4) % 5];
  2662 + var Tx1 = T[(x + 1) % 5];
  2663 + var Tx1Msw = Tx1.high;
  2664 + var Tx1Lsw = Tx1.low;
  2665 +
  2666 + // Mix surrounding columns
  2667 + var tMsw = Tx4.high ^ ((Tx1Msw << 1) | (Tx1Lsw >>> 31));
  2668 + var tLsw = Tx4.low ^ ((Tx1Lsw << 1) | (Tx1Msw >>> 31));
  2669 + for (var y = 0; y < 5; y++) {
  2670 + var lane = state[x + 5 * y];
  2671 + lane.high ^= tMsw;
  2672 + lane.low ^= tLsw;
  2673 + }
  2674 + }
  2675 +
  2676 + // Rho Pi
  2677 + for (var laneIndex = 1; laneIndex < 25; laneIndex++) {
  2678 + var tMsw;
  2679 + var tLsw;
  2680 +
  2681 + // Shortcuts
  2682 + var lane = state[laneIndex];
  2683 + var laneMsw = lane.high;
  2684 + var laneLsw = lane.low;
  2685 + var rhoOffset = RHO_OFFSETS[laneIndex];
  2686 +
  2687 + // Rotate lanes
  2688 + if (rhoOffset < 32) {
  2689 + tMsw = (laneMsw << rhoOffset) | (laneLsw >>> (32 - rhoOffset));
  2690 + tLsw = (laneLsw << rhoOffset) | (laneMsw >>> (32 - rhoOffset));
  2691 + } else /* if (rhoOffset >= 32) */ {
  2692 + tMsw = (laneLsw << (rhoOffset - 32)) | (laneMsw >>> (64 - rhoOffset));
  2693 + tLsw = (laneMsw << (rhoOffset - 32)) | (laneLsw >>> (64 - rhoOffset));
  2694 + }
  2695 +
  2696 + // Transpose lanes
  2697 + var TPiLane = T[PI_INDEXES[laneIndex]];
  2698 + TPiLane.high = tMsw;
  2699 + TPiLane.low = tLsw;
  2700 + }
  2701 +
  2702 + // Rho pi at x = y = 0
  2703 + var T0 = T[0];
  2704 + var state0 = state[0];
  2705 + T0.high = state0.high;
  2706 + T0.low = state0.low;
  2707 +
  2708 + // Chi
  2709 + for (var x = 0; x < 5; x++) {
  2710 + for (var y = 0; y < 5; y++) {
  2711 + // Shortcuts
  2712 + var laneIndex = x + 5 * y;
  2713 + var lane = state[laneIndex];
  2714 + var TLane = T[laneIndex];
  2715 + var Tx1Lane = T[((x + 1) % 5) + 5 * y];
  2716 + var Tx2Lane = T[((x + 2) % 5) + 5 * y];
  2717 +
  2718 + // Mix rows
  2719 + lane.high = TLane.high ^ (~Tx1Lane.high & Tx2Lane.high);
  2720 + lane.low = TLane.low ^ (~Tx1Lane.low & Tx2Lane.low);
  2721 + }
  2722 + }
  2723 +
  2724 + // Iota
  2725 + var lane = state[0];
  2726 + var roundConstant = ROUND_CONSTANTS[round];
  2727 + lane.high ^= roundConstant.high;
  2728 + lane.low ^= roundConstant.low;
  2729 + }
  2730 + },
  2731 +
  2732 + _doFinalize: function () {
  2733 + // Shortcuts
  2734 + var data = this._data;
  2735 + var dataWords = data.words;
  2736 + var nBitsTotal = this._nDataBytes * 8;
  2737 + var nBitsLeft = data.sigBytes * 8;
  2738 + var blockSizeBits = this.blockSize * 32;
  2739 +
  2740 + // Add padding
  2741 + dataWords[nBitsLeft >>> 5] |= 0x1 << (24 - nBitsLeft % 32);
  2742 + dataWords[((Math.ceil((nBitsLeft + 1) / blockSizeBits) * blockSizeBits) >>> 5) - 1] |= 0x80;
  2743 + data.sigBytes = dataWords.length * 4;
  2744 +
  2745 + // Hash final blocks
  2746 + this._process();
  2747 +
  2748 + // Shortcuts
  2749 + var state = this._state;
  2750 + var outputLengthBytes = this.cfg.outputLength / 8;
  2751 + var outputLengthLanes = outputLengthBytes / 8;
  2752 +
  2753 + // Squeeze
  2754 + var hashWords = [];
  2755 + for (var i = 0; i < outputLengthLanes; i++) {
  2756 + // Shortcuts
  2757 + var lane = state[i];
  2758 + var laneMsw = lane.high;
  2759 + var laneLsw = lane.low;
  2760 +
  2761 + // Swap endian
  2762 + laneMsw = (
  2763 + (((laneMsw << 8) | (laneMsw >>> 24)) & 0x00ff00ff) |
  2764 + (((laneMsw << 24) | (laneMsw >>> 8)) & 0xff00ff00)
  2765 + );
  2766 + laneLsw = (
  2767 + (((laneLsw << 8) | (laneLsw >>> 24)) & 0x00ff00ff) |
  2768 + (((laneLsw << 24) | (laneLsw >>> 8)) & 0xff00ff00)
  2769 + );
  2770 +
  2771 + // Squeeze state to retrieve hash
  2772 + hashWords.push(laneLsw);
  2773 + hashWords.push(laneMsw);
  2774 + }
  2775 +
  2776 + // Return final computed hash
  2777 + return new WordArray.init(hashWords, outputLengthBytes);
  2778 + },
  2779 +
  2780 + clone: function () {
  2781 + var clone = Hasher.clone.call(this);
  2782 +
  2783 + var state = clone._state = this._state.slice(0);
  2784 + for (var i = 0; i < 25; i++) {
  2785 + state[i] = state[i].clone();
  2786 + }
  2787 +
  2788 + return clone;
  2789 + }
  2790 + });
  2791 +
  2792 + /**
  2793 + * Shortcut function to the hasher's object interface.
  2794 + *
  2795 + * @param {WordArray|string} message The message to hash.
  2796 + *
  2797 + * @return {WordArray} The hash.
  2798 + *
  2799 + * @static
  2800 + *
  2801 + * @example
  2802 + *
  2803 + * var hash = CryptoJS.SHA3('message');
  2804 + * var hash = CryptoJS.SHA3(wordArray);
  2805 + */
  2806 + C.SHA3 = Hasher._createHelper(SHA3);
  2807 +
  2808 + /**
  2809 + * Shortcut function to the HMAC's object interface.
  2810 + *
  2811 + * @param {WordArray|string} message The message to hash.
  2812 + * @param {WordArray|string} key The secret key.
  2813 + *
  2814 + * @return {WordArray} The HMAC.
  2815 + *
  2816 + * @static
  2817 + *
  2818 + * @example
  2819 + *
  2820 + * var hmac = CryptoJS.HmacSHA3(message, key);
  2821 + */
  2822 + C.HmacSHA3 = Hasher._createHmacHelper(SHA3);
  2823 + }(Math));
  2824 +
  2825 +
  2826 + /** @preserve
  2827 + (c) 2012 by Cédric Mesnil. All rights reserved.
  2828 +
  2829 + Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
  2830 +
  2831 + - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2832 + - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  2833 +
  2834 + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  2835 + */
  2836 +
  2837 + (function (Math) {
  2838 + // Shortcuts
  2839 + var C = CryptoJS;
  2840 + var C_lib = C.lib;
  2841 + var WordArray = C_lib.WordArray;
  2842 + var Hasher = C_lib.Hasher;
  2843 + var C_algo = C.algo;
  2844 +
  2845 + // Constants table
  2846 + var _zl = WordArray.create([
  2847 + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
  2848 + 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,
  2849 + 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12,
  2850 + 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2,
  2851 + 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13]);
  2852 + var _zr = WordArray.create([
  2853 + 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12,
  2854 + 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2,
  2855 + 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13,
  2856 + 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14,
  2857 + 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11]);
  2858 + var _sl = WordArray.create([
  2859 + 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8,
  2860 + 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12,
  2861 + 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5,
  2862 + 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12,
  2863 + 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6 ]);
  2864 + var _sr = WordArray.create([
  2865 + 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6,
  2866 + 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11,
  2867 + 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5,
  2868 + 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8,
  2869 + 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11 ]);
  2870 +
  2871 + var _hl = WordArray.create([ 0x00000000, 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xA953FD4E]);
  2872 + var _hr = WordArray.create([ 0x50A28BE6, 0x5C4DD124, 0x6D703EF3, 0x7A6D76E9, 0x00000000]);
  2873 +
  2874 + /**
  2875 + * RIPEMD160 hash algorithm.
  2876 + */
  2877 + var RIPEMD160 = C_algo.RIPEMD160 = Hasher.extend({
  2878 + _doReset: function () {
  2879 + this._hash = WordArray.create([0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0]);
  2880 + },
  2881 +
  2882 + _doProcessBlock: function (M, offset) {
  2883 +
  2884 + // Swap endian
  2885 + for (var i = 0; i < 16; i++) {
  2886 + // Shortcuts
  2887 + var offset_i = offset + i;
  2888 + var M_offset_i = M[offset_i];
  2889 +
  2890 + // Swap
  2891 + M[offset_i] = (
  2892 + (((M_offset_i << 8) | (M_offset_i >>> 24)) & 0x00ff00ff) |
  2893 + (((M_offset_i << 24) | (M_offset_i >>> 8)) & 0xff00ff00)
  2894 + );
  2895 + }
  2896 + // Shortcut
  2897 + var H = this._hash.words;
  2898 + var hl = _hl.words;
  2899 + var hr = _hr.words;
  2900 + var zl = _zl.words;
  2901 + var zr = _zr.words;
  2902 + var sl = _sl.words;
  2903 + var sr = _sr.words;
  2904 +
  2905 + // Working variables
  2906 + var al, bl, cl, dl, el;
  2907 + var ar, br, cr, dr, er;
  2908 +
  2909 + ar = al = H[0];
  2910 + br = bl = H[1];
  2911 + cr = cl = H[2];
  2912 + dr = dl = H[3];
  2913 + er = el = H[4];
  2914 + // Computation
  2915 + var t;
  2916 + for (var i = 0; i < 80; i += 1) {
  2917 + t = (al + M[offset+zl[i]])|0;
  2918 + if (i<16){
  2919 + t += f1(bl,cl,dl) + hl[0];
  2920 + } else if (i<32) {
  2921 + t += f2(bl,cl,dl) + hl[1];
  2922 + } else if (i<48) {
  2923 + t += f3(bl,cl,dl) + hl[2];
  2924 + } else if (i<64) {
  2925 + t += f4(bl,cl,dl) + hl[3];
  2926 + } else {// if (i<80) {
  2927 + t += f5(bl,cl,dl) + hl[4];
  2928 + }
  2929 + t = t|0;
  2930 + t = rotl(t,sl[i]);
  2931 + t = (t+el)|0;
  2932 + al = el;
  2933 + el = dl;
  2934 + dl = rotl(cl, 10);
  2935 + cl = bl;
  2936 + bl = t;
  2937 +
  2938 + t = (ar + M[offset+zr[i]])|0;
  2939 + if (i<16){
  2940 + t += f5(br,cr,dr) + hr[0];
  2941 + } else if (i<32) {
  2942 + t += f4(br,cr,dr) + hr[1];
  2943 + } else if (i<48) {
  2944 + t += f3(br,cr,dr) + hr[2];
  2945 + } else if (i<64) {
  2946 + t += f2(br,cr,dr) + hr[3];
  2947 + } else {// if (i<80) {
  2948 + t += f1(br,cr,dr) + hr[4];
  2949 + }
  2950 + t = t|0;
  2951 + t = rotl(t,sr[i]) ;
  2952 + t = (t+er)|0;
  2953 + ar = er;
  2954 + er = dr;
  2955 + dr = rotl(cr, 10);
  2956 + cr = br;
  2957 + br = t;
  2958 + }
  2959 + // Intermediate hash value
  2960 + t = (H[1] + cl + dr)|0;
  2961 + H[1] = (H[2] + dl + er)|0;
  2962 + H[2] = (H[3] + el + ar)|0;
  2963 + H[3] = (H[4] + al + br)|0;
  2964 + H[4] = (H[0] + bl + cr)|0;
  2965 + H[0] = t;
  2966 + },
  2967 +
  2968 + _doFinalize: function () {
  2969 + // Shortcuts
  2970 + var data = this._data;
  2971 + var dataWords = data.words;
  2972 +
  2973 + var nBitsTotal = this._nDataBytes * 8;
  2974 + var nBitsLeft = data.sigBytes * 8;
  2975 +
  2976 + // Add padding
  2977 + dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
  2978 + dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = (
  2979 + (((nBitsTotal << 8) | (nBitsTotal >>> 24)) & 0x00ff00ff) |
  2980 + (((nBitsTotal << 24) | (nBitsTotal >>> 8)) & 0xff00ff00)
  2981 + );
  2982 + data.sigBytes = (dataWords.length + 1) * 4;
  2983 +
  2984 + // Hash final blocks
  2985 + this._process();
  2986 +
  2987 + // Shortcuts
  2988 + var hash = this._hash;
  2989 + var H = hash.words;
  2990 +
  2991 + // Swap endian
  2992 + for (var i = 0; i < 5; i++) {
  2993 + // Shortcut
  2994 + var H_i = H[i];
  2995 +
  2996 + // Swap
  2997 + H[i] = (((H_i << 8) | (H_i >>> 24)) & 0x00ff00ff) |
  2998 + (((H_i << 24) | (H_i >>> 8)) & 0xff00ff00);
  2999 + }
  3000 +
  3001 + // Return final computed hash
  3002 + return hash;
  3003 + },
  3004 +
  3005 + clone: function () {
  3006 + var clone = Hasher.clone.call(this);
  3007 + clone._hash = this._hash.clone();
  3008 +
  3009 + return clone;
  3010 + }
  3011 + });
  3012 +
  3013 +
  3014 + function f1(x, y, z) {
  3015 + return ((x) ^ (y) ^ (z));
  3016 +
  3017 + }
  3018 +
  3019 + function f2(x, y, z) {
  3020 + return (((x)&(y)) | ((~x)&(z)));
  3021 + }
  3022 +
  3023 + function f3(x, y, z) {
  3024 + return (((x) | (~(y))) ^ (z));
  3025 + }
  3026 +
  3027 + function f4(x, y, z) {
  3028 + return (((x) & (z)) | ((y)&(~(z))));
  3029 + }
  3030 +
  3031 + function f5(x, y, z) {
  3032 + return ((x) ^ ((y) |(~(z))));
  3033 +
  3034 + }
  3035 +
  3036 + function rotl(x,n) {
  3037 + return (x<<n) | (x>>>(32-n));
  3038 + }
  3039 +
  3040 +
  3041 + /**
  3042 + * Shortcut function to the hasher's object interface.
  3043 + *
  3044 + * @param {WordArray|string} message The message to hash.
  3045 + *
  3046 + * @return {WordArray} The hash.
  3047 + *
  3048 + * @static
  3049 + *
  3050 + * @example
  3051 + *
  3052 + * var hash = CryptoJS.RIPEMD160('message');
  3053 + * var hash = CryptoJS.RIPEMD160(wordArray);
  3054 + */
  3055 + C.RIPEMD160 = Hasher._createHelper(RIPEMD160);
  3056 +
  3057 + /**
  3058 + * Shortcut function to the HMAC's object interface.
  3059 + *
  3060 + * @param {WordArray|string} message The message to hash.
  3061 + * @param {WordArray|string} key The secret key.
  3062 + *
  3063 + * @return {WordArray} The HMAC.
  3064 + *
  3065 + * @static
  3066 + *
  3067 + * @example
  3068 + *
  3069 + * var hmac = CryptoJS.HmacRIPEMD160(message, key);
  3070 + */
  3071 + C.HmacRIPEMD160 = Hasher._createHmacHelper(RIPEMD160);
  3072 + }(Math));
  3073 +
  3074 +
  3075 + (function () {
  3076 + // Shortcuts
  3077 + var C = CryptoJS;
  3078 + var C_lib = C.lib;
  3079 + var Base = C_lib.Base;
  3080 + var C_enc = C.enc;
  3081 + var Utf8 = C_enc.Utf8;
  3082 + var C_algo = C.algo;
  3083 +
  3084 + /**
  3085 + * HMAC algorithm.
  3086 + */
  3087 + var HMAC = C_algo.HMAC = Base.extend({
  3088 + /**
  3089 + * Initializes a newly created HMAC.
  3090 + *
  3091 + * @param {Hasher} hasher The hash algorithm to use.
  3092 + * @param {WordArray|string} key The secret key.
  3093 + *
  3094 + * @example
  3095 + *
  3096 + * var hmacHasher = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA256, key);
  3097 + */
  3098 + init: function (hasher, key) {
  3099 + // Init hasher
  3100 + hasher = this._hasher = new hasher.init();
  3101 +
  3102 + // Convert string to WordArray, else assume WordArray already
  3103 + if (typeof key == 'string') {
  3104 + key = Utf8.parse(key);
  3105 + }
  3106 +
  3107 + // Shortcuts
  3108 + var hasherBlockSize = hasher.blockSize;
  3109 + var hasherBlockSizeBytes = hasherBlockSize * 4;
  3110 +
  3111 + // Allow arbitrary length keys
  3112 + if (key.sigBytes > hasherBlockSizeBytes) {
  3113 + key = hasher.finalize(key);
  3114 + }
  3115 +
  3116 + // Clamp excess bits
  3117 + key.clamp();
  3118 +
  3119 + // Clone key for inner and outer pads
  3120 + var oKey = this._oKey = key.clone();
  3121 + var iKey = this._iKey = key.clone();
  3122 +
  3123 + // Shortcuts
  3124 + var oKeyWords = oKey.words;
  3125 + var iKeyWords = iKey.words;
  3126 +
  3127 + // XOR keys with pad constants
  3128 + for (var i = 0; i < hasherBlockSize; i++) {
  3129 + oKeyWords[i] ^= 0x5c5c5c5c;
  3130 + iKeyWords[i] ^= 0x36363636;
  3131 + }
  3132 + oKey.sigBytes = iKey.sigBytes = hasherBlockSizeBytes;
  3133 +
  3134 + // Set initial values
  3135 + this.reset();
  3136 + },
  3137 +
  3138 + /**
  3139 + * Resets this HMAC to its initial state.
  3140 + *
  3141 + * @example
  3142 + *
  3143 + * hmacHasher.reset();
  3144 + */
  3145 + reset: function () {
  3146 + // Shortcut
  3147 + var hasher = this._hasher;
  3148 +
  3149 + // Reset
  3150 + hasher.reset();
  3151 + hasher.update(this._iKey);
  3152 + },
  3153 +
  3154 + /**
  3155 + * Updates this HMAC with a message.
  3156 + *
  3157 + * @param {WordArray|string} messageUpdate The message to append.
  3158 + *
  3159 + * @return {HMAC} This HMAC instance.
  3160 + *
  3161 + * @example
  3162 + *
  3163 + * hmacHasher.update('message');
  3164 + * hmacHasher.update(wordArray);
  3165 + */
  3166 + update: function (messageUpdate) {
  3167 + this._hasher.update(messageUpdate);
  3168 +
  3169 + // Chainable
  3170 + return this;
  3171 + },
  3172 +
  3173 + /**
  3174 + * Finalizes the HMAC computation.
  3175 + * Note that the finalize operation is effectively a destructive, read-once operation.
  3176 + *
  3177 + * @param {WordArray|string} messageUpdate (Optional) A final message update.
  3178 + *
  3179 + * @return {WordArray} The HMAC.
  3180 + *
  3181 + * @example
  3182 + *
  3183 + * var hmac = hmacHasher.finalize();
  3184 + * var hmac = hmacHasher.finalize('message');
  3185 + * var hmac = hmacHasher.finalize(wordArray);
  3186 + */
  3187 + finalize: function (messageUpdate) {
  3188 + // Shortcut
  3189 + var hasher = this._hasher;
  3190 +
  3191 + // Compute HMAC
  3192 + var innerHash = hasher.finalize(messageUpdate);
  3193 + hasher.reset();
  3194 + var hmac = hasher.finalize(this._oKey.clone().concat(innerHash));
  3195 +
  3196 + return hmac;
  3197 + }
  3198 + });
  3199 + }());
  3200 +
  3201 +
  3202 + (function () {
  3203 + // Shortcuts
  3204 + var C = CryptoJS;
  3205 + var C_lib = C.lib;
  3206 + var Base = C_lib.Base;
  3207 + var WordArray = C_lib.WordArray;
  3208 + var C_algo = C.algo;
  3209 + var SHA1 = C_algo.SHA1;
  3210 + var HMAC = C_algo.HMAC;
  3211 +
  3212 + /**
  3213 + * Password-Based Key Derivation Function 2 algorithm.
  3214 + */
  3215 + var PBKDF2 = C_algo.PBKDF2 = Base.extend({
  3216 + /**
  3217 + * Configuration options.
  3218 + *
  3219 + * @property {number} keySize The key size in words to generate. Default: 4 (128 bits)
  3220 + * @property {Hasher} hasher The hasher to use. Default: SHA1
  3221 + * @property {number} iterations The number of iterations to perform. Default: 1
  3222 + */
  3223 + cfg: Base.extend({
  3224 + keySize: 128/32,
  3225 + hasher: SHA1,
  3226 + iterations: 1
  3227 + }),
  3228 +
  3229 + /**
  3230 + * Initializes a newly created key derivation function.
  3231 + *
  3232 + * @param {Object} cfg (Optional) The configuration options to use for the derivation.
  3233 + *
  3234 + * @example
  3235 + *
  3236 + * var kdf = CryptoJS.algo.PBKDF2.create();
  3237 + * var kdf = CryptoJS.algo.PBKDF2.create({ keySize: 8 });
  3238 + * var kdf = CryptoJS.algo.PBKDF2.create({ keySize: 8, iterations: 1000 });
  3239 + */
  3240 + init: function (cfg) {
  3241 + this.cfg = this.cfg.extend(cfg);
  3242 + },
  3243 +
  3244 + /**
  3245 + * Computes the Password-Based Key Derivation Function 2.
  3246 + *
  3247 + * @param {WordArray|string} password The password.
  3248 + * @param {WordArray|string} salt A salt.
  3249 + *
  3250 + * @return {WordArray} The derived key.
  3251 + *
  3252 + * @example
  3253 + *
  3254 + * var key = kdf.compute(password, salt);
  3255 + */
  3256 + compute: function (password, salt) {
  3257 + // Shortcut
  3258 + var cfg = this.cfg;
  3259 +
  3260 + // Init HMAC
  3261 + var hmac = HMAC.create(cfg.hasher, password);
  3262 +
  3263 + // Initial values
  3264 + var derivedKey = WordArray.create();
  3265 + var blockIndex = WordArray.create([0x00000001]);
  3266 +
  3267 + // Shortcuts
  3268 + var derivedKeyWords = derivedKey.words;
  3269 + var blockIndexWords = blockIndex.words;
  3270 + var keySize = cfg.keySize;
  3271 + var iterations = cfg.iterations;
  3272 +
  3273 + // Generate key
  3274 + while (derivedKeyWords.length < keySize) {
  3275 + var block = hmac.update(salt).finalize(blockIndex);
  3276 + hmac.reset();
  3277 +
  3278 + // Shortcuts
  3279 + var blockWords = block.words;
  3280 + var blockWordsLength = blockWords.length;
  3281 +
  3282 + // Iterations
  3283 + var intermediate = block;
  3284 + for (var i = 1; i < iterations; i++) {
  3285 + intermediate = hmac.finalize(intermediate);
  3286 + hmac.reset();
  3287 +
  3288 + // Shortcut
  3289 + var intermediateWords = intermediate.words;
  3290 +
  3291 + // XOR intermediate with block
  3292 + for (var j = 0; j < blockWordsLength; j++) {
  3293 + blockWords[j] ^= intermediateWords[j];
  3294 + }
  3295 + }
  3296 +
  3297 + derivedKey.concat(block);
  3298 + blockIndexWords[0]++;
  3299 + }
  3300 + derivedKey.sigBytes = keySize * 4;
  3301 +
  3302 + return derivedKey;
  3303 + }
  3304 + });
  3305 +
  3306 + /**
  3307 + * Computes the Password-Based Key Derivation Function 2.
  3308 + *
  3309 + * @param {WordArray|string} password The password.
  3310 + * @param {WordArray|string} salt A salt.
  3311 + * @param {Object} cfg (Optional) The configuration options to use for this computation.
  3312 + *
  3313 + * @return {WordArray} The derived key.
  3314 + *
  3315 + * @static
  3316 + *
  3317 + * @example
  3318 + *
  3319 + * var key = CryptoJS.PBKDF2(password, salt);
  3320 + * var key = CryptoJS.PBKDF2(password, salt, { keySize: 8 });
  3321 + * var key = CryptoJS.PBKDF2(password, salt, { keySize: 8, iterations: 1000 });
  3322 + */
  3323 + C.PBKDF2 = function (password, salt, cfg) {
  3324 + return PBKDF2.create(cfg).compute(password, salt);
  3325 + };
  3326 + }());
  3327 +
  3328 +
  3329 + (function () {
  3330 + // Shortcuts
  3331 + var C = CryptoJS;
  3332 + var C_lib = C.lib;
  3333 + var Base = C_lib.Base;
  3334 + var WordArray = C_lib.WordArray;
  3335 + var C_algo = C.algo;
  3336 + var MD5 = C_algo.MD5;
  3337 +
  3338 + /**
  3339 + * This key derivation function is meant to conform with EVP_BytesToKey.
  3340 + * www.openssl.org/docs/crypto/EVP_BytesToKey.html
  3341 + */
  3342 + var EvpKDF = C_algo.EvpKDF = Base.extend({
  3343 + /**
  3344 + * Configuration options.
  3345 + *
  3346 + * @property {number} keySize The key size in words to generate. Default: 4 (128 bits)
  3347 + * @property {Hasher} hasher The hash algorithm to use. Default: MD5
  3348 + * @property {number} iterations The number of iterations to perform. Default: 1
  3349 + */
  3350 + cfg: Base.extend({
  3351 + keySize: 128/32,
  3352 + hasher: MD5,
  3353 + iterations: 1
  3354 + }),
  3355 +
  3356 + /**
  3357 + * Initializes a newly created key derivation function.
  3358 + *
  3359 + * @param {Object} cfg (Optional) The configuration options to use for the derivation.
  3360 + *
  3361 + * @example
  3362 + *
  3363 + * var kdf = CryptoJS.algo.EvpKDF.create();
  3364 + * var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8 });
  3365 + * var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8, iterations: 1000 });
  3366 + */
  3367 + init: function (cfg) {
  3368 + this.cfg = this.cfg.extend(cfg);
  3369 + },
  3370 +
  3371 + /**
  3372 + * Derives a key from a password.
  3373 + *
  3374 + * @param {WordArray|string} password The password.
  3375 + * @param {WordArray|string} salt A salt.
  3376 + *
  3377 + * @return {WordArray} The derived key.
  3378 + *
  3379 + * @example
  3380 + *
  3381 + * var key = kdf.compute(password, salt);
  3382 + */
  3383 + compute: function (password, salt) {
  3384 + var block;
  3385 +
  3386 + // Shortcut
  3387 + var cfg = this.cfg;
  3388 +
  3389 + // Init hasher
  3390 + var hasher = cfg.hasher.create();
  3391 +
  3392 + // Initial values
  3393 + var derivedKey = WordArray.create();
  3394 +
  3395 + // Shortcuts
  3396 + var derivedKeyWords = derivedKey.words;
  3397 + var keySize = cfg.keySize;
  3398 + var iterations = cfg.iterations;
  3399 +
  3400 + // Generate key
  3401 + while (derivedKeyWords.length < keySize) {
  3402 + if (block) {
  3403 + hasher.update(block);
  3404 + }
  3405 + block = hasher.update(password).finalize(salt);
  3406 + hasher.reset();
  3407 +
  3408 + // Iterations
  3409 + for (var i = 1; i < iterations; i++) {
  3410 + block = hasher.finalize(block);
  3411 + hasher.reset();
  3412 + }
  3413 +
  3414 + derivedKey.concat(block);
  3415 + }
  3416 + derivedKey.sigBytes = keySize * 4;
  3417 +
  3418 + return derivedKey;
  3419 + }
  3420 + });
  3421 +
  3422 + /**
  3423 + * Derives a key from a password.
  3424 + *
  3425 + * @param {WordArray|string} password The password.
  3426 + * @param {WordArray|string} salt A salt.
  3427 + * @param {Object} cfg (Optional) The configuration options to use for this computation.
  3428 + *
  3429 + * @return {WordArray} The derived key.
  3430 + *
  3431 + * @static
  3432 + *
  3433 + * @example
  3434 + *
  3435 + * var key = CryptoJS.EvpKDF(password, salt);
  3436 + * var key = CryptoJS.EvpKDF(password, salt, { keySize: 8 });
  3437 + * var key = CryptoJS.EvpKDF(password, salt, { keySize: 8, iterations: 1000 });
  3438 + */
  3439 + C.EvpKDF = function (password, salt, cfg) {
  3440 + return EvpKDF.create(cfg).compute(password, salt);
  3441 + };
  3442 + }());
  3443 +
  3444 +
  3445 + /**
  3446 + * Cipher core components.
  3447 + */
  3448 + CryptoJS.lib.Cipher || (function (undefined) {
  3449 + // Shortcuts
  3450 + var C = CryptoJS;
  3451 + var C_lib = C.lib;
  3452 + var Base = C_lib.Base;
  3453 + var WordArray = C_lib.WordArray;
  3454 + var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm;
  3455 + var C_enc = C.enc;
  3456 + var Utf8 = C_enc.Utf8;
  3457 + var Base64 = C_enc.Base64;
  3458 + var C_algo = C.algo;
  3459 + var EvpKDF = C_algo.EvpKDF;
  3460 +
  3461 + /**
  3462 + * Abstract base cipher template.
  3463 + *
  3464 + * @property {number} keySize This cipher's key size. Default: 4 (128 bits)
  3465 + * @property {number} ivSize This cipher's IV size. Default: 4 (128 bits)
  3466 + * @property {number} _ENC_XFORM_MODE A constant representing encryption mode.
  3467 + * @property {number} _DEC_XFORM_MODE A constant representing decryption mode.
  3468 + */
  3469 + var Cipher = C_lib.Cipher = BufferedBlockAlgorithm.extend({
  3470 + /**
  3471 + * Configuration options.
  3472 + *
  3473 + * @property {WordArray} iv The IV to use for this operation.
  3474 + */
  3475 + cfg: Base.extend(),
  3476 +
  3477 + /**
  3478 + * Creates this cipher in encryption mode.
  3479 + *
  3480 + * @param {WordArray} key The key.
  3481 + * @param {Object} cfg (Optional) The configuration options to use for this operation.
  3482 + *
  3483 + * @return {Cipher} A cipher instance.
  3484 + *
  3485 + * @static
  3486 + *
  3487 + * @example
  3488 + *
  3489 + * var cipher = CryptoJS.algo.AES.createEncryptor(keyWordArray, { iv: ivWordArray });
  3490 + */
  3491 + createEncryptor: function (key, cfg) {
  3492 + return this.create(this._ENC_XFORM_MODE, key, cfg);
  3493 + },
  3494 +
  3495 + /**
  3496 + * Creates this cipher in decryption mode.
  3497 + *
  3498 + * @param {WordArray} key The key.
  3499 + * @param {Object} cfg (Optional) The configuration options to use for this operation.
  3500 + *
  3501 + * @return {Cipher} A cipher instance.
  3502 + *
  3503 + * @static
  3504 + *
  3505 + * @example
  3506 + *
  3507 + * var cipher = CryptoJS.algo.AES.createDecryptor(keyWordArray, { iv: ivWordArray });
  3508 + */
  3509 + createDecryptor: function (key, cfg) {
  3510 + return this.create(this._DEC_XFORM_MODE, key, cfg);
  3511 + },
  3512 +
  3513 + /**
  3514 + * Initializes a newly created cipher.
  3515 + *
  3516 + * @param {number} xformMode Either the encryption or decryption transormation mode constant.
  3517 + * @param {WordArray} key The key.
  3518 + * @param {Object} cfg (Optional) The configuration options to use for this operation.
  3519 + *
  3520 + * @example
  3521 + *
  3522 + * var cipher = CryptoJS.algo.AES.create(CryptoJS.algo.AES._ENC_XFORM_MODE, keyWordArray, { iv: ivWordArray });
  3523 + */
  3524 + init: function (xformMode, key, cfg) {
  3525 + // Apply config defaults
  3526 + this.cfg = this.cfg.extend(cfg);
  3527 +
  3528 + // Store transform mode and key
  3529 + this._xformMode = xformMode;
  3530 + this._key = key;
  3531 +
  3532 + // Set initial values
  3533 + this.reset();
  3534 + },
  3535 +
  3536 + /**
  3537 + * Resets this cipher to its initial state.
  3538 + *
  3539 + * @example
  3540 + *
  3541 + * cipher.reset();
  3542 + */
  3543 + reset: function () {
  3544 + // Reset data buffer
  3545 + BufferedBlockAlgorithm.reset.call(this);
  3546 +
  3547 + // Perform concrete-cipher logic
  3548 + this._doReset();
  3549 + },
  3550 +
  3551 + /**
  3552 + * Adds data to be encrypted or decrypted.
  3553 + *
  3554 + * @param {WordArray|string} dataUpdate The data to encrypt or decrypt.
  3555 + *
  3556 + * @return {WordArray} The data after processing.
  3557 + *
  3558 + * @example
  3559 + *
  3560 + * var encrypted = cipher.process('data');
  3561 + * var encrypted = cipher.process(wordArray);
  3562 + */
  3563 + process: function (dataUpdate) {
  3564 + // Append
  3565 + this._append(dataUpdate);
  3566 +
  3567 + // Process available blocks
  3568 + return this._process();
  3569 + },
  3570 +
  3571 + /**
  3572 + * Finalizes the encryption or decryption process.
  3573 + * Note that the finalize operation is effectively a destructive, read-once operation.
  3574 + *
  3575 + * @param {WordArray|string} dataUpdate The final data to encrypt or decrypt.
  3576 + *
  3577 + * @return {WordArray} The data after final processing.
  3578 + *
  3579 + * @example
  3580 + *
  3581 + * var encrypted = cipher.finalize();
  3582 + * var encrypted = cipher.finalize('data');
  3583 + * var encrypted = cipher.finalize(wordArray);
  3584 + */
  3585 + finalize: function (dataUpdate) {
  3586 + // Final data update
  3587 + if (dataUpdate) {
  3588 + this._append(dataUpdate);
  3589 + }
  3590 +
  3591 + // Perform concrete-cipher logic
  3592 + var finalProcessedData = this._doFinalize();
  3593 +
  3594 + return finalProcessedData;
  3595 + },
  3596 +
  3597 + keySize: 128/32,
  3598 +
  3599 + ivSize: 128/32,
  3600 +
  3601 + _ENC_XFORM_MODE: 1,
  3602 +
  3603 + _DEC_XFORM_MODE: 2,
  3604 +
  3605 + /**
  3606 + * Creates shortcut functions to a cipher's object interface.
  3607 + *
  3608 + * @param {Cipher} cipher The cipher to create a helper for.
  3609 + *
  3610 + * @return {Object} An object with encrypt and decrypt shortcut functions.
  3611 + *
  3612 + * @static
  3613 + *
  3614 + * @example
  3615 + *
  3616 + * var AES = CryptoJS.lib.Cipher._createHelper(CryptoJS.algo.AES);
  3617 + */
  3618 + _createHelper: (function () {
  3619 + function selectCipherStrategy(key) {
  3620 + if (typeof key == 'string') {
  3621 + return PasswordBasedCipher;
  3622 + } else {
  3623 + return SerializableCipher;
  3624 + }
  3625 + }
  3626 +
  3627 + return function (cipher) {
  3628 + return {
  3629 + encrypt: function (message, key, cfg) {
  3630 + return selectCipherStrategy(key).encrypt(cipher, message, key, cfg);
  3631 + },
  3632 +
  3633 + decrypt: function (ciphertext, key, cfg) {
  3634 + return selectCipherStrategy(key).decrypt(cipher, ciphertext, key, cfg);
  3635 + }
  3636 + };
  3637 + };
  3638 + }())
  3639 + });
  3640 +
  3641 + /**
  3642 + * Abstract base stream cipher template.
  3643 + *
  3644 + * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 1 (32 bits)
  3645 + */
  3646 + var StreamCipher = C_lib.StreamCipher = Cipher.extend({
  3647 + _doFinalize: function () {
  3648 + // Process partial blocks
  3649 + var finalProcessedBlocks = this._process(!!'flush');
  3650 +
  3651 + return finalProcessedBlocks;
  3652 + },
  3653 +
  3654 + blockSize: 1
  3655 + });
  3656 +
  3657 + /**
  3658 + * Mode namespace.
  3659 + */
  3660 + var C_mode = C.mode = {};
  3661 +
  3662 + /**
  3663 + * Abstract base block cipher mode template.
  3664 + */
  3665 + var BlockCipherMode = C_lib.BlockCipherMode = Base.extend({
  3666 + /**
  3667 + * Creates this mode for encryption.
  3668 + *
  3669 + * @param {Cipher} cipher A block cipher instance.
  3670 + * @param {Array} iv The IV words.
  3671 + *
  3672 + * @static
  3673 + *
  3674 + * @example
  3675 + *
  3676 + * var mode = CryptoJS.mode.CBC.createEncryptor(cipher, iv.words);
  3677 + */
  3678 + createEncryptor: function (cipher, iv) {
  3679 + return this.Encryptor.create(cipher, iv);
  3680 + },
  3681 +
  3682 + /**
  3683 + * Creates this mode for decryption.
  3684 + *
  3685 + * @param {Cipher} cipher A block cipher instance.
  3686 + * @param {Array} iv The IV words.
  3687 + *
  3688 + * @static
  3689 + *
  3690 + * @example
  3691 + *
  3692 + * var mode = CryptoJS.mode.CBC.createDecryptor(cipher, iv.words);
  3693 + */
  3694 + createDecryptor: function (cipher, iv) {
  3695 + return this.Decryptor.create(cipher, iv);
  3696 + },
  3697 +
  3698 + /**
  3699 + * Initializes a newly created mode.
  3700 + *
  3701 + * @param {Cipher} cipher A block cipher instance.
  3702 + * @param {Array} iv The IV words.
  3703 + *
  3704 + * @example
  3705 + *
  3706 + * var mode = CryptoJS.mode.CBC.Encryptor.create(cipher, iv.words);
  3707 + */
  3708 + init: function (cipher, iv) {
  3709 + this._cipher = cipher;
  3710 + this._iv = iv;
  3711 + }
  3712 + });
  3713 +
  3714 + /**
  3715 + * Cipher Block Chaining mode.
  3716 + */
  3717 + var CBC = C_mode.CBC = (function () {
  3718 + /**
  3719 + * Abstract base CBC mode.
  3720 + */
  3721 + var CBC = BlockCipherMode.extend();
  3722 +
  3723 + /**
  3724 + * CBC encryptor.
  3725 + */
  3726 + CBC.Encryptor = CBC.extend({
  3727 + /**
  3728 + * Processes the data block at offset.
  3729 + *
  3730 + * @param {Array} words The data words to operate on.
  3731 + * @param {number} offset The offset where the block starts.
  3732 + *
  3733 + * @example
  3734 + *
  3735 + * mode.processBlock(data.words, offset);
  3736 + */
  3737 + processBlock: function (words, offset) {
  3738 + // Shortcuts
  3739 + var cipher = this._cipher;
  3740 + var blockSize = cipher.blockSize;
  3741 +
  3742 + // XOR and encrypt
  3743 + xorBlock.call(this, words, offset, blockSize);
  3744 + cipher.encryptBlock(words, offset);
  3745 +
  3746 + // Remember this block to use with next block
  3747 + this._prevBlock = words.slice(offset, offset + blockSize);
  3748 + }
  3749 + });
  3750 +
  3751 + /**
  3752 + * CBC decryptor.
  3753 + */
  3754 + CBC.Decryptor = CBC.extend({
  3755 + /**
  3756 + * Processes the data block at offset.
  3757 + *
  3758 + * @param {Array} words The data words to operate on.
  3759 + * @param {number} offset The offset where the block starts.
  3760 + *
  3761 + * @example
  3762 + *
  3763 + * mode.processBlock(data.words, offset);
  3764 + */
  3765 + processBlock: function (words, offset) {
  3766 + // Shortcuts
  3767 + var cipher = this._cipher;
  3768 + var blockSize = cipher.blockSize;
  3769 +
  3770 + // Remember this block to use with next block
  3771 + var thisBlock = words.slice(offset, offset + blockSize);
  3772 +
  3773 + // Decrypt and XOR
  3774 + cipher.decryptBlock(words, offset);
  3775 + xorBlock.call(this, words, offset, blockSize);
  3776 +
  3777 + // This block becomes the previous block
  3778 + this._prevBlock = thisBlock;
  3779 + }
  3780 + });
  3781 +
  3782 + function xorBlock(words, offset, blockSize) {
  3783 + var block;
  3784 +
  3785 + // Shortcut
  3786 + var iv = this._iv;
  3787 +
  3788 + // Choose mixing block
  3789 + if (iv) {
  3790 + block = iv;
  3791 +
  3792 + // Remove IV for subsequent blocks
  3793 + this._iv = undefined;
  3794 + } else {
  3795 + block = this._prevBlock;
  3796 + }
  3797 +
  3798 + // XOR blocks
  3799 + for (var i = 0; i < blockSize; i++) {
  3800 + words[offset + i] ^= block[i];
  3801 + }
  3802 + }
  3803 +
  3804 + return CBC;
  3805 + }());
  3806 +
  3807 + /**
  3808 + * Padding namespace.
  3809 + */
  3810 + var C_pad = C.pad = {};
  3811 +
  3812 + /**
  3813 + * PKCS #5/7 padding strategy.
  3814 + */
  3815 + var Pkcs7 = C_pad.Pkcs7 = {
  3816 + /**
  3817 + * Pads data using the algorithm defined in PKCS #5/7.
  3818 + *
  3819 + * @param {WordArray} data The data to pad.
  3820 + * @param {number} blockSize The multiple that the data should be padded to.
  3821 + *
  3822 + * @static
  3823 + *
  3824 + * @example
  3825 + *
  3826 + * CryptoJS.pad.Pkcs7.pad(wordArray, 4);
  3827 + */
  3828 + pad: function (data, blockSize) {
  3829 + // Shortcut
  3830 + var blockSizeBytes = blockSize * 4;
  3831 +
  3832 + // Count padding bytes
  3833 + var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes;
  3834 +
  3835 + // Create padding word
  3836 + var paddingWord = (nPaddingBytes << 24) | (nPaddingBytes << 16) | (nPaddingBytes << 8) | nPaddingBytes;
  3837 +
  3838 + // Create padding
  3839 + var paddingWords = [];
  3840 + for (var i = 0; i < nPaddingBytes; i += 4) {
  3841 + paddingWords.push(paddingWord);
  3842 + }
  3843 + var padding = WordArray.create(paddingWords, nPaddingBytes);
  3844 +
  3845 + // Add padding
  3846 + data.concat(padding);
  3847 + },
  3848 +
  3849 + /**
  3850 + * Unpads data that had been padded using the algorithm defined in PKCS #5/7.
  3851 + *
  3852 + * @param {WordArray} data The data to unpad.
  3853 + *
  3854 + * @static
  3855 + *
  3856 + * @example
  3857 + *
  3858 + * CryptoJS.pad.Pkcs7.unpad(wordArray);
  3859 + */
  3860 + unpad: function (data) {
  3861 + // Get number of padding bytes from last byte
  3862 + var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;
  3863 +
  3864 + // Remove padding
  3865 + data.sigBytes -= nPaddingBytes;
  3866 + }
  3867 + };
  3868 +
  3869 + /**
  3870 + * Abstract base block cipher template.
  3871 + *
  3872 + * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 4 (128 bits)
  3873 + */
  3874 + var BlockCipher = C_lib.BlockCipher = Cipher.extend({
  3875 + /**
  3876 + * Configuration options.
  3877 + *
  3878 + * @property {Mode} mode The block mode to use. Default: CBC
  3879 + * @property {Padding} padding The padding strategy to use. Default: Pkcs7
  3880 + */
  3881 + cfg: Cipher.cfg.extend({
  3882 + mode: CBC,
  3883 + padding: Pkcs7
  3884 + }),
  3885 +
  3886 + reset: function () {
  3887 + var modeCreator;
  3888 +
  3889 + // Reset cipher
  3890 + Cipher.reset.call(this);
  3891 +
  3892 + // Shortcuts
  3893 + var cfg = this.cfg;
  3894 + var iv = cfg.iv;
  3895 + var mode = cfg.mode;
  3896 +
  3897 + // Reset block mode
  3898 + if (this._xformMode == this._ENC_XFORM_MODE) {
  3899 + modeCreator = mode.createEncryptor;
  3900 + } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {
  3901 + modeCreator = mode.createDecryptor;
  3902 + // Keep at least one block in the buffer for unpadding
  3903 + this._minBufferSize = 1;
  3904 + }
  3905 +
  3906 + if (this._mode && this._mode.__creator == modeCreator) {
  3907 + this._mode.init(this, iv && iv.words);
  3908 + } else {
  3909 + this._mode = modeCreator.call(mode, this, iv && iv.words);
  3910 + this._mode.__creator = modeCreator;
  3911 + }
  3912 + },
  3913 +
  3914 + _doProcessBlock: function (words, offset) {
  3915 + this._mode.processBlock(words, offset);
  3916 + },
  3917 +
  3918 + _doFinalize: function () {
  3919 + var finalProcessedBlocks;
  3920 +
  3921 + // Shortcut
  3922 + var padding = this.cfg.padding;
  3923 +
  3924 + // Finalize
  3925 + if (this._xformMode == this._ENC_XFORM_MODE) {
  3926 + // Pad data
  3927 + padding.pad(this._data, this.blockSize);
  3928 +
  3929 + // Process final blocks
  3930 + finalProcessedBlocks = this._process(!!'flush');
  3931 + } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {
  3932 + // Process final blocks
  3933 + finalProcessedBlocks = this._process(!!'flush');
  3934 +
  3935 + // Unpad data
  3936 + padding.unpad(finalProcessedBlocks);
  3937 + }
  3938 +
  3939 + return finalProcessedBlocks;
  3940 + },
  3941 +
  3942 + blockSize: 128/32
  3943 + });
  3944 +
  3945 + /**
  3946 + * A collection of cipher parameters.
  3947 + *
  3948 + * @property {WordArray} ciphertext The raw ciphertext.
  3949 + * @property {WordArray} key The key to this ciphertext.
  3950 + * @property {WordArray} iv The IV used in the ciphering operation.
  3951 + * @property {WordArray} salt The salt used with a key derivation function.
  3952 + * @property {Cipher} algorithm The cipher algorithm.
  3953 + * @property {Mode} mode The block mode used in the ciphering operation.
  3954 + * @property {Padding} padding The padding scheme used in the ciphering operation.
  3955 + * @property {number} blockSize The block size of the cipher.
  3956 + * @property {Format} formatter The default formatting strategy to convert this cipher params object to a string.
  3957 + */
  3958 + var CipherParams = C_lib.CipherParams = Base.extend({
  3959 + /**
  3960 + * Initializes a newly created cipher params object.
  3961 + *
  3962 + * @param {Object} cipherParams An object with any of the possible cipher parameters.
  3963 + *
  3964 + * @example
  3965 + *
  3966 + * var cipherParams = CryptoJS.lib.CipherParams.create({
  3967 + * ciphertext: ciphertextWordArray,
  3968 + * key: keyWordArray,
  3969 + * iv: ivWordArray,
  3970 + * salt: saltWordArray,
  3971 + * algorithm: CryptoJS.algo.AES,
  3972 + * mode: CryptoJS.mode.CBC,
  3973 + * padding: CryptoJS.pad.PKCS7,
  3974 + * blockSize: 4,
  3975 + * formatter: CryptoJS.format.OpenSSL
  3976 + * });
  3977 + */
  3978 + init: function (cipherParams) {
  3979 + this.mixIn(cipherParams);
  3980 + },
  3981 +
  3982 + /**
  3983 + * Converts this cipher params object to a string.
  3984 + *
  3985 + * @param {Format} formatter (Optional) The formatting strategy to use.
  3986 + *
  3987 + * @return {string} The stringified cipher params.
  3988 + *
  3989 + * @throws Error If neither the formatter nor the default formatter is set.
  3990 + *
  3991 + * @example
  3992 + *
  3993 + * var string = cipherParams + '';
  3994 + * var string = cipherParams.toString();
  3995 + * var string = cipherParams.toString(CryptoJS.format.OpenSSL);
  3996 + */
  3997 + toString: function (formatter) {
  3998 + return (formatter || this.formatter).stringify(this);
  3999 + }
  4000 + });
  4001 +
  4002 + /**
  4003 + * Format namespace.
  4004 + */
  4005 + var C_format = C.format = {};
  4006 +
  4007 + /**
  4008 + * OpenSSL formatting strategy.
  4009 + */
  4010 + var OpenSSLFormatter = C_format.OpenSSL = {
  4011 + /**
  4012 + * Converts a cipher params object to an OpenSSL-compatible string.
  4013 + *
  4014 + * @param {CipherParams} cipherParams The cipher params object.
  4015 + *
  4016 + * @return {string} The OpenSSL-compatible string.
  4017 + *
  4018 + * @static
  4019 + *
  4020 + * @example
  4021 + *
  4022 + * var openSSLString = CryptoJS.format.OpenSSL.stringify(cipherParams);
  4023 + */
  4024 + stringify: function (cipherParams) {
  4025 + var wordArray;
  4026 +
  4027 + // Shortcuts
  4028 + var ciphertext = cipherParams.ciphertext;
  4029 + var salt = cipherParams.salt;
  4030 +
  4031 + // Format
  4032 + if (salt) {
  4033 + wordArray = WordArray.create([0x53616c74, 0x65645f5f]).concat(salt).concat(ciphertext);
  4034 + } else {
  4035 + wordArray = ciphertext;
  4036 + }
  4037 +
  4038 + return wordArray.toString(Base64);
  4039 + },
  4040 +
  4041 + /**
  4042 + * Converts an OpenSSL-compatible string to a cipher params object.
  4043 + *
  4044 + * @param {string} openSSLStr The OpenSSL-compatible string.
  4045 + *
  4046 + * @return {CipherParams} The cipher params object.
  4047 + *
  4048 + * @static
  4049 + *
  4050 + * @example
  4051 + *
  4052 + * var cipherParams = CryptoJS.format.OpenSSL.parse(openSSLString);
  4053 + */
  4054 + parse: function (openSSLStr) {
  4055 + var salt;
  4056 +
  4057 + // Parse base64
  4058 + var ciphertext = Base64.parse(openSSLStr);
  4059 +
  4060 + // Shortcut
  4061 + var ciphertextWords = ciphertext.words;
  4062 +
  4063 + // Test for salt
  4064 + if (ciphertextWords[0] == 0x53616c74 && ciphertextWords[1] == 0x65645f5f) {
  4065 + // Extract salt
  4066 + salt = WordArray.create(ciphertextWords.slice(2, 4));
  4067 +
  4068 + // Remove salt from ciphertext
  4069 + ciphertextWords.splice(0, 4);
  4070 + ciphertext.sigBytes -= 16;
  4071 + }
  4072 +
  4073 + return CipherParams.create({ ciphertext: ciphertext, salt: salt });
  4074 + }
  4075 + };
  4076 +
  4077 + /**
  4078 + * A cipher wrapper that returns ciphertext as a serializable cipher params object.
  4079 + */
  4080 + var SerializableCipher = C_lib.SerializableCipher = Base.extend({
  4081 + /**
  4082 + * Configuration options.
  4083 + *
  4084 + * @property {Formatter} format The formatting strategy to convert cipher param objects to and from a string. Default: OpenSSL
  4085 + */
  4086 + cfg: Base.extend({
  4087 + format: OpenSSLFormatter
  4088 + }),
  4089 +
  4090 + /**
  4091 + * Encrypts a message.
  4092 + *
  4093 + * @param {Cipher} cipher The cipher algorithm to use.
  4094 + * @param {WordArray|string} message The message to encrypt.
  4095 + * @param {WordArray} key The key.
  4096 + * @param {Object} cfg (Optional) The configuration options to use for this operation.
  4097 + *
  4098 + * @return {CipherParams} A cipher params object.
  4099 + *
  4100 + * @static
  4101 + *
  4102 + * @example
  4103 + *
  4104 + * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key);
  4105 + * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv });
  4106 + * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv, format: CryptoJS.format.OpenSSL });
  4107 + */
  4108 + encrypt: function (cipher, message, key, cfg) {
  4109 + // Apply config defaults
  4110 + cfg = this.cfg.extend(cfg);
  4111 +
  4112 + // Encrypt
  4113 + var encryptor = cipher.createEncryptor(key, cfg);
  4114 + var ciphertext = encryptor.finalize(message);
  4115 +
  4116 + // Shortcut
  4117 + var cipherCfg = encryptor.cfg;
  4118 +
  4119 + // Create and return serializable cipher params
  4120 + return CipherParams.create({
  4121 + ciphertext: ciphertext,
  4122 + key: key,
  4123 + iv: cipherCfg.iv,
  4124 + algorithm: cipher,
  4125 + mode: cipherCfg.mode,
  4126 + padding: cipherCfg.padding,
  4127 + blockSize: cipher.blockSize,
  4128 + formatter: cfg.format
  4129 + });
  4130 + },
  4131 +
  4132 + /**
  4133 + * Decrypts serialized ciphertext.
  4134 + *
  4135 + * @param {Cipher} cipher The cipher algorithm to use.
  4136 + * @param {CipherParams|string} ciphertext The ciphertext to decrypt.
  4137 + * @param {WordArray} key The key.
  4138 + * @param {Object} cfg (Optional) The configuration options to use for this operation.
  4139 + *
  4140 + * @return {WordArray} The plaintext.
  4141 + *
  4142 + * @static
  4143 + *
  4144 + * @example
  4145 + *
  4146 + * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, key, { iv: iv, format: CryptoJS.format.OpenSSL });
  4147 + * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, key, { iv: iv, format: CryptoJS.format.OpenSSL });
  4148 + */
  4149 + decrypt: function (cipher, ciphertext, key, cfg) {
  4150 + // Apply config defaults
  4151 + cfg = this.cfg.extend(cfg);
  4152 +
  4153 + // Convert string to CipherParams
  4154 + ciphertext = this._parse(ciphertext, cfg.format);
  4155 +
  4156 + // Decrypt
  4157 + var plaintext = cipher.createDecryptor(key, cfg).finalize(ciphertext.ciphertext);
  4158 +
  4159 + return plaintext;
  4160 + },
  4161 +
  4162 + /**
  4163 + * Converts serialized ciphertext to CipherParams,
  4164 + * else assumed CipherParams already and returns ciphertext unchanged.
  4165 + *
  4166 + * @param {CipherParams|string} ciphertext The ciphertext.
  4167 + * @param {Formatter} format The formatting strategy to use to parse serialized ciphertext.
  4168 + *
  4169 + * @return {CipherParams} The unserialized ciphertext.
  4170 + *
  4171 + * @static
  4172 + *
  4173 + * @example
  4174 + *
  4175 + * var ciphertextParams = CryptoJS.lib.SerializableCipher._parse(ciphertextStringOrParams, format);
  4176 + */
  4177 + _parse: function (ciphertext, format) {
  4178 + if (typeof ciphertext == 'string') {
  4179 + return format.parse(ciphertext, this);
  4180 + } else {
  4181 + return ciphertext;
  4182 + }
  4183 + }
  4184 + });
  4185 +
  4186 + /**
  4187 + * Key derivation function namespace.
  4188 + */
  4189 + var C_kdf = C.kdf = {};
  4190 +
  4191 + /**
  4192 + * OpenSSL key derivation function.
  4193 + */
  4194 + var OpenSSLKdf = C_kdf.OpenSSL = {
  4195 + /**
  4196 + * Derives a key and IV from a password.
  4197 + *
  4198 + * @param {string} password The password to derive from.
  4199 + * @param {number} keySize The size in words of the key to generate.
  4200 + * @param {number} ivSize The size in words of the IV to generate.
  4201 + * @param {WordArray|string} salt (Optional) A 64-bit salt to use. If omitted, a salt will be generated randomly.
  4202 + *
  4203 + * @return {CipherParams} A cipher params object with the key, IV, and salt.
  4204 + *
  4205 + * @static
  4206 + *
  4207 + * @example
  4208 + *
  4209 + * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32);
  4210 + * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32, 'saltsalt');
  4211 + */
  4212 + execute: function (password, keySize, ivSize, salt) {
  4213 + // Generate random salt
  4214 + if (!salt) {
  4215 + salt = WordArray.random(64/8);
  4216 + }
  4217 +
  4218 + // Derive key and IV
  4219 + var key = EvpKDF.create({ keySize: keySize + ivSize }).compute(password, salt);
  4220 +
  4221 + // Separate key and IV
  4222 + var iv = WordArray.create(key.words.slice(keySize), ivSize * 4);
  4223 + key.sigBytes = keySize * 4;
  4224 +
  4225 + // Return params
  4226 + return CipherParams.create({ key: key, iv: iv, salt: salt });
  4227 + }
  4228 + };
  4229 +
  4230 + /**
  4231 + * A serializable cipher wrapper that derives the key from a password,
  4232 + * and returns ciphertext as a serializable cipher params object.
  4233 + */
  4234 + var PasswordBasedCipher = C_lib.PasswordBasedCipher = SerializableCipher.extend({
  4235 + /**
  4236 + * Configuration options.
  4237 + *
  4238 + * @property {KDF} kdf The key derivation function to use to generate a key and IV from a password. Default: OpenSSL
  4239 + */
  4240 + cfg: SerializableCipher.cfg.extend({
  4241 + kdf: OpenSSLKdf
  4242 + }),
  4243 +
  4244 + /**
  4245 + * Encrypts a message using a password.
  4246 + *
  4247 + * @param {Cipher} cipher The cipher algorithm to use.
  4248 + * @param {WordArray|string} message The message to encrypt.
  4249 + * @param {string} password The password.
  4250 + * @param {Object} cfg (Optional) The configuration options to use for this operation.
  4251 + *
  4252 + * @return {CipherParams} A cipher params object.
  4253 + *
  4254 + * @static
  4255 + *
  4256 + * @example
  4257 + *
  4258 + * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password');
  4259 + * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password', { format: CryptoJS.format.OpenSSL });
  4260 + */
  4261 + encrypt: function (cipher, message, password, cfg) {
  4262 + // Apply config defaults
  4263 + cfg = this.cfg.extend(cfg);
  4264 +
  4265 + // Derive key and other params
  4266 + var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize);
  4267 +
  4268 + // Add IV to config
  4269 + cfg.iv = derivedParams.iv;
  4270 +
  4271 + // Encrypt
  4272 + var ciphertext = SerializableCipher.encrypt.call(this, cipher, message, derivedParams.key, cfg);
  4273 +
  4274 + // Mix in derived params
  4275 + ciphertext.mixIn(derivedParams);
  4276 +
  4277 + return ciphertext;
  4278 + },
  4279 +
  4280 + /**
  4281 + * Decrypts serialized ciphertext using a password.
  4282 + *
  4283 + * @param {Cipher} cipher The cipher algorithm to use.
  4284 + * @param {CipherParams|string} ciphertext The ciphertext to decrypt.
  4285 + * @param {string} password The password.
  4286 + * @param {Object} cfg (Optional) The configuration options to use for this operation.
  4287 + *
  4288 + * @return {WordArray} The plaintext.
  4289 + *
  4290 + * @static
  4291 + *
  4292 + * @example
  4293 + *
  4294 + * var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, 'password', { format: CryptoJS.format.OpenSSL });
  4295 + * var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, 'password', { format: CryptoJS.format.OpenSSL });
  4296 + */
  4297 + decrypt: function (cipher, ciphertext, password, cfg) {
  4298 + // Apply config defaults
  4299 + cfg = this.cfg.extend(cfg);
  4300 +
  4301 + // Convert string to CipherParams
  4302 + ciphertext = this._parse(ciphertext, cfg.format);
  4303 +
  4304 + // Derive key and other params
  4305 + var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize, ciphertext.salt);
  4306 +
  4307 + // Add IV to config
  4308 + cfg.iv = derivedParams.iv;
  4309 +
  4310 + // Decrypt
  4311 + var plaintext = SerializableCipher.decrypt.call(this, cipher, ciphertext, derivedParams.key, cfg);
  4312 +
  4313 + return plaintext;
  4314 + }
  4315 + });
  4316 + }());
  4317 +
  4318 +
  4319 + /**
  4320 + * Cipher Feedback block mode.
  4321 + */
  4322 + CryptoJS.mode.CFB = (function () {
  4323 + var CFB = CryptoJS.lib.BlockCipherMode.extend();
  4324 +
  4325 + CFB.Encryptor = CFB.extend({
  4326 + processBlock: function (words, offset) {
  4327 + // Shortcuts
  4328 + var cipher = this._cipher;
  4329 + var blockSize = cipher.blockSize;
  4330 +
  4331 + generateKeystreamAndEncrypt.call(this, words, offset, blockSize, cipher);
  4332 +
  4333 + // Remember this block to use with next block
  4334 + this._prevBlock = words.slice(offset, offset + blockSize);
  4335 + }
  4336 + });
  4337 +
  4338 + CFB.Decryptor = CFB.extend({
  4339 + processBlock: function (words, offset) {
  4340 + // Shortcuts
  4341 + var cipher = this._cipher;
  4342 + var blockSize = cipher.blockSize;
  4343 +
  4344 + // Remember this block to use with next block
  4345 + var thisBlock = words.slice(offset, offset + blockSize);
  4346 +
  4347 + generateKeystreamAndEncrypt.call(this, words, offset, blockSize, cipher);
  4348 +
  4349 + // This block becomes the previous block
  4350 + this._prevBlock = thisBlock;
  4351 + }
  4352 + });
  4353 +
  4354 + function generateKeystreamAndEncrypt(words, offset, blockSize, cipher) {
  4355 + var keystream;
  4356 +
  4357 + // Shortcut
  4358 + var iv = this._iv;
  4359 +
  4360 + // Generate keystream
  4361 + if (iv) {
  4362 + keystream = iv.slice(0);
  4363 +
  4364 + // Remove IV for subsequent blocks
  4365 + this._iv = undefined;
  4366 + } else {
  4367 + keystream = this._prevBlock;
  4368 + }
  4369 + cipher.encryptBlock(keystream, 0);
  4370 +
  4371 + // Encrypt
  4372 + for (var i = 0; i < blockSize; i++) {
  4373 + words[offset + i] ^= keystream[i];
  4374 + }
  4375 + }
  4376 +
  4377 + return CFB;
  4378 + }());
  4379 +
  4380 +
  4381 + /**
  4382 + * Counter block mode.
  4383 + */
  4384 + CryptoJS.mode.CTR = (function () {
  4385 + var CTR = CryptoJS.lib.BlockCipherMode.extend();
  4386 +
  4387 + var Encryptor = CTR.Encryptor = CTR.extend({
  4388 + processBlock: function (words, offset) {
  4389 + // Shortcuts
  4390 + var cipher = this._cipher
  4391 + var blockSize = cipher.blockSize;
  4392 + var iv = this._iv;
  4393 + var counter = this._counter;
  4394 +
  4395 + // Generate keystream
  4396 + if (iv) {
  4397 + counter = this._counter = iv.slice(0);
  4398 +
  4399 + // Remove IV for subsequent blocks
  4400 + this._iv = undefined;
  4401 + }
  4402 + var keystream = counter.slice(0);
  4403 + cipher.encryptBlock(keystream, 0);
  4404 +
  4405 + // Increment counter
  4406 + counter[blockSize - 1] = (counter[blockSize - 1] + 1) | 0
  4407 +
  4408 + // Encrypt
  4409 + for (var i = 0; i < blockSize; i++) {
  4410 + words[offset + i] ^= keystream[i];
  4411 + }
  4412 + }
  4413 + });
  4414 +
  4415 + CTR.Decryptor = Encryptor;
  4416 +
  4417 + return CTR;
  4418 + }());
  4419 +
  4420 +
  4421 + /** @preserve
  4422 + * Counter block mode compatible with Dr Brian Gladman fileenc.c
  4423 + * derived from CryptoJS.mode.CTR
  4424 + * Jan Hruby jhruby.web@gmail.com
  4425 + */
  4426 + CryptoJS.mode.CTRGladman = (function () {
  4427 + var CTRGladman = CryptoJS.lib.BlockCipherMode.extend();
  4428 +
  4429 + function incWord(word)
  4430 + {
  4431 + if (((word >> 24) & 0xff) === 0xff) { //overflow
  4432 + var b1 = (word >> 16)&0xff;
  4433 + var b2 = (word >> 8)&0xff;
  4434 + var b3 = word & 0xff;
  4435 +
  4436 + if (b1 === 0xff) // overflow b1
  4437 + {
  4438 + b1 = 0;
  4439 + if (b2 === 0xff)
  4440 + {
  4441 + b2 = 0;
  4442 + if (b3 === 0xff)
  4443 + {
  4444 + b3 = 0;
  4445 + }
  4446 + else
  4447 + {
  4448 + ++b3;
  4449 + }
  4450 + }
  4451 + else
  4452 + {
  4453 + ++b2;
  4454 + }
  4455 + }
  4456 + else
  4457 + {
  4458 + ++b1;
  4459 + }
  4460 +
  4461 + word = 0;
  4462 + word += (b1 << 16);
  4463 + word += (b2 << 8);
  4464 + word += b3;
  4465 + }
  4466 + else
  4467 + {
  4468 + word += (0x01 << 24);
  4469 + }
  4470 + return word;
  4471 + }
  4472 +
  4473 + function incCounter(counter)
  4474 + {
  4475 + if ((counter[0] = incWord(counter[0])) === 0)
  4476 + {
  4477 + // encr_data in fileenc.c from Dr Brian Gladman's counts only with DWORD j < 8
  4478 + counter[1] = incWord(counter[1]);
  4479 + }
  4480 + return counter;
  4481 + }
  4482 +
  4483 + var Encryptor = CTRGladman.Encryptor = CTRGladman.extend({
  4484 + processBlock: function (words, offset) {
  4485 + // Shortcuts
  4486 + var cipher = this._cipher
  4487 + var blockSize = cipher.blockSize;
  4488 + var iv = this._iv;
  4489 + var counter = this._counter;
  4490 +
  4491 + // Generate keystream
  4492 + if (iv) {
  4493 + counter = this._counter = iv.slice(0);
  4494 +
  4495 + // Remove IV for subsequent blocks
  4496 + this._iv = undefined;
  4497 + }
  4498 +
  4499 + incCounter(counter);
  4500 +
  4501 + var keystream = counter.slice(0);
  4502 + cipher.encryptBlock(keystream, 0);
  4503 +
  4504 + // Encrypt
  4505 + for (var i = 0; i < blockSize; i++) {
  4506 + words[offset + i] ^= keystream[i];
  4507 + }
  4508 + }
  4509 + });
  4510 +
  4511 + CTRGladman.Decryptor = Encryptor;
  4512 +
  4513 + return CTRGladman;
  4514 + }());
  4515 +
  4516 +
  4517 +
  4518 +
  4519 + /**
  4520 + * Output Feedback block mode.
  4521 + */
  4522 + CryptoJS.mode.OFB = (function () {
  4523 + var OFB = CryptoJS.lib.BlockCipherMode.extend();
  4524 +
  4525 + var Encryptor = OFB.Encryptor = OFB.extend({
  4526 + processBlock: function (words, offset) {
  4527 + // Shortcuts
  4528 + var cipher = this._cipher
  4529 + var blockSize = cipher.blockSize;
  4530 + var iv = this._iv;
  4531 + var keystream = this._keystream;
  4532 +
  4533 + // Generate keystream
  4534 + if (iv) {
  4535 + keystream = this._keystream = iv.slice(0);
  4536 +
  4537 + // Remove IV for subsequent blocks
  4538 + this._iv = undefined;
  4539 + }
  4540 + cipher.encryptBlock(keystream, 0);
  4541 +
  4542 + // Encrypt
  4543 + for (var i = 0; i < blockSize; i++) {
  4544 + words[offset + i] ^= keystream[i];
  4545 + }
  4546 + }
  4547 + });
  4548 +
  4549 + OFB.Decryptor = Encryptor;
  4550 +
  4551 + return OFB;
  4552 + }());
  4553 +
  4554 +
  4555 + /**
  4556 + * Electronic Codebook block mode.
  4557 + */
  4558 + CryptoJS.mode.ECB = (function () {
  4559 + var ECB = CryptoJS.lib.BlockCipherMode.extend();
  4560 +
  4561 + ECB.Encryptor = ECB.extend({
  4562 + processBlock: function (words, offset) {
  4563 + this._cipher.encryptBlock(words, offset);
  4564 + }
  4565 + });
  4566 +
  4567 + ECB.Decryptor = ECB.extend({
  4568 + processBlock: function (words, offset) {
  4569 + this._cipher.decryptBlock(words, offset);
  4570 + }
  4571 + });
  4572 +
  4573 + return ECB;
  4574 + }());
  4575 +
  4576 +
  4577 + /**
  4578 + * ANSI X.923 padding strategy.
  4579 + */
  4580 + CryptoJS.pad.AnsiX923 = {
  4581 + pad: function (data, blockSize) {
  4582 + // Shortcuts
  4583 + var dataSigBytes = data.sigBytes;
  4584 + var blockSizeBytes = blockSize * 4;
  4585 +
  4586 + // Count padding bytes
  4587 + var nPaddingBytes = blockSizeBytes - dataSigBytes % blockSizeBytes;
  4588 +
  4589 + // Compute last byte position
  4590 + var lastBytePos = dataSigBytes + nPaddingBytes - 1;
  4591 +
  4592 + // Pad
  4593 + data.clamp();
  4594 + data.words[lastBytePos >>> 2] |= nPaddingBytes << (24 - (lastBytePos % 4) * 8);
  4595 + data.sigBytes += nPaddingBytes;
  4596 + },
  4597 +
  4598 + unpad: function (data) {
  4599 + // Get number of padding bytes from last byte
  4600 + var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;
  4601 +
  4602 + // Remove padding
  4603 + data.sigBytes -= nPaddingBytes;
  4604 + }
  4605 + };
  4606 +
  4607 +
  4608 + /**
  4609 + * ISO 10126 padding strategy.
  4610 + */
  4611 + CryptoJS.pad.Iso10126 = {
  4612 + pad: function (data, blockSize) {
  4613 + // Shortcut
  4614 + var blockSizeBytes = blockSize * 4;
  4615 +
  4616 + // Count padding bytes
  4617 + var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes;
  4618 +
  4619 + // Pad
  4620 + data.concat(CryptoJS.lib.WordArray.random(nPaddingBytes - 1)).
  4621 + concat(CryptoJS.lib.WordArray.create([nPaddingBytes << 24], 1));
  4622 + },
  4623 +
  4624 + unpad: function (data) {
  4625 + // Get number of padding bytes from last byte
  4626 + var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;
  4627 +
  4628 + // Remove padding
  4629 + data.sigBytes -= nPaddingBytes;
  4630 + }
  4631 + };
  4632 +
  4633 +
  4634 + /**
  4635 + * ISO/IEC 9797-1 Padding Method 2.
  4636 + */
  4637 + CryptoJS.pad.Iso97971 = {
  4638 + pad: function (data, blockSize) {
  4639 + // Add 0x80 byte
  4640 + data.concat(CryptoJS.lib.WordArray.create([0x80000000], 1));
  4641 +
  4642 + // Zero pad the rest
  4643 + CryptoJS.pad.ZeroPadding.pad(data, blockSize);
  4644 + },
  4645 +
  4646 + unpad: function (data) {
  4647 + // Remove zero padding
  4648 + CryptoJS.pad.ZeroPadding.unpad(data);
  4649 +
  4650 + // Remove one more byte -- the 0x80 byte
  4651 + data.sigBytes--;
  4652 + }
  4653 + };
  4654 +
  4655 +
  4656 + /**
  4657 + * Zero padding strategy.
  4658 + */
  4659 + CryptoJS.pad.ZeroPadding = {
  4660 + pad: function (data, blockSize) {
  4661 + // Shortcut
  4662 + var blockSizeBytes = blockSize * 4;
  4663 +
  4664 + // Pad
  4665 + data.clamp();
  4666 + data.sigBytes += blockSizeBytes - ((data.sigBytes % blockSizeBytes) || blockSizeBytes);
  4667 + },
  4668 +
  4669 + unpad: function (data) {
  4670 + // Shortcut
  4671 + var dataWords = data.words;
  4672 +
  4673 + // Unpad
  4674 + var i = data.sigBytes - 1;
  4675 + for (var i = data.sigBytes - 1; i >= 0; i--) {
  4676 + if (((dataWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff)) {
  4677 + data.sigBytes = i + 1;
  4678 + break;
  4679 + }
  4680 + }
  4681 + }
  4682 + };
  4683 +
  4684 +
  4685 + /**
  4686 + * A noop padding strategy.
  4687 + */
  4688 + CryptoJS.pad.NoPadding = {
  4689 + pad: function () {
  4690 + },
  4691 +
  4692 + unpad: function () {
  4693 + }
  4694 + };
  4695 +
  4696 +
  4697 + (function (undefined) {
  4698 + // Shortcuts
  4699 + var C = CryptoJS;
  4700 + var C_lib = C.lib;
  4701 + var CipherParams = C_lib.CipherParams;
  4702 + var C_enc = C.enc;
  4703 + var Hex = C_enc.Hex;
  4704 + var C_format = C.format;
  4705 +
  4706 + var HexFormatter = C_format.Hex = {
  4707 + /**
  4708 + * Converts the ciphertext of a cipher params object to a hexadecimally encoded string.
  4709 + *
  4710 + * @param {CipherParams} cipherParams The cipher params object.
  4711 + *
  4712 + * @return {string} The hexadecimally encoded string.
  4713 + *
  4714 + * @static
  4715 + *
  4716 + * @example
  4717 + *
  4718 + * var hexString = CryptoJS.format.Hex.stringify(cipherParams);
  4719 + */
  4720 + stringify: function (cipherParams) {
  4721 + return cipherParams.ciphertext.toString(Hex);
  4722 + },
  4723 +
  4724 + /**
  4725 + * Converts a hexadecimally encoded ciphertext string to a cipher params object.
  4726 + *
  4727 + * @param {string} input The hexadecimally encoded string.
  4728 + *
  4729 + * @return {CipherParams} The cipher params object.
  4730 + *
  4731 + * @static
  4732 + *
  4733 + * @example
  4734 + *
  4735 + * var cipherParams = CryptoJS.format.Hex.parse(hexString);
  4736 + */
  4737 + parse: function (input) {
  4738 + var ciphertext = Hex.parse(input);
  4739 + return CipherParams.create({ ciphertext: ciphertext });
  4740 + }
  4741 + };
  4742 + }());
  4743 +
  4744 +
  4745 + (function () {
  4746 + // Shortcuts
  4747 + var C = CryptoJS;
  4748 + var C_lib = C.lib;
  4749 + var BlockCipher = C_lib.BlockCipher;
  4750 + var C_algo = C.algo;
  4751 +
  4752 + // Lookup tables
  4753 + var SBOX = [];
  4754 + var INV_SBOX = [];
  4755 + var SUB_MIX_0 = [];
  4756 + var SUB_MIX_1 = [];
  4757 + var SUB_MIX_2 = [];
  4758 + var SUB_MIX_3 = [];
  4759 + var INV_SUB_MIX_0 = [];
  4760 + var INV_SUB_MIX_1 = [];
  4761 + var INV_SUB_MIX_2 = [];
  4762 + var INV_SUB_MIX_3 = [];
  4763 +
  4764 + // Compute lookup tables
  4765 + (function () {
  4766 + // Compute double table
  4767 + var d = [];
  4768 + for (var i = 0; i < 256; i++) {
  4769 + if (i < 128) {
  4770 + d[i] = i << 1;
  4771 + } else {
  4772 + d[i] = (i << 1) ^ 0x11b;
  4773 + }
  4774 + }
  4775 +
  4776 + // Walk GF(2^8)
  4777 + var x = 0;
  4778 + var xi = 0;
  4779 + for (var i = 0; i < 256; i++) {
  4780 + // Compute sbox
  4781 + var sx = xi ^ (xi << 1) ^ (xi << 2) ^ (xi << 3) ^ (xi << 4);
  4782 + sx = (sx >>> 8) ^ (sx & 0xff) ^ 0x63;
  4783 + SBOX[x] = sx;
  4784 + INV_SBOX[sx] = x;
  4785 +
  4786 + // Compute multiplication
  4787 + var x2 = d[x];
  4788 + var x4 = d[x2];
  4789 + var x8 = d[x4];
  4790 +
  4791 + // Compute sub bytes, mix columns tables
  4792 + var t = (d[sx] * 0x101) ^ (sx * 0x1010100);
  4793 + SUB_MIX_0[x] = (t << 24) | (t >>> 8);
  4794 + SUB_MIX_1[x] = (t << 16) | (t >>> 16);
  4795 + SUB_MIX_2[x] = (t << 8) | (t >>> 24);
  4796 + SUB_MIX_3[x] = t;
  4797 +
  4798 + // Compute inv sub bytes, inv mix columns tables
  4799 + var t = (x8 * 0x1010101) ^ (x4 * 0x10001) ^ (x2 * 0x101) ^ (x * 0x1010100);
  4800 + INV_SUB_MIX_0[sx] = (t << 24) | (t >>> 8);
  4801 + INV_SUB_MIX_1[sx] = (t << 16) | (t >>> 16);
  4802 + INV_SUB_MIX_2[sx] = (t << 8) | (t >>> 24);
  4803 + INV_SUB_MIX_3[sx] = t;
  4804 +
  4805 + // Compute next counter
  4806 + if (!x) {
  4807 + x = xi = 1;
  4808 + } else {
  4809 + x = x2 ^ d[d[d[x8 ^ x2]]];
  4810 + xi ^= d[d[xi]];
  4811 + }
  4812 + }
  4813 + }());
  4814 +
  4815 + // Precomputed Rcon lookup
  4816 + var RCON = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36];
  4817 +
  4818 + /**
  4819 + * AES block cipher algorithm.
  4820 + */
  4821 + var AES = C_algo.AES = BlockCipher.extend({
  4822 + _doReset: function () {
  4823 + var t;
  4824 +
  4825 + // Skip reset of nRounds has been set before and key did not change
  4826 + if (this._nRounds && this._keyPriorReset === this._key) {
  4827 + return;
  4828 + }
  4829 +
  4830 + // Shortcuts
  4831 + var key = this._keyPriorReset = this._key;
  4832 + var keyWords = key.words;
  4833 + var keySize = key.sigBytes / 4;
  4834 +
  4835 + // Compute number of rounds
  4836 + var nRounds = this._nRounds = keySize + 6;
  4837 +
  4838 + // Compute number of key schedule rows
  4839 + var ksRows = (nRounds + 1) * 4;
  4840 +
  4841 + // Compute key schedule
  4842 + var keySchedule = this._keySchedule = [];
  4843 + for (var ksRow = 0; ksRow < ksRows; ksRow++) {
  4844 + if (ksRow < keySize) {
  4845 + keySchedule[ksRow] = keyWords[ksRow];
  4846 + } else {
  4847 + t = keySchedule[ksRow - 1];
  4848 +
  4849 + if (!(ksRow % keySize)) {
  4850 + // Rot word
  4851 + t = (t << 8) | (t >>> 24);
  4852 +
  4853 + // Sub word
  4854 + t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff];
  4855 +
  4856 + // Mix Rcon
  4857 + t ^= RCON[(ksRow / keySize) | 0] << 24;
  4858 + } else if (keySize > 6 && ksRow % keySize == 4) {
  4859 + // Sub word
  4860 + t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff];
  4861 + }
  4862 +
  4863 + keySchedule[ksRow] = keySchedule[ksRow - keySize] ^ t;
  4864 + }
  4865 + }
  4866 +
  4867 + // Compute inv key schedule
  4868 + var invKeySchedule = this._invKeySchedule = [];
  4869 + for (var invKsRow = 0; invKsRow < ksRows; invKsRow++) {
  4870 + var ksRow = ksRows - invKsRow;
  4871 +
  4872 + if (invKsRow % 4) {
  4873 + var t = keySchedule[ksRow];
  4874 + } else {
  4875 + var t = keySchedule[ksRow - 4];
  4876 + }
  4877 +
  4878 + if (invKsRow < 4 || ksRow <= 4) {
  4879 + invKeySchedule[invKsRow] = t;
  4880 + } else {
  4881 + invKeySchedule[invKsRow] = INV_SUB_MIX_0[SBOX[t >>> 24]] ^ INV_SUB_MIX_1[SBOX[(t >>> 16) & 0xff]] ^
  4882 + INV_SUB_MIX_2[SBOX[(t >>> 8) & 0xff]] ^ INV_SUB_MIX_3[SBOX[t & 0xff]];
  4883 + }
  4884 + }
  4885 + },
  4886 +
  4887 + encryptBlock: function (M, offset) {
  4888 + this._doCryptBlock(M, offset, this._keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX);
  4889 + },
  4890 +
  4891 + decryptBlock: function (M, offset) {
  4892 + // Swap 2nd and 4th rows
  4893 + var t = M[offset + 1];
  4894 + M[offset + 1] = M[offset + 3];
  4895 + M[offset + 3] = t;
  4896 +
  4897 + this._doCryptBlock(M, offset, this._invKeySchedule, INV_SUB_MIX_0, INV_SUB_MIX_1, INV_SUB_MIX_2, INV_SUB_MIX_3, INV_SBOX);
  4898 +
  4899 + // Inv swap 2nd and 4th rows
  4900 + var t = M[offset + 1];
  4901 + M[offset + 1] = M[offset + 3];
  4902 + M[offset + 3] = t;
  4903 + },
  4904 +
  4905 + _doCryptBlock: function (M, offset, keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX) {
  4906 + // Shortcut
  4907 + var nRounds = this._nRounds;
  4908 +
  4909 + // Get input, add round key
  4910 + var s0 = M[offset] ^ keySchedule[0];
  4911 + var s1 = M[offset + 1] ^ keySchedule[1];
  4912 + var s2 = M[offset + 2] ^ keySchedule[2];
  4913 + var s3 = M[offset + 3] ^ keySchedule[3];
  4914 +
  4915 + // Key schedule row counter
  4916 + var ksRow = 4;
  4917 +
  4918 + // Rounds
  4919 + for (var round = 1; round < nRounds; round++) {
  4920 + // Shift rows, sub bytes, mix columns, add round key
  4921 + var t0 = SUB_MIX_0[s0 >>> 24] ^ SUB_MIX_1[(s1 >>> 16) & 0xff] ^ SUB_MIX_2[(s2 >>> 8) & 0xff] ^ SUB_MIX_3[s3 & 0xff] ^ keySchedule[ksRow++];
  4922 + var t1 = SUB_MIX_0[s1 >>> 24] ^ SUB_MIX_1[(s2 >>> 16) & 0xff] ^ SUB_MIX_2[(s3 >>> 8) & 0xff] ^ SUB_MIX_3[s0 & 0xff] ^ keySchedule[ksRow++];
  4923 + var t2 = SUB_MIX_0[s2 >>> 24] ^ SUB_MIX_1[(s3 >>> 16) & 0xff] ^ SUB_MIX_2[(s0 >>> 8) & 0xff] ^ SUB_MIX_3[s1 & 0xff] ^ keySchedule[ksRow++];
  4924 + var t3 = SUB_MIX_0[s3 >>> 24] ^ SUB_MIX_1[(s0 >>> 16) & 0xff] ^ SUB_MIX_2[(s1 >>> 8) & 0xff] ^ SUB_MIX_3[s2 & 0xff] ^ keySchedule[ksRow++];
  4925 +
  4926 + // Update state
  4927 + s0 = t0;
  4928 + s1 = t1;
  4929 + s2 = t2;
  4930 + s3 = t3;
  4931 + }
  4932 +
  4933 + // Shift rows, sub bytes, add round key
  4934 + var t0 = ((SBOX[s0 >>> 24] << 24) | (SBOX[(s1 >>> 16) & 0xff] << 16) | (SBOX[(s2 >>> 8) & 0xff] << 8) | SBOX[s3 & 0xff]) ^ keySchedule[ksRow++];
  4935 + var t1 = ((SBOX[s1 >>> 24] << 24) | (SBOX[(s2 >>> 16) & 0xff] << 16) | (SBOX[(s3 >>> 8) & 0xff] << 8) | SBOX[s0 & 0xff]) ^ keySchedule[ksRow++];
  4936 + var t2 = ((SBOX[s2 >>> 24] << 24) | (SBOX[(s3 >>> 16) & 0xff] << 16) | (SBOX[(s0 >>> 8) & 0xff] << 8) | SBOX[s1 & 0xff]) ^ keySchedule[ksRow++];
  4937 + var t3 = ((SBOX[s3 >>> 24] << 24) | (SBOX[(s0 >>> 16) & 0xff] << 16) | (SBOX[(s1 >>> 8) & 0xff] << 8) | SBOX[s2 & 0xff]) ^ keySchedule[ksRow++];
  4938 +
  4939 + // Set output
  4940 + M[offset] = t0;
  4941 + M[offset + 1] = t1;
  4942 + M[offset + 2] = t2;
  4943 + M[offset + 3] = t3;
  4944 + },
  4945 +
  4946 + keySize: 256/32
  4947 + });
  4948 +
  4949 + /**
  4950 + * Shortcut functions to the cipher's object interface.
  4951 + *
  4952 + * @example
  4953 + *
  4954 + * var ciphertext = CryptoJS.AES.encrypt(message, key, cfg);
  4955 + * var plaintext = CryptoJS.AES.decrypt(ciphertext, key, cfg);
  4956 + */
  4957 + C.AES = BlockCipher._createHelper(AES);
  4958 + }());
  4959 +
  4960 +
  4961 + (function () {
  4962 + // Shortcuts
  4963 + var C = CryptoJS;
  4964 + var C_lib = C.lib;
  4965 + var WordArray = C_lib.WordArray;
  4966 + var BlockCipher = C_lib.BlockCipher;
  4967 + var C_algo = C.algo;
  4968 +
  4969 + // Permuted Choice 1 constants
  4970 + var PC1 = [
  4971 + 57, 49, 41, 33, 25, 17, 9, 1,
  4972 + 58, 50, 42, 34, 26, 18, 10, 2,
  4973 + 59, 51, 43, 35, 27, 19, 11, 3,
  4974 + 60, 52, 44, 36, 63, 55, 47, 39,
  4975 + 31, 23, 15, 7, 62, 54, 46, 38,
  4976 + 30, 22, 14, 6, 61, 53, 45, 37,
  4977 + 29, 21, 13, 5, 28, 20, 12, 4
  4978 + ];
  4979 +
  4980 + // Permuted Choice 2 constants
  4981 + var PC2 = [
  4982 + 14, 17, 11, 24, 1, 5,
  4983 + 3, 28, 15, 6, 21, 10,
  4984 + 23, 19, 12, 4, 26, 8,
  4985 + 16, 7, 27, 20, 13, 2,
  4986 + 41, 52, 31, 37, 47, 55,
  4987 + 30, 40, 51, 45, 33, 48,
  4988 + 44, 49, 39, 56, 34, 53,
  4989 + 46, 42, 50, 36, 29, 32
  4990 + ];
  4991 +
  4992 + // Cumulative bit shift constants
  4993 + var BIT_SHIFTS = [1, 2, 4, 6, 8, 10, 12, 14, 15, 17, 19, 21, 23, 25, 27, 28];
  4994 +
  4995 + // SBOXes and round permutation constants
  4996 + var SBOX_P = [
  4997 + {
  4998 + 0x0: 0x808200,
  4999 + 0x10000000: 0x8000,
  5000 + 0x20000000: 0x808002,
  5001 + 0x30000000: 0x2,
  5002 + 0x40000000: 0x200,
  5003 + 0x50000000: 0x808202,
  5004 + 0x60000000: 0x800202,
  5005 + 0x70000000: 0x800000,
  5006 + 0x80000000: 0x202,
  5007 + 0x90000000: 0x800200,
  5008 + 0xa0000000: 0x8200,
  5009 + 0xb0000000: 0x808000,
  5010 + 0xc0000000: 0x8002,
  5011 + 0xd0000000: 0x800002,
  5012 + 0xe0000000: 0x0,
  5013 + 0xf0000000: 0x8202,
  5014 + 0x8000000: 0x0,
  5015 + 0x18000000: 0x808202,
  5016 + 0x28000000: 0x8202,
  5017 + 0x38000000: 0x8000,
  5018 + 0x48000000: 0x808200,
  5019 + 0x58000000: 0x200,
  5020 + 0x68000000: 0x808002,
  5021 + 0x78000000: 0x2,
  5022 + 0x88000000: 0x800200,
  5023 + 0x98000000: 0x8200,
  5024 + 0xa8000000: 0x808000,
  5025 + 0xb8000000: 0x800202,
  5026 + 0xc8000000: 0x800002,
  5027 + 0xd8000000: 0x8002,
  5028 + 0xe8000000: 0x202,
  5029 + 0xf8000000: 0x800000,
  5030 + 0x1: 0x8000,
  5031 + 0x10000001: 0x2,
  5032 + 0x20000001: 0x808200,
  5033 + 0x30000001: 0x800000,
  5034 + 0x40000001: 0x808002,
  5035 + 0x50000001: 0x8200,
  5036 + 0x60000001: 0x200,
  5037 + 0x70000001: 0x800202,
  5038 + 0x80000001: 0x808202,
  5039 + 0x90000001: 0x808000,
  5040 + 0xa0000001: 0x800002,
  5041 + 0xb0000001: 0x8202,
  5042 + 0xc0000001: 0x202,
  5043 + 0xd0000001: 0x800200,
  5044 + 0xe0000001: 0x8002,
  5045 + 0xf0000001: 0x0,
  5046 + 0x8000001: 0x808202,
  5047 + 0x18000001: 0x808000,
  5048 + 0x28000001: 0x800000,
  5049 + 0x38000001: 0x200,
  5050 + 0x48000001: 0x8000,
  5051 + 0x58000001: 0x800002,
  5052 + 0x68000001: 0x2,
  5053 + 0x78000001: 0x8202,
  5054 + 0x88000001: 0x8002,
  5055 + 0x98000001: 0x800202,
  5056 + 0xa8000001: 0x202,
  5057 + 0xb8000001: 0x808200,
  5058 + 0xc8000001: 0x800200,
  5059 + 0xd8000001: 0x0,
  5060 + 0xe8000001: 0x8200,
  5061 + 0xf8000001: 0x808002
  5062 + },
  5063 + {
  5064 + 0x0: 0x40084010,
  5065 + 0x1000000: 0x4000,
  5066 + 0x2000000: 0x80000,
  5067 + 0x3000000: 0x40080010,
  5068 + 0x4000000: 0x40000010,
  5069 + 0x5000000: 0x40084000,
  5070 + 0x6000000: 0x40004000,
  5071 + 0x7000000: 0x10,
  5072 + 0x8000000: 0x84000,
  5073 + 0x9000000: 0x40004010,
  5074 + 0xa000000: 0x40000000,
  5075 + 0xb000000: 0x84010,
  5076 + 0xc000000: 0x80010,
  5077 + 0xd000000: 0x0,
  5078 + 0xe000000: 0x4010,
  5079 + 0xf000000: 0x40080000,
  5080 + 0x800000: 0x40004000,
  5081 + 0x1800000: 0x84010,
  5082 + 0x2800000: 0x10,
  5083 + 0x3800000: 0x40004010,
  5084 + 0x4800000: 0x40084010,
  5085 + 0x5800000: 0x40000000,
  5086 + 0x6800000: 0x80000,
  5087 + 0x7800000: 0x40080010,
  5088 + 0x8800000: 0x80010,
  5089 + 0x9800000: 0x0,
  5090 + 0xa800000: 0x4000,
  5091 + 0xb800000: 0x40080000,
  5092 + 0xc800000: 0x40000010,
  5093 + 0xd800000: 0x84000,
  5094 + 0xe800000: 0x40084000,
  5095 + 0xf800000: 0x4010,
  5096 + 0x10000000: 0x0,
  5097 + 0x11000000: 0x40080010,
  5098 + 0x12000000: 0x40004010,
  5099 + 0x13000000: 0x40084000,
  5100 + 0x14000000: 0x40080000,
  5101 + 0x15000000: 0x10,
  5102 + 0x16000000: 0x84010,
  5103 + 0x17000000: 0x4000,
  5104 + 0x18000000: 0x4010,
  5105 + 0x19000000: 0x80000,
  5106 + 0x1a000000: 0x80010,
  5107 + 0x1b000000: 0x40000010,
  5108 + 0x1c000000: 0x84000,
  5109 + 0x1d000000: 0x40004000,
  5110 + 0x1e000000: 0x40000000,
  5111 + 0x1f000000: 0x40084010,
  5112 + 0x10800000: 0x84010,
  5113 + 0x11800000: 0x80000,
  5114 + 0x12800000: 0x40080000,
  5115 + 0x13800000: 0x4000,
  5116 + 0x14800000: 0x40004000,
  5117 + 0x15800000: 0x40084010,
  5118 + 0x16800000: 0x10,
  5119 + 0x17800000: 0x40000000,
  5120 + 0x18800000: 0x40084000,
  5121 + 0x19800000: 0x40000010,
  5122 + 0x1a800000: 0x40004010,
  5123 + 0x1b800000: 0x80010,
  5124 + 0x1c800000: 0x0,
  5125 + 0x1d800000: 0x4010,
  5126 + 0x1e800000: 0x40080010,
  5127 + 0x1f800000: 0x84000
  5128 + },
  5129 + {
  5130 + 0x0: 0x104,
  5131 + 0x100000: 0x0,
  5132 + 0x200000: 0x4000100,
  5133 + 0x300000: 0x10104,
  5134 + 0x400000: 0x10004,
  5135 + 0x500000: 0x4000004,
  5136 + 0x600000: 0x4010104,
  5137 + 0x700000: 0x4010000,
  5138 + 0x800000: 0x4000000,
  5139 + 0x900000: 0x4010100,
  5140 + 0xa00000: 0x10100,
  5141 + 0xb00000: 0x4010004,
  5142 + 0xc00000: 0x4000104,
  5143 + 0xd00000: 0x10000,
  5144 + 0xe00000: 0x4,
  5145 + 0xf00000: 0x100,
  5146 + 0x80000: 0x4010100,
  5147 + 0x180000: 0x4010004,
  5148 + 0x280000: 0x0,
  5149 + 0x380000: 0x4000100,
  5150 + 0x480000: 0x4000004,
  5151 + 0x580000: 0x10000,
  5152 + 0x680000: 0x10004,
  5153 + 0x780000: 0x104,
  5154 + 0x880000: 0x4,
  5155 + 0x980000: 0x100,
  5156 + 0xa80000: 0x4010000,
  5157 + 0xb80000: 0x10104,
  5158 + 0xc80000: 0x10100,
  5159 + 0xd80000: 0x4000104,
  5160 + 0xe80000: 0x4010104,
  5161 + 0xf80000: 0x4000000,
  5162 + 0x1000000: 0x4010100,
  5163 + 0x1100000: 0x10004,
  5164 + 0x1200000: 0x10000,
  5165 + 0x1300000: 0x4000100,
  5166 + 0x1400000: 0x100,
  5167 + 0x1500000: 0x4010104,
  5168 + 0x1600000: 0x4000004,
  5169 + 0x1700000: 0x0,
  5170 + 0x1800000: 0x4000104,
  5171 + 0x1900000: 0x4000000,
  5172 + 0x1a00000: 0x4,
  5173 + 0x1b00000: 0x10100,
  5174 + 0x1c00000: 0x4010000,
  5175 + 0x1d00000: 0x104,
  5176 + 0x1e00000: 0x10104,
  5177 + 0x1f00000: 0x4010004,
  5178 + 0x1080000: 0x4000000,
  5179 + 0x1180000: 0x104,
  5180 + 0x1280000: 0x4010100,
  5181 + 0x1380000: 0x0,
  5182 + 0x1480000: 0x10004,
  5183 + 0x1580000: 0x4000100,
  5184 + 0x1680000: 0x100,
  5185 + 0x1780000: 0x4010004,
  5186 + 0x1880000: 0x10000,
  5187 + 0x1980000: 0x4010104,
  5188 + 0x1a80000: 0x10104,
  5189 + 0x1b80000: 0x4000004,
  5190 + 0x1c80000: 0x4000104,
  5191 + 0x1d80000: 0x4010000,
  5192 + 0x1e80000: 0x4,
  5193 + 0x1f80000: 0x10100
  5194 + },
  5195 + {
  5196 + 0x0: 0x80401000,
  5197 + 0x10000: 0x80001040,
  5198 + 0x20000: 0x401040,
  5199 + 0x30000: 0x80400000,
  5200 + 0x40000: 0x0,
  5201 + 0x50000: 0x401000,
  5202 + 0x60000: 0x80000040,
  5203 + 0x70000: 0x400040,
  5204 + 0x80000: 0x80000000,
  5205 + 0x90000: 0x400000,
  5206 + 0xa0000: 0x40,
  5207 + 0xb0000: 0x80001000,
  5208 + 0xc0000: 0x80400040,
  5209 + 0xd0000: 0x1040,
  5210 + 0xe0000: 0x1000,
  5211 + 0xf0000: 0x80401040,
  5212 + 0x8000: 0x80001040,
  5213 + 0x18000: 0x40,
  5214 + 0x28000: 0x80400040,
  5215 + 0x38000: 0x80001000,
  5216 + 0x48000: 0x401000,
  5217 + 0x58000: 0x80401040,
  5218 + 0x68000: 0x0,
  5219 + 0x78000: 0x80400000,
  5220 + 0x88000: 0x1000,
  5221 + 0x98000: 0x80401000,
  5222 + 0xa8000: 0x400000,
  5223 + 0xb8000: 0x1040,
  5224 + 0xc8000: 0x80000000,
  5225 + 0xd8000: 0x400040,
  5226 + 0xe8000: 0x401040,
  5227 + 0xf8000: 0x80000040,
  5228 + 0x100000: 0x400040,
  5229 + 0x110000: 0x401000,
  5230 + 0x120000: 0x80000040,
  5231 + 0x130000: 0x0,
  5232 + 0x140000: 0x1040,
  5233 + 0x150000: 0x80400040,
  5234 + 0x160000: 0x80401000,
  5235 + 0x170000: 0x80001040,
  5236 + 0x180000: 0x80401040,
  5237 + 0x190000: 0x80000000,
  5238 + 0x1a0000: 0x80400000,
  5239 + 0x1b0000: 0x401040,
  5240 + 0x1c0000: 0x80001000,
  5241 + 0x1d0000: 0x400000,
  5242 + 0x1e0000: 0x40,
  5243 + 0x1f0000: 0x1000,
  5244 + 0x108000: 0x80400000,
  5245 + 0x118000: 0x80401040,
  5246 + 0x128000: 0x0,
  5247 + 0x138000: 0x401000,
  5248 + 0x148000: 0x400040,
  5249 + 0x158000: 0x80000000,
  5250 + 0x168000: 0x80001040,
  5251 + 0x178000: 0x40,
  5252 + 0x188000: 0x80000040,
  5253 + 0x198000: 0x1000,
  5254 + 0x1a8000: 0x80001000,
  5255 + 0x1b8000: 0x80400040,
  5256 + 0x1c8000: 0x1040,
  5257 + 0x1d8000: 0x80401000,
  5258 + 0x1e8000: 0x400000,
  5259 + 0x1f8000: 0x401040
  5260 + },
  5261 + {
  5262 + 0x0: 0x80,
  5263 + 0x1000: 0x1040000,
  5264 + 0x2000: 0x40000,
  5265 + 0x3000: 0x20000000,
  5266 + 0x4000: 0x20040080,
  5267 + 0x5000: 0x1000080,
  5268 + 0x6000: 0x21000080,
  5269 + 0x7000: 0x40080,
  5270 + 0x8000: 0x1000000,
  5271 + 0x9000: 0x20040000,
  5272 + 0xa000: 0x20000080,
  5273 + 0xb000: 0x21040080,
  5274 + 0xc000: 0x21040000,
  5275 + 0xd000: 0x0,
  5276 + 0xe000: 0x1040080,
  5277 + 0xf000: 0x21000000,
  5278 + 0x800: 0x1040080,
  5279 + 0x1800: 0x21000080,
  5280 + 0x2800: 0x80,
  5281 + 0x3800: 0x1040000,
  5282 + 0x4800: 0x40000,
  5283 + 0x5800: 0x20040080,
  5284 + 0x6800: 0x21040000,
  5285 + 0x7800: 0x20000000,
  5286 + 0x8800: 0x20040000,
  5287 + 0x9800: 0x0,
  5288 + 0xa800: 0x21040080,
  5289 + 0xb800: 0x1000080,
  5290 + 0xc800: 0x20000080,
  5291 + 0xd800: 0x21000000,
  5292 + 0xe800: 0x1000000,
  5293 + 0xf800: 0x40080,
  5294 + 0x10000: 0x40000,
  5295 + 0x11000: 0x80,
  5296 + 0x12000: 0x20000000,
  5297 + 0x13000: 0x21000080,
  5298 + 0x14000: 0x1000080,
  5299 + 0x15000: 0x21040000,
  5300 + 0x16000: 0x20040080,
  5301 + 0x17000: 0x1000000,
  5302 + 0x18000: 0x21040080,
  5303 + 0x19000: 0x21000000,
  5304 + 0x1a000: 0x1040000,
  5305 + 0x1b000: 0x20040000,
  5306 + 0x1c000: 0x40080,
  5307 + 0x1d000: 0x20000080,
  5308 + 0x1e000: 0x0,
  5309 + 0x1f000: 0x1040080,
  5310 + 0x10800: 0x21000080,
  5311 + 0x11800: 0x1000000,
  5312 + 0x12800: 0x1040000,
  5313 + 0x13800: 0x20040080,
  5314 + 0x14800: 0x20000000,
  5315 + 0x15800: 0x1040080,
  5316 + 0x16800: 0x80,
  5317 + 0x17800: 0x21040000,
  5318 + 0x18800: 0x40080,
  5319 + 0x19800: 0x21040080,
  5320 + 0x1a800: 0x0,
  5321 + 0x1b800: 0x21000000,
  5322 + 0x1c800: 0x1000080,
  5323 + 0x1d800: 0x40000,
  5324 + 0x1e800: 0x20040000,
  5325 + 0x1f800: 0x20000080
  5326 + },
  5327 + {
  5328 + 0x0: 0x10000008,
  5329 + 0x100: 0x2000,
  5330 + 0x200: 0x10200000,
  5331 + 0x300: 0x10202008,
  5332 + 0x400: 0x10002000,
  5333 + 0x500: 0x200000,
  5334 + 0x600: 0x200008,
  5335 + 0x700: 0x10000000,
  5336 + 0x800: 0x0,
  5337 + 0x900: 0x10002008,
  5338 + 0xa00: 0x202000,
  5339 + 0xb00: 0x8,
  5340 + 0xc00: 0x10200008,
  5341 + 0xd00: 0x202008,
  5342 + 0xe00: 0x2008,
  5343 + 0xf00: 0x10202000,
  5344 + 0x80: 0x10200000,
  5345 + 0x180: 0x10202008,
  5346 + 0x280: 0x8,
  5347 + 0x380: 0x200000,
  5348 + 0x480: 0x202008,
  5349 + 0x580: 0x10000008,
  5350 + 0x680: 0x10002000,
  5351 + 0x780: 0x2008,
  5352 + 0x880: 0x200008,
  5353 + 0x980: 0x2000,
  5354 + 0xa80: 0x10002008,
  5355 + 0xb80: 0x10200008,
  5356 + 0xc80: 0x0,
  5357 + 0xd80: 0x10202000,
  5358 + 0xe80: 0x202000,
  5359 + 0xf80: 0x10000000,
  5360 + 0x1000: 0x10002000,
  5361 + 0x1100: 0x10200008,
  5362 + 0x1200: 0x10202008,
  5363 + 0x1300: 0x2008,
  5364 + 0x1400: 0x200000,
  5365 + 0x1500: 0x10000000,
  5366 + 0x1600: 0x10000008,
  5367 + 0x1700: 0x202000,
  5368 + 0x1800: 0x202008,
  5369 + 0x1900: 0x0,
  5370 + 0x1a00: 0x8,
  5371 + 0x1b00: 0x10200000,
  5372 + 0x1c00: 0x2000,
  5373 + 0x1d00: 0x10002008,
  5374 + 0x1e00: 0x10202000,
  5375 + 0x1f00: 0x200008,
  5376 + 0x1080: 0x8,
  5377 + 0x1180: 0x202000,
  5378 + 0x1280: 0x200000,
  5379 + 0x1380: 0x10000008,
  5380 + 0x1480: 0x10002000,
  5381 + 0x1580: 0x2008,
  5382 + 0x1680: 0x10202008,
  5383 + 0x1780: 0x10200000,
  5384 + 0x1880: 0x10202000,
  5385 + 0x1980: 0x10200008,
  5386 + 0x1a80: 0x2000,
  5387 + 0x1b80: 0x202008,
  5388 + 0x1c80: 0x200008,
  5389 + 0x1d80: 0x0,
  5390 + 0x1e80: 0x10000000,
  5391 + 0x1f80: 0x10002008
  5392 + },
  5393 + {
  5394 + 0x0: 0x100000,
  5395 + 0x10: 0x2000401,
  5396 + 0x20: 0x400,
  5397 + 0x30: 0x100401,
  5398 + 0x40: 0x2100401,
  5399 + 0x50: 0x0,
  5400 + 0x60: 0x1,
  5401 + 0x70: 0x2100001,
  5402 + 0x80: 0x2000400,
  5403 + 0x90: 0x100001,
  5404 + 0xa0: 0x2000001,
  5405 + 0xb0: 0x2100400,
  5406 + 0xc0: 0x2100000,
  5407 + 0xd0: 0x401,
  5408 + 0xe0: 0x100400,
  5409 + 0xf0: 0x2000000,
  5410 + 0x8: 0x2100001,
  5411 + 0x18: 0x0,
  5412 + 0x28: 0x2000401,
  5413 + 0x38: 0x2100400,
  5414 + 0x48: 0x100000,
  5415 + 0x58: 0x2000001,
  5416 + 0x68: 0x2000000,
  5417 + 0x78: 0x401,
  5418 + 0x88: 0x100401,
  5419 + 0x98: 0x2000400,
  5420 + 0xa8: 0x2100000,
  5421 + 0xb8: 0x100001,
  5422 + 0xc8: 0x400,
  5423 + 0xd8: 0x2100401,
  5424 + 0xe8: 0x1,
  5425 + 0xf8: 0x100400,
  5426 + 0x100: 0x2000000,
  5427 + 0x110: 0x100000,
  5428 + 0x120: 0x2000401,
  5429 + 0x130: 0x2100001,
  5430 + 0x140: 0x100001,
  5431 + 0x150: 0x2000400,
  5432 + 0x160: 0x2100400,
  5433 + 0x170: 0x100401,
  5434 + 0x180: 0x401,
  5435 + 0x190: 0x2100401,
  5436 + 0x1a0: 0x100400,
  5437 + 0x1b0: 0x1,
  5438 + 0x1c0: 0x0,
  5439 + 0x1d0: 0x2100000,
  5440 + 0x1e0: 0x2000001,
  5441 + 0x1f0: 0x400,
  5442 + 0x108: 0x100400,
  5443 + 0x118: 0x2000401,
  5444 + 0x128: 0x2100001,
  5445 + 0x138: 0x1,
  5446 + 0x148: 0x2000000,
  5447 + 0x158: 0x100000,
  5448 + 0x168: 0x401,
  5449 + 0x178: 0x2100400,
  5450 + 0x188: 0x2000001,
  5451 + 0x198: 0x2100000,
  5452 + 0x1a8: 0x0,
  5453 + 0x1b8: 0x2100401,
  5454 + 0x1c8: 0x100401,
  5455 + 0x1d8: 0x400,
  5456 + 0x1e8: 0x2000400,
  5457 + 0x1f8: 0x100001
  5458 + },
  5459 + {
  5460 + 0x0: 0x8000820,
  5461 + 0x1: 0x20000,
  5462 + 0x2: 0x8000000,
  5463 + 0x3: 0x20,
  5464 + 0x4: 0x20020,
  5465 + 0x5: 0x8020820,
  5466 + 0x6: 0x8020800,
  5467 + 0x7: 0x800,
  5468 + 0x8: 0x8020000,
  5469 + 0x9: 0x8000800,
  5470 + 0xa: 0x20800,
  5471 + 0xb: 0x8020020,
  5472 + 0xc: 0x820,
  5473 + 0xd: 0x0,
  5474 + 0xe: 0x8000020,
  5475 + 0xf: 0x20820,
  5476 + 0x80000000: 0x800,
  5477 + 0x80000001: 0x8020820,
  5478 + 0x80000002: 0x8000820,
  5479 + 0x80000003: 0x8000000,
  5480 + 0x80000004: 0x8020000,
  5481 + 0x80000005: 0x20800,
  5482 + 0x80000006: 0x20820,
  5483 + 0x80000007: 0x20,
  5484 + 0x80000008: 0x8000020,
  5485 + 0x80000009: 0x820,
  5486 + 0x8000000a: 0x20020,
  5487 + 0x8000000b: 0x8020800,
  5488 + 0x8000000c: 0x0,
  5489 + 0x8000000d: 0x8020020,
  5490 + 0x8000000e: 0x8000800,
  5491 + 0x8000000f: 0x20000,
  5492 + 0x10: 0x20820,
  5493 + 0x11: 0x8020800,
  5494 + 0x12: 0x20,
  5495 + 0x13: 0x800,
  5496 + 0x14: 0x8000800,
  5497 + 0x15: 0x8000020,
  5498 + 0x16: 0x8020020,
  5499 + 0x17: 0x20000,
  5500 + 0x18: 0x0,
  5501 + 0x19: 0x20020,
  5502 + 0x1a: 0x8020000,
  5503 + 0x1b: 0x8000820,
  5504 + 0x1c: 0x8020820,
  5505 + 0x1d: 0x20800,
  5506 + 0x1e: 0x820,
  5507 + 0x1f: 0x8000000,
  5508 + 0x80000010: 0x20000,
  5509 + 0x80000011: 0x800,
  5510 + 0x80000012: 0x8020020,
  5511 + 0x80000013: 0x20820,
  5512 + 0x80000014: 0x20,
  5513 + 0x80000015: 0x8020000,
  5514 + 0x80000016: 0x8000000,
  5515 + 0x80000017: 0x8000820,
  5516 + 0x80000018: 0x8020820,
  5517 + 0x80000019: 0x8000020,
  5518 + 0x8000001a: 0x8000800,
  5519 + 0x8000001b: 0x0,
  5520 + 0x8000001c: 0x20800,
  5521 + 0x8000001d: 0x820,
  5522 + 0x8000001e: 0x20020,
  5523 + 0x8000001f: 0x8020800
  5524 + }
  5525 + ];
  5526 +
  5527 + // Masks that select the SBOX input
  5528 + var SBOX_MASK = [
  5529 + 0xf8000001, 0x1f800000, 0x01f80000, 0x001f8000,
  5530 + 0x0001f800, 0x00001f80, 0x000001f8, 0x8000001f
  5531 + ];
  5532 +
  5533 + /**
  5534 + * DES block cipher algorithm.
  5535 + */
  5536 + var DES = C_algo.DES = BlockCipher.extend({
  5537 + _doReset: function () {
  5538 + // Shortcuts
  5539 + var key = this._key;
  5540 + var keyWords = key.words;
  5541 +
  5542 + // Select 56 bits according to PC1
  5543 + var keyBits = [];
  5544 + for (var i = 0; i < 56; i++) {
  5545 + var keyBitPos = PC1[i] - 1;
  5546 + keyBits[i] = (keyWords[keyBitPos >>> 5] >>> (31 - keyBitPos % 32)) & 1;
  5547 + }
  5548 +
  5549 + // Assemble 16 subkeys
  5550 + var subKeys = this._subKeys = [];
  5551 + for (var nSubKey = 0; nSubKey < 16; nSubKey++) {
  5552 + // Create subkey
  5553 + var subKey = subKeys[nSubKey] = [];
  5554 +
  5555 + // Shortcut
  5556 + var bitShift = BIT_SHIFTS[nSubKey];
  5557 +
  5558 + // Select 48 bits according to PC2
  5559 + for (var i = 0; i < 24; i++) {
  5560 + // Select from the left 28 key bits
  5561 + subKey[(i / 6) | 0] |= keyBits[((PC2[i] - 1) + bitShift) % 28] << (31 - i % 6);
  5562 +
  5563 + // Select from the right 28 key bits
  5564 + subKey[4 + ((i / 6) | 0)] |= keyBits[28 + (((PC2[i + 24] - 1) + bitShift) % 28)] << (31 - i % 6);
  5565 + }
  5566 +
  5567 + // Since each subkey is applied to an expanded 32-bit input,
  5568 + // the subkey can be broken into 8 values scaled to 32-bits,
  5569 + // which allows the key to be used without expansion
  5570 + subKey[0] = (subKey[0] << 1) | (subKey[0] >>> 31);
  5571 + for (var i = 1; i < 7; i++) {
  5572 + subKey[i] = subKey[i] >>> ((i - 1) * 4 + 3);
  5573 + }
  5574 + subKey[7] = (subKey[7] << 5) | (subKey[7] >>> 27);
  5575 + }
  5576 +
  5577 + // Compute inverse subkeys
  5578 + var invSubKeys = this._invSubKeys = [];
  5579 + for (var i = 0; i < 16; i++) {
  5580 + invSubKeys[i] = subKeys[15 - i];
  5581 + }
  5582 + },
  5583 +
  5584 + encryptBlock: function (M, offset) {
  5585 + this._doCryptBlock(M, offset, this._subKeys);
  5586 + },
  5587 +
  5588 + decryptBlock: function (M, offset) {
  5589 + this._doCryptBlock(M, offset, this._invSubKeys);
  5590 + },
  5591 +
  5592 + _doCryptBlock: function (M, offset, subKeys) {
  5593 + // Get input
  5594 + this._lBlock = M[offset];
  5595 + this._rBlock = M[offset + 1];
  5596 +
  5597 + // Initial permutation
  5598 + exchangeLR.call(this, 4, 0x0f0f0f0f);
  5599 + exchangeLR.call(this, 16, 0x0000ffff);
  5600 + exchangeRL.call(this, 2, 0x33333333);
  5601 + exchangeRL.call(this, 8, 0x00ff00ff);
  5602 + exchangeLR.call(this, 1, 0x55555555);
  5603 +
  5604 + // Rounds
  5605 + for (var round = 0; round < 16; round++) {
  5606 + // Shortcuts
  5607 + var subKey = subKeys[round];
  5608 + var lBlock = this._lBlock;
  5609 + var rBlock = this._rBlock;
  5610 +
  5611 + // Feistel function
  5612 + var f = 0;
  5613 + for (var i = 0; i < 8; i++) {
  5614 + f |= SBOX_P[i][((rBlock ^ subKey[i]) & SBOX_MASK[i]) >>> 0];
  5615 + }
  5616 + this._lBlock = rBlock;
  5617 + this._rBlock = lBlock ^ f;
  5618 + }
  5619 +
  5620 + // Undo swap from last round
  5621 + var t = this._lBlock;
  5622 + this._lBlock = this._rBlock;
  5623 + this._rBlock = t;
  5624 +
  5625 + // Final permutation
  5626 + exchangeLR.call(this, 1, 0x55555555);
  5627 + exchangeRL.call(this, 8, 0x00ff00ff);
  5628 + exchangeRL.call(this, 2, 0x33333333);
  5629 + exchangeLR.call(this, 16, 0x0000ffff);
  5630 + exchangeLR.call(this, 4, 0x0f0f0f0f);
  5631 +
  5632 + // Set output
  5633 + M[offset] = this._lBlock;
  5634 + M[offset + 1] = this._rBlock;
  5635 + },
  5636 +
  5637 + keySize: 64/32,
  5638 +
  5639 + ivSize: 64/32,
  5640 +
  5641 + blockSize: 64/32
  5642 + });
  5643 +
  5644 + // Swap bits across the left and right words
  5645 + function exchangeLR(offset, mask) {
  5646 + var t = ((this._lBlock >>> offset) ^ this._rBlock) & mask;
  5647 + this._rBlock ^= t;
  5648 + this._lBlock ^= t << offset;
  5649 + }
  5650 +
  5651 + function exchangeRL(offset, mask) {
  5652 + var t = ((this._rBlock >>> offset) ^ this._lBlock) & mask;
  5653 + this._lBlock ^= t;
  5654 + this._rBlock ^= t << offset;
  5655 + }
  5656 +
  5657 + /**
  5658 + * Shortcut functions to the cipher's object interface.
  5659 + *
  5660 + * @example
  5661 + *
  5662 + * var ciphertext = CryptoJS.DES.encrypt(message, key, cfg);
  5663 + * var plaintext = CryptoJS.DES.decrypt(ciphertext, key, cfg);
  5664 + */
  5665 + C.DES = BlockCipher._createHelper(DES);
  5666 +
  5667 + /**
  5668 + * Triple-DES block cipher algorithm.
  5669 + */
  5670 + var TripleDES = C_algo.TripleDES = BlockCipher.extend({
  5671 + _doReset: function () {
  5672 + // Shortcuts
  5673 + var key = this._key;
  5674 + var keyWords = key.words;
  5675 + // Make sure the key length is valid (64, 128 or >= 192 bit)
  5676 + if (keyWords.length !== 2 && keyWords.length !== 4 && keyWords.length < 6) {
  5677 + throw new Error('Invalid key length - 3DES requires the key length to be 64, 128, 192 or >192.');
  5678 + }
  5679 +
  5680 + // Extend the key according to the keying options defined in 3DES standard
  5681 + var key1 = keyWords.slice(0, 2);
  5682 + var key2 = keyWords.length < 4 ? keyWords.slice(0, 2) : keyWords.slice(2, 4);
  5683 + var key3 = keyWords.length < 6 ? keyWords.slice(0, 2) : keyWords.slice(4, 6);
  5684 +
  5685 + // Create DES instances
  5686 + this._des1 = DES.createEncryptor(WordArray.create(key1));
  5687 + this._des2 = DES.createEncryptor(WordArray.create(key2));
  5688 + this._des3 = DES.createEncryptor(WordArray.create(key3));
  5689 + },
  5690 +
  5691 + encryptBlock: function (M, offset) {
  5692 + this._des1.encryptBlock(M, offset);
  5693 + this._des2.decryptBlock(M, offset);
  5694 + this._des3.encryptBlock(M, offset);
  5695 + },
  5696 +
  5697 + decryptBlock: function (M, offset) {
  5698 + this._des3.decryptBlock(M, offset);
  5699 + this._des2.encryptBlock(M, offset);
  5700 + this._des1.decryptBlock(M, offset);
  5701 + },
  5702 +
  5703 + keySize: 192/32,
  5704 +
  5705 + ivSize: 64/32,
  5706 +
  5707 + blockSize: 64/32
  5708 + });
  5709 +
  5710 + /**
  5711 + * Shortcut functions to the cipher's object interface.
  5712 + *
  5713 + * @example
  5714 + *
  5715 + * var ciphertext = CryptoJS.TripleDES.encrypt(message, key, cfg);
  5716 + * var plaintext = CryptoJS.TripleDES.decrypt(ciphertext, key, cfg);
  5717 + */
  5718 + C.TripleDES = BlockCipher._createHelper(TripleDES);
  5719 + }());
  5720 +
  5721 +
  5722 + (function () {
  5723 + // Shortcuts
  5724 + var C = CryptoJS;
  5725 + var C_lib = C.lib;
  5726 + var StreamCipher = C_lib.StreamCipher;
  5727 + var C_algo = C.algo;
  5728 +
  5729 + /**
  5730 + * RC4 stream cipher algorithm.
  5731 + */
  5732 + var RC4 = C_algo.RC4 = StreamCipher.extend({
  5733 + _doReset: function () {
  5734 + // Shortcuts
  5735 + var key = this._key;
  5736 + var keyWords = key.words;
  5737 + var keySigBytes = key.sigBytes;
  5738 +
  5739 + // Init sbox
  5740 + var S = this._S = [];
  5741 + for (var i = 0; i < 256; i++) {
  5742 + S[i] = i;
  5743 + }
  5744 +
  5745 + // Key setup
  5746 + for (var i = 0, j = 0; i < 256; i++) {
  5747 + var keyByteIndex = i % keySigBytes;
  5748 + var keyByte = (keyWords[keyByteIndex >>> 2] >>> (24 - (keyByteIndex % 4) * 8)) & 0xff;
  5749 +
  5750 + j = (j + S[i] + keyByte) % 256;
  5751 +
  5752 + // Swap
  5753 + var t = S[i];
  5754 + S[i] = S[j];
  5755 + S[j] = t;
  5756 + }
  5757 +
  5758 + // Counters
  5759 + this._i = this._j = 0;
  5760 + },
  5761 +
  5762 + _doProcessBlock: function (M, offset) {
  5763 + M[offset] ^= generateKeystreamWord.call(this);
  5764 + },
  5765 +
  5766 + keySize: 256/32,
  5767 +
  5768 + ivSize: 0
  5769 + });
  5770 +
  5771 + function generateKeystreamWord() {
  5772 + // Shortcuts
  5773 + var S = this._S;
  5774 + var i = this._i;
  5775 + var j = this._j;
  5776 +
  5777 + // Generate keystream word
  5778 + var keystreamWord = 0;
  5779 + for (var n = 0; n < 4; n++) {
  5780 + i = (i + 1) % 256;
  5781 + j = (j + S[i]) % 256;
  5782 +
  5783 + // Swap
  5784 + var t = S[i];
  5785 + S[i] = S[j];
  5786 + S[j] = t;
  5787 +
  5788 + keystreamWord |= S[(S[i] + S[j]) % 256] << (24 - n * 8);
  5789 + }
  5790 +
  5791 + // Update counters
  5792 + this._i = i;
  5793 + this._j = j;
  5794 +
  5795 + return keystreamWord;
  5796 + }
  5797 +
  5798 + /**
  5799 + * Shortcut functions to the cipher's object interface.
  5800 + *
  5801 + * @example
  5802 + *
  5803 + * var ciphertext = CryptoJS.RC4.encrypt(message, key, cfg);
  5804 + * var plaintext = CryptoJS.RC4.decrypt(ciphertext, key, cfg);
  5805 + */
  5806 + C.RC4 = StreamCipher._createHelper(RC4);
  5807 +
  5808 + /**
  5809 + * Modified RC4 stream cipher algorithm.
  5810 + */
  5811 + var RC4Drop = C_algo.RC4Drop = RC4.extend({
  5812 + /**
  5813 + * Configuration options.
  5814 + *
  5815 + * @property {number} drop The number of keystream words to drop. Default 192
  5816 + */
  5817 + cfg: RC4.cfg.extend({
  5818 + drop: 192
  5819 + }),
  5820 +
  5821 + _doReset: function () {
  5822 + RC4._doReset.call(this);
  5823 +
  5824 + // Drop
  5825 + for (var i = this.cfg.drop; i > 0; i--) {
  5826 + generateKeystreamWord.call(this);
  5827 + }
  5828 + }
  5829 + });
  5830 +
  5831 + /**
  5832 + * Shortcut functions to the cipher's object interface.
  5833 + *
  5834 + * @example
  5835 + *
  5836 + * var ciphertext = CryptoJS.RC4Drop.encrypt(message, key, cfg);
  5837 + * var plaintext = CryptoJS.RC4Drop.decrypt(ciphertext, key, cfg);
  5838 + */
  5839 + C.RC4Drop = StreamCipher._createHelper(RC4Drop);
  5840 + }());
  5841 +
  5842 +
  5843 + (function () {
  5844 + // Shortcuts
  5845 + var C = CryptoJS;
  5846 + var C_lib = C.lib;
  5847 + var StreamCipher = C_lib.StreamCipher;
  5848 + var C_algo = C.algo;
  5849 +
  5850 + // Reusable objects
  5851 + var S = [];
  5852 + var C_ = [];
  5853 + var G = [];
  5854 +
  5855 + /**
  5856 + * Rabbit stream cipher algorithm
  5857 + */
  5858 + var Rabbit = C_algo.Rabbit = StreamCipher.extend({
  5859 + _doReset: function () {
  5860 + // Shortcuts
  5861 + var K = this._key.words;
  5862 + var iv = this.cfg.iv;
  5863 +
  5864 + // Swap endian
  5865 + for (var i = 0; i < 4; i++) {
  5866 + K[i] = (((K[i] << 8) | (K[i] >>> 24)) & 0x00ff00ff) |
  5867 + (((K[i] << 24) | (K[i] >>> 8)) & 0xff00ff00);
  5868 + }
  5869 +
  5870 + // Generate initial state values
  5871 + var X = this._X = [
  5872 + K[0], (K[3] << 16) | (K[2] >>> 16),
  5873 + K[1], (K[0] << 16) | (K[3] >>> 16),
  5874 + K[2], (K[1] << 16) | (K[0] >>> 16),
  5875 + K[3], (K[2] << 16) | (K[1] >>> 16)
  5876 + ];
  5877 +
  5878 + // Generate initial counter values
  5879 + var C = this._C = [
  5880 + (K[2] << 16) | (K[2] >>> 16), (K[0] & 0xffff0000) | (K[1] & 0x0000ffff),
  5881 + (K[3] << 16) | (K[3] >>> 16), (K[1] & 0xffff0000) | (K[2] & 0x0000ffff),
  5882 + (K[0] << 16) | (K[0] >>> 16), (K[2] & 0xffff0000) | (K[3] & 0x0000ffff),
  5883 + (K[1] << 16) | (K[1] >>> 16), (K[3] & 0xffff0000) | (K[0] & 0x0000ffff)
  5884 + ];
  5885 +
  5886 + // Carry bit
  5887 + this._b = 0;
  5888 +
  5889 + // Iterate the system four times
  5890 + for (var i = 0; i < 4; i++) {
  5891 + nextState.call(this);
  5892 + }
  5893 +
  5894 + // Modify the counters
  5895 + for (var i = 0; i < 8; i++) {
  5896 + C[i] ^= X[(i + 4) & 7];
  5897 + }
  5898 +
  5899 + // IV setup
  5900 + if (iv) {
  5901 + // Shortcuts
  5902 + var IV = iv.words;
  5903 + var IV_0 = IV[0];
  5904 + var IV_1 = IV[1];
  5905 +
  5906 + // Generate four subvectors
  5907 + var i0 = (((IV_0 << 8) | (IV_0 >>> 24)) & 0x00ff00ff) | (((IV_0 << 24) | (IV_0 >>> 8)) & 0xff00ff00);
  5908 + var i2 = (((IV_1 << 8) | (IV_1 >>> 24)) & 0x00ff00ff) | (((IV_1 << 24) | (IV_1 >>> 8)) & 0xff00ff00);
  5909 + var i1 = (i0 >>> 16) | (i2 & 0xffff0000);
  5910 + var i3 = (i2 << 16) | (i0 & 0x0000ffff);
  5911 +
  5912 + // Modify counter values
  5913 + C[0] ^= i0;
  5914 + C[1] ^= i1;
  5915 + C[2] ^= i2;
  5916 + C[3] ^= i3;
  5917 + C[4] ^= i0;
  5918 + C[5] ^= i1;
  5919 + C[6] ^= i2;
  5920 + C[7] ^= i3;
  5921 +
  5922 + // Iterate the system four times
  5923 + for (var i = 0; i < 4; i++) {
  5924 + nextState.call(this);
  5925 + }
  5926 + }
  5927 + },
  5928 +
  5929 + _doProcessBlock: function (M, offset) {
  5930 + // Shortcut
  5931 + var X = this._X;
  5932 +
  5933 + // Iterate the system
  5934 + nextState.call(this);
  5935 +
  5936 + // Generate four keystream words
  5937 + S[0] = X[0] ^ (X[5] >>> 16) ^ (X[3] << 16);
  5938 + S[1] = X[2] ^ (X[7] >>> 16) ^ (X[5] << 16);
  5939 + S[2] = X[4] ^ (X[1] >>> 16) ^ (X[7] << 16);
  5940 + S[3] = X[6] ^ (X[3] >>> 16) ^ (X[1] << 16);
  5941 +
  5942 + for (var i = 0; i < 4; i++) {
  5943 + // Swap endian
  5944 + S[i] = (((S[i] << 8) | (S[i] >>> 24)) & 0x00ff00ff) |
  5945 + (((S[i] << 24) | (S[i] >>> 8)) & 0xff00ff00);
  5946 +
  5947 + // Encrypt
  5948 + M[offset + i] ^= S[i];
  5949 + }
  5950 + },
  5951 +
  5952 + blockSize: 128/32,
  5953 +
  5954 + ivSize: 64/32
  5955 + });
  5956 +
  5957 + function nextState() {
  5958 + // Shortcuts
  5959 + var X = this._X;
  5960 + var C = this._C;
  5961 +
  5962 + // Save old counter values
  5963 + for (var i = 0; i < 8; i++) {
  5964 + C_[i] = C[i];
  5965 + }
  5966 +
  5967 + // Calculate new counter values
  5968 + C[0] = (C[0] + 0x4d34d34d + this._b) | 0;
  5969 + C[1] = (C[1] + 0xd34d34d3 + ((C[0] >>> 0) < (C_[0] >>> 0) ? 1 : 0)) | 0;
  5970 + C[2] = (C[2] + 0x34d34d34 + ((C[1] >>> 0) < (C_[1] >>> 0) ? 1 : 0)) | 0;
  5971 + C[3] = (C[3] + 0x4d34d34d + ((C[2] >>> 0) < (C_[2] >>> 0) ? 1 : 0)) | 0;
  5972 + C[4] = (C[4] + 0xd34d34d3 + ((C[3] >>> 0) < (C_[3] >>> 0) ? 1 : 0)) | 0;
  5973 + C[5] = (C[5] + 0x34d34d34 + ((C[4] >>> 0) < (C_[4] >>> 0) ? 1 : 0)) | 0;
  5974 + C[6] = (C[6] + 0x4d34d34d + ((C[5] >>> 0) < (C_[5] >>> 0) ? 1 : 0)) | 0;
  5975 + C[7] = (C[7] + 0xd34d34d3 + ((C[6] >>> 0) < (C_[6] >>> 0) ? 1 : 0)) | 0;
  5976 + this._b = (C[7] >>> 0) < (C_[7] >>> 0) ? 1 : 0;
  5977 +
  5978 + // Calculate the g-values
  5979 + for (var i = 0; i < 8; i++) {
  5980 + var gx = X[i] + C[i];
  5981 +
  5982 + // Construct high and low argument for squaring
  5983 + var ga = gx & 0xffff;
  5984 + var gb = gx >>> 16;
  5985 +
  5986 + // Calculate high and low result of squaring
  5987 + var gh = ((((ga * ga) >>> 17) + ga * gb) >>> 15) + gb * gb;
  5988 + var gl = (((gx & 0xffff0000) * gx) | 0) + (((gx & 0x0000ffff) * gx) | 0);
  5989 +
  5990 + // High XOR low
  5991 + G[i] = gh ^ gl;
  5992 + }
  5993 +
  5994 + // Calculate new state values
  5995 + X[0] = (G[0] + ((G[7] << 16) | (G[7] >>> 16)) + ((G[6] << 16) | (G[6] >>> 16))) | 0;
  5996 + X[1] = (G[1] + ((G[0] << 8) | (G[0] >>> 24)) + G[7]) | 0;
  5997 + X[2] = (G[2] + ((G[1] << 16) | (G[1] >>> 16)) + ((G[0] << 16) | (G[0] >>> 16))) | 0;
  5998 + X[3] = (G[3] + ((G[2] << 8) | (G[2] >>> 24)) + G[1]) | 0;
  5999 + X[4] = (G[4] + ((G[3] << 16) | (G[3] >>> 16)) + ((G[2] << 16) | (G[2] >>> 16))) | 0;
  6000 + X[5] = (G[5] + ((G[4] << 8) | (G[4] >>> 24)) + G[3]) | 0;
  6001 + X[6] = (G[6] + ((G[5] << 16) | (G[5] >>> 16)) + ((G[4] << 16) | (G[4] >>> 16))) | 0;
  6002 + X[7] = (G[7] + ((G[6] << 8) | (G[6] >>> 24)) + G[5]) | 0;
  6003 + }
  6004 +
  6005 + /**
  6006 + * Shortcut functions to the cipher's object interface.
  6007 + *
  6008 + * @example
  6009 + *
  6010 + * var ciphertext = CryptoJS.Rabbit.encrypt(message, key, cfg);
  6011 + * var plaintext = CryptoJS.Rabbit.decrypt(ciphertext, key, cfg);
  6012 + */
  6013 + C.Rabbit = StreamCipher._createHelper(Rabbit);
  6014 + }());
  6015 +
  6016 +
  6017 + (function () {
  6018 + // Shortcuts
  6019 + var C = CryptoJS;
  6020 + var C_lib = C.lib;
  6021 + var StreamCipher = C_lib.StreamCipher;
  6022 + var C_algo = C.algo;
  6023 +
  6024 + // Reusable objects
  6025 + var S = [];
  6026 + var C_ = [];
  6027 + var G = [];
  6028 +
  6029 + /**
  6030 + * Rabbit stream cipher algorithm.
  6031 + *
  6032 + * This is a legacy version that neglected to convert the key to little-endian.
  6033 + * This error doesn't affect the cipher's security,
  6034 + * but it does affect its compatibility with other implementations.
  6035 + */
  6036 + var RabbitLegacy = C_algo.RabbitLegacy = StreamCipher.extend({
  6037 + _doReset: function () {
  6038 + // Shortcuts
  6039 + var K = this._key.words;
  6040 + var iv = this.cfg.iv;
  6041 +
  6042 + // Generate initial state values
  6043 + var X = this._X = [
  6044 + K[0], (K[3] << 16) | (K[2] >>> 16),
  6045 + K[1], (K[0] << 16) | (K[3] >>> 16),
  6046 + K[2], (K[1] << 16) | (K[0] >>> 16),
  6047 + K[3], (K[2] << 16) | (K[1] >>> 16)
  6048 + ];
  6049 +
  6050 + // Generate initial counter values
  6051 + var C = this._C = [
  6052 + (K[2] << 16) | (K[2] >>> 16), (K[0] & 0xffff0000) | (K[1] & 0x0000ffff),
  6053 + (K[3] << 16) | (K[3] >>> 16), (K[1] & 0xffff0000) | (K[2] & 0x0000ffff),
  6054 + (K[0] << 16) | (K[0] >>> 16), (K[2] & 0xffff0000) | (K[3] & 0x0000ffff),
  6055 + (K[1] << 16) | (K[1] >>> 16), (K[3] & 0xffff0000) | (K[0] & 0x0000ffff)
  6056 + ];
  6057 +
  6058 + // Carry bit
  6059 + this._b = 0;
  6060 +
  6061 + // Iterate the system four times
  6062 + for (var i = 0; i < 4; i++) {
  6063 + nextState.call(this);
  6064 + }
  6065 +
  6066 + // Modify the counters
  6067 + for (var i = 0; i < 8; i++) {
  6068 + C[i] ^= X[(i + 4) & 7];
  6069 + }
  6070 +
  6071 + // IV setup
  6072 + if (iv) {
  6073 + // Shortcuts
  6074 + var IV = iv.words;
  6075 + var IV_0 = IV[0];
  6076 + var IV_1 = IV[1];
  6077 +
  6078 + // Generate four subvectors
  6079 + var i0 = (((IV_0 << 8) | (IV_0 >>> 24)) & 0x00ff00ff) | (((IV_0 << 24) | (IV_0 >>> 8)) & 0xff00ff00);
  6080 + var i2 = (((IV_1 << 8) | (IV_1 >>> 24)) & 0x00ff00ff) | (((IV_1 << 24) | (IV_1 >>> 8)) & 0xff00ff00);
  6081 + var i1 = (i0 >>> 16) | (i2 & 0xffff0000);
  6082 + var i3 = (i2 << 16) | (i0 & 0x0000ffff);
  6083 +
  6084 + // Modify counter values
  6085 + C[0] ^= i0;
  6086 + C[1] ^= i1;
  6087 + C[2] ^= i2;
  6088 + C[3] ^= i3;
  6089 + C[4] ^= i0;
  6090 + C[5] ^= i1;
  6091 + C[6] ^= i2;
  6092 + C[7] ^= i3;
  6093 +
  6094 + // Iterate the system four times
  6095 + for (var i = 0; i < 4; i++) {
  6096 + nextState.call(this);
  6097 + }
  6098 + }
  6099 + },
  6100 +
  6101 + _doProcessBlock: function (M, offset) {
  6102 + // Shortcut
  6103 + var X = this._X;
  6104 +
  6105 + // Iterate the system
  6106 + nextState.call(this);
  6107 +
  6108 + // Generate four keystream words
  6109 + S[0] = X[0] ^ (X[5] >>> 16) ^ (X[3] << 16);
  6110 + S[1] = X[2] ^ (X[7] >>> 16) ^ (X[5] << 16);
  6111 + S[2] = X[4] ^ (X[1] >>> 16) ^ (X[7] << 16);
  6112 + S[3] = X[6] ^ (X[3] >>> 16) ^ (X[1] << 16);
  6113 +
  6114 + for (var i = 0; i < 4; i++) {
  6115 + // Swap endian
  6116 + S[i] = (((S[i] << 8) | (S[i] >>> 24)) & 0x00ff00ff) |
  6117 + (((S[i] << 24) | (S[i] >>> 8)) & 0xff00ff00);
  6118 +
  6119 + // Encrypt
  6120 + M[offset + i] ^= S[i];
  6121 + }
  6122 + },
  6123 +
  6124 + blockSize: 128/32,
  6125 +
  6126 + ivSize: 64/32
  6127 + });
  6128 +
  6129 + function nextState() {
  6130 + // Shortcuts
  6131 + var X = this._X;
  6132 + var C = this._C;
  6133 +
  6134 + // Save old counter values
  6135 + for (var i = 0; i < 8; i++) {
  6136 + C_[i] = C[i];
  6137 + }
  6138 +
  6139 + // Calculate new counter values
  6140 + C[0] = (C[0] + 0x4d34d34d + this._b) | 0;
  6141 + C[1] = (C[1] + 0xd34d34d3 + ((C[0] >>> 0) < (C_[0] >>> 0) ? 1 : 0)) | 0;
  6142 + C[2] = (C[2] + 0x34d34d34 + ((C[1] >>> 0) < (C_[1] >>> 0) ? 1 : 0)) | 0;
  6143 + C[3] = (C[3] + 0x4d34d34d + ((C[2] >>> 0) < (C_[2] >>> 0) ? 1 : 0)) | 0;
  6144 + C[4] = (C[4] + 0xd34d34d3 + ((C[3] >>> 0) < (C_[3] >>> 0) ? 1 : 0)) | 0;
  6145 + C[5] = (C[5] + 0x34d34d34 + ((C[4] >>> 0) < (C_[4] >>> 0) ? 1 : 0)) | 0;
  6146 + C[6] = (C[6] + 0x4d34d34d + ((C[5] >>> 0) < (C_[5] >>> 0) ? 1 : 0)) | 0;
  6147 + C[7] = (C[7] + 0xd34d34d3 + ((C[6] >>> 0) < (C_[6] >>> 0) ? 1 : 0)) | 0;
  6148 + this._b = (C[7] >>> 0) < (C_[7] >>> 0) ? 1 : 0;
  6149 +
  6150 + // Calculate the g-values
  6151 + for (var i = 0; i < 8; i++) {
  6152 + var gx = X[i] + C[i];
  6153 +
  6154 + // Construct high and low argument for squaring
  6155 + var ga = gx & 0xffff;
  6156 + var gb = gx >>> 16;
  6157 +
  6158 + // Calculate high and low result of squaring
  6159 + var gh = ((((ga * ga) >>> 17) + ga * gb) >>> 15) + gb * gb;
  6160 + var gl = (((gx & 0xffff0000) * gx) | 0) + (((gx & 0x0000ffff) * gx) | 0);
  6161 +
  6162 + // High XOR low
  6163 + G[i] = gh ^ gl;
  6164 + }
  6165 +
  6166 + // Calculate new state values
  6167 + X[0] = (G[0] + ((G[7] << 16) | (G[7] >>> 16)) + ((G[6] << 16) | (G[6] >>> 16))) | 0;
  6168 + X[1] = (G[1] + ((G[0] << 8) | (G[0] >>> 24)) + G[7]) | 0;
  6169 + X[2] = (G[2] + ((G[1] << 16) | (G[1] >>> 16)) + ((G[0] << 16) | (G[0] >>> 16))) | 0;
  6170 + X[3] = (G[3] + ((G[2] << 8) | (G[2] >>> 24)) + G[1]) | 0;
  6171 + X[4] = (G[4] + ((G[3] << 16) | (G[3] >>> 16)) + ((G[2] << 16) | (G[2] >>> 16))) | 0;
  6172 + X[5] = (G[5] + ((G[4] << 8) | (G[4] >>> 24)) + G[3]) | 0;
  6173 + X[6] = (G[6] + ((G[5] << 16) | (G[5] >>> 16)) + ((G[4] << 16) | (G[4] >>> 16))) | 0;
  6174 + X[7] = (G[7] + ((G[6] << 8) | (G[6] >>> 24)) + G[5]) | 0;
  6175 + }
  6176 +
  6177 + /**
  6178 + * Shortcut functions to the cipher's object interface.
  6179 + *
  6180 + * @example
  6181 + *
  6182 + * var ciphertext = CryptoJS.RabbitLegacy.encrypt(message, key, cfg);
  6183 + * var plaintext = CryptoJS.RabbitLegacy.decrypt(ciphertext, key, cfg);
  6184 + */
  6185 + C.RabbitLegacy = StreamCipher._createHelper(RabbitLegacy);
  6186 + }());
  6187 +
  6188 +
  6189 + return CryptoJS;
  6190 +
  6191 +}));