CVE-2023-46233: Use of a Broken or Risky Cryptographic Algorithm (CWE-327)
value: crypto-js is a JavaScript library of crypto standards. Prior to version 4.2.0, crypto-js PBKDF2 is 1,000 times weaker than originally specified in 1993, and at least 1,300,000 times weaker than current industry standard. This is because it both defaults to SHA1, a cryptographic hash algorithm considered insecure since at least 2005, and defaults to one single iteration, a 'strength' or 'difficulty' value specified at 1,000 when specified in 1993. PBKDF2 relies on iteration count as a countermeasure to preimage and collision attacks. If used to protect passwords, the impact is high. If used to generate signatures, the impact is high. Version 4.2.0 contains a patch for this issue. As a workaround, configure crypto-js to use SHA256 with at least 250,000 iterations.
CWE description: The product uses a broken or risky cryptographic algorithm or protocol.
CVSS v3 base score: 9.1
Published: 2023-10-25T21:15Z
Repository: https://github.com/brix/crypto-js
Language: JavaScript
Files changed: .gitignore, .jshintrc, .travis.yml, CONTRIBUTING.md, Gruntfile.js, LICENSE, README.md, docs/QuickStartGuide.wiki, grunt/config/clean.js, grunt/config/copy.js, grunt/config/jshint.js, grunt/config/jsonlint.js, grunt/config/modularize.js, grunt/config/update_json.js, grunt/tasks/modularize.js, package.json, src/aes.js, src/blowfish.js, src/cipher-core.js, src/core.js, src/enc-base64.js, src/enc-base64url.js, src/enc-utf16.js, src/evpkdf.js, src/format-hex.js, src/hmac.js, src/lib-typedarrays.js, src/md5.js, src/mode-cfb.js, src/mode-ctr-gladman.js, src/mode-ctr.js, src/mode-ecb.js, src/mode-ofb.js, src/pad-ansix923.js, src/pad-iso10126.js, src/pad-iso97971.js, src/pad-nopadding.js, src/pad-zeropadding.js, src/pbkdf2.js, src/rabbit-legacy.js, src/rabbit.js, src/rc4.js, src/ripemd160.js, src/sha1.js, src/sha224.js, src/sha256.js, src/sha3.js, src/sha384.js, src/sha512.js, src/tripledes.js, src/x64-core.js, test/aes-profile.js, test/aes-test.js, test/blowfish-test.js, test/cipher-test.js, test/config-test.js, test/des-profile.js, test/des-test.js, test/enc-base64-test.js, test/enc-hex-test.js, test/enc-latin1-test.js, test/enc-utf16-test.js, test/enc-utf8-test.js, test/evpkdf-profile.js, test/evpkdf-test.js, test/format-openssl-test.js, test/hmac-md5-profile.js, test/hmac-md5-test.js, test/hmac-sha224-test.js, test/hmac-sha256-test.js, test/hmac-sha384-test.js, test/hmac-sha512-test.js, test/kdf-openssl-test.js, test/lib-base-test.js, test/lib-cipherparams-test.js, test/lib-passwordbasedcipher-test.js, test/lib-serializablecipher-test.js, test/lib-typedarrays-test.js, test/lib-wordarray-test.js, test/md5-profile.js, test/md5-test.js, test/mode-cbc-test.js, test/mode-cfb-test.js, test/mode-ctr-test.js, test/mode-ecb-test.js, test/mode-ofb-test.js, test/pad-ansix923-test.js, test/pad-iso10126-test.js, test/pad-iso97971-test.js, test/pad-pkcs7-test.js, test/pad-zeropadding-test.js, test/pbkdf2-profile.js, test/pbkdf2-test.js, test/profile.html, test/rabbit-legacy-test.js, test/rabbit-profile.js, test/rabbit-test.js, test/rc4-profile.js, test/rc4-test.js, test/ripemd160-test.js, test/sha1-profile.js, test/sha1-test.js, test/sha224-test.js, test/sha256-profile.js, test/sha256-test.js, test/sha3-profile.js, test/sha3-test.js, test/sha384-test.js, test/sha512-profile.js, test/sha512-test.js, test/test-build.html, test/test.html, test/test1.html, test/tripledes-profile.js, test/tripledes-test.js, test/x64-word-test.js, test/x64-wordarray-test.js
Commit date: 2023-10-24 23:52:46 +0200
Commit message: Change default hash algorithm and iteration's for PBKDF2 to prevent weak security by using the default configuration.

Diff: diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..3bd5f35
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+node_modules
+build
+.svn
\ No newline at end of file
diff --git a/.jshintrc b/.jshintrc
new file mode 100644
index 0000000..72c2b12
--- /dev/null
+++ b/.jshintrc
@@ -0,0 +1,33 @@
+{
+  "bitwise": false, // Prohibits the use of bitwise operators (not confuse & with &&)
+  "curly": true, // Requires to always put curly braces around blocks in loops and conditionals
+  "eqeqeq": false, // Prohibits the use of == and != in favor of === and !==
+  "eqnull": true, // Suppresses warnings about == null comparisons
+  "immed": true, // Requires immediate invocations to be wrapped in parens e.g. `(function () { } ());`
+  "latedef": false, // Prohibits the use of a variable before it was defined
+  "newcap": false, // Requires to capitalize names of constructor functions
+  "noarg": true, // Prohibits the use of arguments.caller and arguments.callee
+  "strict": false, // Requires all functions to run in ECMAScript 5's strict mode
+  "undef": true, // Require non-global variables to be declared (prevents global leaks)
+  "asi": true, // Suppresses warnings about missing semicolons
+  "funcscope": false,
+  "shadow": true,
+  "expr": true,
+  "-W041": true,
+  "-W018": true,
+  "globals": {
+    "CryptoJS": true,
+    "escape": true,
+    "unescape": true,
+    "Int8Array": true,
+    "Int16Array": true,
+    "Int32Array": true,
+    "Uint8Array": true,
+    "Uint16Array": true,
+    "Uint32Array": true,
+    "Uint8ClampedArray": true,
+    "ArrayBuffer": true,
+    "Float32Array": true,
+    "Float64Array": true
+  }
+}
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..cca89fb
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,15 @@
+dist: trusty
+sudo: false
+
+language: node_js
+node_js:
+  - "6"
+  - "7"
+
+before_script:
+  - npm install -g grunt-cli
+  - npm install build
+
+cache:
+  directories:
+    - "node_modules"
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 0000000..09bf774
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,28 @@
+# Contribution
+
+# Git Flow 
+
+The crypto-js project uses [git flow](https://github.com/nvie/gitflow) to manage branches. 
+Do your changes on the `develop` or even better on a `feature/*` branch. Don't do any changes on the `master` branch.
+
+# Pull request
+
+Target your pull request on `develop` branch. Other pull request won't be accepted.
+
+# How to build
+
+1. Clone
+
+2. Run
+
+    ```sh
+    npm install
+    ```
+
+3. Run
+
+    ```sh
+    npm run build
+    ```
+    
+4. Check `build` folder
\ No newline at end of file
diff --git a/Gruntfile.js b/Gruntfile.js
new file mode 100644
index 0000000..e083f92
--- /dev/null
+++ b/Gruntfile.js
@@ -0,0 +1,51 @@
+/*jshint node: true*/
+
+'use strict';
+
+var path = require('path');
+
+module.exports = function (grunt) {
+
+    // Load all grunt tasks from node_modules, and config from /grunt/config
+    require('load-grunt-config')(grunt, {
+        configPath: path.join(process.cwd(), 'grunt/config'),
+        config: {
+            pkg: grunt.file.readJSON('package.json'),
+            meta: {
+                cwd: '',
+                cwdAll: '**/*',
+
+                source: 'src/',
+                sourceAll: 'src/**/*',
+
+                build: 'build/',
+                buildAll: 'build/**/*',
+
+                test: 'test/',
+                testAll: 'test/**/*',
+
+                npm: 'node_modules/',
+                npmAll: 'node_modules/**/*'
+            }
+        }
+    });
+    
+    
+
+    // Will load the custom tasks
+    grunt.loadTasks('./grunt/tasks');
+
+    grunt.registerTask('build', 'Build a bundle', [
+        'clean:build',
+        'modularize:build',
+        'copy:build',
+        'update_json:npm',
+        'update_json:bower'
+    ]);
+
+    grunt.registerTask('default', 'Run code checker', [
+        'jsonlint',
+        'jshint'
+    ]);
+
+};
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..b0828e5
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,24 @@
+# License
+
+[The MIT License (MIT)](http://opensource.org/licenses/MIT)
+
+Copyright (c) 2009-2013 Jeff Mott  
+Copyright (c) 2013-2016 Evan Vosberg
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..78e2c64
--- /dev/null
+++ b/README.md
@@ -0,0 +1,267 @@
+# crypto-js
+
+JavaScript library of crypto standards.
+
+## Discontinued
+
+Active development of CryptoJS has been discontinued. This library is no longer maintained.
+
+Nowadays, NodeJS and modern browsers have a native `Crypto` module. The latest version of CryptoJS already uses the native Crypto module for random number generation, since `Math.random()` is not crypto-safe. Further development of CryptoJS would result in it only being a wrapper of native Crypto. Therefore, development and maintenance has been discontinued, it is time to go for the native `crypto` module.
+
+## Node.js (Install)
+
+Requirements:
+
+- Node.js
+- npm (Node.js package manager)
+
+```bash
+npm install crypto-js
+```
+
+### Usage
+
+ES6 import for typical API call signing use case:
+
+```javascript
+import sha256 from 'crypto-js/sha256';
+import hmacSHA512 from 'crypto-js/hmac-sha512';
+import Base64 from 'crypto-js/enc-base64';
+
+const message, nonce, path, privateKey; // ...
+const hashDigest = sha256(nonce + message);
+const hmacDigest = Base64.stringify(hmacSHA512(path + hashDigest, privateKey));
+```
+
+Modular include:
+
+```javascript
+var AES = require("crypto-js/aes");
+var SHA256 = require("crypto-js/sha256");
+...
+console.log(SHA256("Message"));
+```
+
+Including all libraries, for access to extra methods:
+
+```javascript
+var CryptoJS = require("crypto-js");
+console.log(CryptoJS.HmacSHA1("Message", "Key"));
+```
+
+## Client (browser)
+
+Requirements:
+
+- Node.js
+- Bower (package manager for frontend)
+
+```bash
+bower install crypto-js
+```
+
+### Usage
+
+Modular include:
+
+```javascript
+require.config({
+    packages: [
+        {
+            name: 'crypto-js',
+            location: 'path-to/bower_components/crypto-js',
+            main: 'index'
+        }
+    ]
+});
+
+require(["crypto-js/aes", "crypto-js/sha256"], function (AES, SHA256) {
+    console.log(SHA256("Message"));
+});
+```
+
+Including all libraries, for access to extra methods:
+
+```javascript
+// Above-mentioned will work or use this simple form
+require.config({
+    paths: {
+        'crypto-js': 'path-to/bower_components/crypto-js/crypto-js'
+    }
+});
+
+require(["crypto-js"], function (CryptoJS) {
+    console.log(CryptoJS.HmacSHA1("Message", "Key"));
+});
+```
+
+### Usage without RequireJS
+
+```html
+<script type="text/javascript" src="path-to/bower_components/crypto-js/crypto-js.js"></script>
+<script type="text/javascript">
+    var encrypted = CryptoJS.AES(...);
+    var encrypted = CryptoJS.SHA256(...);
+</script>
+```
+
+## API
+
+See: https://cryptojs.gitbook.io/docs/
+
+### AES Encryption
+
+#### Plain text encryption
+
+```javascript
+var CryptoJS = require("crypto-js");
+
+// Encrypt
+var ciphertext = CryptoJS.AES.encrypt('my message', 'secret key 123').toString();
+
+// Decrypt
+var bytes  = CryptoJS.AES.decrypt(ciphertext, 'secret key 123');
+var originalText = bytes.toString(CryptoJS.enc.Utf8);
+
+console.log(originalText); // 'my message'
+```
+
+#### Object encryption
+
+```javascript
+var CryptoJS = require("crypto-js");
+
+var data = [{id: 1}, {id: 2}]
+
+// Encrypt
+var ciphertext = CryptoJS.AES.encrypt(JSON.stringify(data), 'secret key 123').toString();
+
+// Decrypt
+var bytes  = CryptoJS.AES.decrypt(ciphertext, 'secret key 123');
+var decryptedData = JSON.parse(bytes.toString(CryptoJS.enc.Utf8));
+
+console.log(decryptedData); // [{id: 1}, {id: 2}]
+```
+
+### List of modules
+
+
+- ```crypto-js/core```
+- ```crypto-js/x64-core```
+- ```crypto-js/lib-typedarrays```
+
+---
+
+- ```crypto-js/md5```
+- ```crypto-js/sha1```
+- ```crypto-js/sha256```
+- ```crypto-js/sha224```
+- ```crypto-js/sha512```
+- ```crypto-js/sha384```
+- ```crypto-js/sha3```
+- ```crypto-js/ripemd160```
+
+---
+
+- ```crypto-js/hmac-md5```
+- ```crypto-js/hmac-sha1```
+- ```crypto-js/hmac-sha256```
+- ```crypto-js/hmac-sha224```
+- ```crypto-js/hmac-sha512```
+- ```crypto-js/hmac-sha384```
+- ```crypto-js/hmac-sha3```
+- ```crypto-js/hmac-ripemd160```
+
+---
+
+- ```crypto-js/pbkdf2```
+
+---
+
+- ```crypto-js/aes```
+- ```crypto-js/tripledes```
+- ```crypto-js/rc4```
+- ```crypto-js/rabbit```
+- ```crypto-js/rabbit-legacy```
+- ```crypto-js/evpkdf```
+
+---
+
+- ```crypto-js/format-openssl```
+- ```crypto-js/format-hex```
+
+---
+
+- ```crypto-js/enc-latin1```
+- ```crypto-js/enc-utf8```
+- ```crypto-js/enc-hex```
+- ```crypto-js/enc-utf16```
+- ```crypto-js/enc-base64```
+
+---
+
+- ```crypto-js/mode-cfb```
+- ```crypto-js/mode-ctr```
+- ```crypto-js/mode-ctr-gladman```
+- ```crypto-js/mode-ofb```
+- ```crypto-js/mode-ecb```
+
+---
+
+- ```crypto-js/pad-pkcs7```
+- ```crypto-js/pad-ansix923```
+- ```crypto-js/pad-iso10126```
+- ```crypto-js/pad-iso97971```
+- ```crypto-js/pad-zeropadding```
+- ```crypto-js/pad-nopadding```
+
+
+## Release notes
+
+### 4.1.1
+
+Fix module order in bundled release.
+
+Include the browser field in the released package.json.
+
+### 4.1.0
+
+Added url safe variant of base64 encoding. [357](https://github.com/brix/crypto-js/pull/357)
+
+Avoid webpack to add crypto-browser package. [364](https://github.com/brix/crypto-js/pull/364)
+
+### 4.0.0
+
+This is an update including breaking changes for some environments.
+
+In this version `Math.random()` has been replaced by the random methods of the native crypto module.
+
+For this reason CryptoJS might not run in some JavaScript environments without native crypto module. Such as IE 10 or before or React Native.
+
+### 3.3.0
+
+Rollback, `3.3.0` is the same as `3.1.9-1`.
+
+The move of using native secure crypto module will be shifted to a new `4.x.x` version. As it is a breaking change the impact is too big for a minor release.
+
+### 3.2.1
+
+The usage of the native crypto module has been fixed. The import and access of the native crypto module has been improved.
+
+### 3.2.0
+
+In this version `Math.random()` has been replaced by the random methods of the native crypto module.
+
+For this reason CryptoJS might does not run in some JavaScript environments without native crypto module. Such as IE 10 or before.
+
+If it's absolute required to run CryptoJS in such an environment, stay with `3.1.x` version. Encrypting and decrypting stays compatible. But keep in mind `3.1.x` versions still use `Math.random()` which is cryptographically not secure, as it's not random enough. 
+
+This version came along with `CRITICAL` `BUG`. 
+
+DO NOT USE THIS VERSION! Please, go for a newer version!
+
+### 3.1.x
+
+The `3.1.x` are based on the original CryptoJS, wrapped in CommonJS modules.
+
+
diff --git a/docs/QuickStartGuide.wiki b/docs/QuickStartGuide.wiki
new file mode 100644
index 0000000..6b20199
--- /dev/null
+++ b/docs/QuickStartGuide.wiki
@@ -0,0 +1,470 @@
+<wiki:toc/>
+
+----
+
+= Quick-start Guide =
+
+== Hashers ==
+
+=== The Hasher Algorithms ===
+
+==== MD5 ====
+
+MD5 is a widely used hash function. It's been used in a variety of security applications and is also commonly used to check the integrity of files. Though, MD5 is not collision resistant, and it isn't suitable for applications like SSL certificates or digital signatures that rely on this property.
+
+{{{
+<script src="http://crypto-js.googlecode.com/svn/tags/3.1/build/rollups/md5.js"></script>
+<script>
+    var hash = CryptoJS.MD5("Message");
+</script>
+}}}
+
+==== SHA-1 ====
+
+The SHA hash functions were designed by the National Security Agency (NSA). SHA-1 is the most established of the existing SHA hash functions, and it's used in a variety of security applications and protocols. Though, SHA-1's collision resistance has been weakening as new attacks are discovered or improved.
+
+{{{
+<script src="http://crypto-js.googlecode.com/svn/tags/3.1/build/rollups/sha1.js"></script>
+<script>
+    var hash = CryptoJS.SHA1("Message");
+</script>
+}}}
+
+==== SHA-2 ====
+
+SHA-256 is one of the four variants in the SHA-2 set. It isn't as widely used as SHA-1, though it appears to provide much better security.
+
+{{{
+<script src="http://crypto-js.googlecode.com/svn/tags/3.1/build/rollups/sha256.js"></script>
+<script>
+    var hash = CryptoJS.SHA256("Message");
+</script>
+}}}
+
+SHA-512 is largely identical to SHA-256 but operates on 64-bit words rather than 32.
+
+{{{
+<script src="http://crypto-js.googlecode.com/svn/tags/3.1/build/rollups/sha512.js"></script>
+<script>
+    var hash = CryptoJS.SHA512("Message");
+</script>
+}}}
+
+CryptoJS also supports SHA-224 and SHA-384, which are largely identical but truncated versions of SHA-256 and SHA-512 respectively.
+
+==== SHA-3 ====
+
+SHA-3 is the winner of a five-year competition to select a new cryptographic hash algorithm where 64 competing designs were evaluated.
+
+{{{
+<script src="http://crypto-js.googlecode.com/svn/tags/3.1/build/rollups/sha3.js"></script>
+<script>
+    var hash = CryptoJS.SHA3("Message");
+</script>
+}}}
+
+SHA-3 can be configured to output hash lengths of one of 224, 256, 384, or 512 bits. The default is 512 bits.
+
+{{{
+<script src="http://crypto-js.googlecode.com/svn/tags/3.1/build/rollups/sha3.js"></script>
+<script>
+    var hash = CryptoJS.SHA3("Message", { outputLength: 512 });
+    var hash = CryptoJS.SHA3("Message", { outputLength: 384 });
+    var hash = CryptoJS.SHA3("Message", { outputLength: 256 });
+    var hash = CryptoJS.SHA3("Message", { outputLength: 224 });
+</script>
+}}}
+
+==== RIPEMD-160 ====
+
+{{{
+<script src="http://crypto-js.googlecode.com/svn/tags/3.1/build/rollups/ripemd160.js"></script>
+<script>
+    var hash = CryptoJS.RIPEMD160("Message");
+</script>
+}}}
+
+=== The Hasher Input ===
+
+The hash algorithms accept either strings or instances of CryptoJS.lib.WordArray. A WordArray object represents an array of 32-bit words. When you pass a string, it's automatically converted to a WordArray encoded as UTF-8.
+
+=== The Hasher Output ===
+
+The hash you get back isn't a string yet. It's a WordArray object. When you use a WordArray object in a string context, it's automatically converted to a hex string.
+
+{{{
+<script src="http://crypto-js.googlecode.com/svn/tags/3.1/build/rollups/sha256.js"></script>
+<script>
+    var hash = CryptoJS.SHA256("Message");
+
+    alert(typeof hash); // object
+
+    alert(hash); // 2f77668a9dfbf8d5848b9eeb4a7145ca94c6ed9236e4a773f6dcafa5132b2f91
+</script>
+}}}
+
+You can convert a WordArray object to other formats by explicitly calling the toString method and passing an encoder.
+
+{{{
+<script src="http://crypto-js.googlecode.com/svn/tags/3.1/build/rollups/sha256.js"></script>
+<script src="http://crypto-js.googlecode.com/svn/tags/3.1/build/components/enc-base64-min.js"></script>
+<script>
+    var hash = CryptoJS.SHA256("Message");
+
+    alert(hash.toString(CryptoJS.enc.Base64)); // L3dmip37+NWEi57rSnFFypTG7ZI25Kdz9tyvpRMrL5E=
+
+    alert(hash.toString(CryptoJS.enc.Latin1)); // /wf��ûøÕ���ëJqEÊ�Æí�6ä§söÜ¯¥+/�
+
+    alert(hash.toString(CryptoJS.enc.Hex)); // 2f77668a9dfbf8d5848b9eeb4a7145ca94c6ed9236e4a773f6dcafa5132b2f91
+</script>
+}}}
+
+=== Progressive Hashing ===
+
+{{{
+<script src="http://crypto-js.googlecode.com/svn/tags/3.1/build/rollups/sha256.js"></script>
+<script>
+    var sha256 = CryptoJS.algo.SHA256.create();
+
+    sha256.update("Message Part 1");
+    sha256.update("Message Part 2");
+    sha256.update("Message Part 3");
+
+    var hash = sha256.finalize();
+</script>
+}}}
+
+== HMAC ==
+
+Keyed-hash message authentication codes (HMAC) is a mechanism for message authentication using cryptographic hash functions.
+
+HMAC can be used in combination with any iterated cryptographic hash function.
+
+{{{
+<script src="http://crypto-js.googlecode.com/svn/tags/3.1/build/rollups/hmac-md5.js"></script>
+<script src="http://crypto-js.googlecode.com/svn/tags/3.1/build/rollups/hmac-sha1.js"></script>
+<script src="http://crypto-js.googlecode.com/svn/tags/3.1/build/rollups/hmac-sha256.js"></script>
+<script src="http://crypto-js.googlecode.com/svn/tags/3.1/build/rollups/hmac-sha512.js"></script>
+<script>
+    var hash = CryptoJS.HmacMD5("Message", "Secret Passphrase");
+    var hash = CryptoJS.HmacSHA1("Message", "Secret Passphrase");
+    var hash = CryptoJS.HmacSHA256("Message", "Secret Passphrase");
+    var hash = CryptoJS.HmacSHA512("Message", "Secret Passphrase");
+</script>
+}}}
+
+=== Progressive HMAC Hashing ===
+
+{{{
+<script src="http://crypto-js.googlecode.com/svn/tags/3.1/build/rollups/hmac-sha256.js"></script>
+<script>
+    var hmac = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA256, "Secret Passphrase");
+
+    hmac.update("Message Part 1");
+    hmac.update("Message Part 2");
+    hmac.update("Message Part 3");
+
+    var hash = hmac.finalize();
+</script>
+}}}
+
+== PBKDF2 ==
+
+PBKDF2 is a password-based key derivation function. In many applications of cryptography, user security is ultimately dependent on a password, and because a password usually can't be used directly as a cryptographic key, some processing is required.
+
+A salt provides a large set of keys for any given password, and an iteration count increases the cost of producing keys from a password, thereby also increasing the difficulty of attack.
+
+{{{
+<script src="http://crypto-js.googlecode.com/svn/tags/3.1/build/rollups/pbkdf2.js"></script>
+<script>
+    var salt = CryptoJS.lib.WordArray.random(128/8);
+
+    var key128Bits = CryptoJS.PBKDF2("Secret Passphrase", salt, { keySize: 128/32 });
+    var key256Bits = CryptoJS.PBKDF2("Secret Passphrase", salt, { keySize: 256/32 });
+    var key512Bits = CryptoJS.PBKDF2("Secret Passphrase", salt, { keySize: 512/32 });
+
+    var key512Bits1000Iterations = CryptoJS.PBKDF2("Secret Passphrase", salt, { keySize: 512/32, iterations: 1000 });
+</script>
+}}}
+
+== Ciphers ==
+
+=== The Cipher Algorithms ===
+
+==== AES ====
+
+The Advanced Encryption Standard (AES) is a U.S. Federal Information Processing Standard (FIPS). It was selected after a 5-year process where 15 competing designs were evaluated.
+
+{{{
+<script src="http://crypto-js.googlecode.com/svn/tags/3.1/build/rollups/aes.js"></script>
+<script>
+    var encrypted = CryptoJS.AES.encrypt("Message", "Secret Passphrase");
+
+    var decrypted = CryptoJS.AES.decrypt(encrypted, "Secret Passphrase");
+</script>
+}}}
+
+CryptoJS supports AES-128, AES-192, and AES-256. It will pick the variant by the size of the key you pass in. If you use a passphrase, then it will generate a 256-bit key.
+
+==== DES, Triple DES ====
+
+DES is a previously dominant algorithm for encryption, and was published as an official Federal Information Processing Standard (FIPS). DES is now considered to be insecure due to the small key size.
+
+{{{
+<script src="http://crypto-js.googlecode.com/svn/tags/3.1/build/rollups/tripledes.js"></script>
+<script>
+    var encrypted = CryptoJS.DES.encrypt("Message", "Secret Passphrase");
+
+    var decrypted = CryptoJS.DES.decrypt(encrypted, "Secret Passphrase");
+</script>
+}}}
+
+Triple DES applies DES three times to each block to increase the key size. The algorithm is believed to be secure in this form.
+
+{{{
+<script src="http://crypto-js.googlecode.com/svn/tags/3.1/build/rollups/tripledes.js"></script>
+<script>
+    var encrypted = CryptoJS.TripleDES.encrypt("Message", "Secret Passphrase");
+
+    var decrypted = CryptoJS.TripleDES.decrypt(encrypted, "Secret Passphrase");
+</script>
+}}}
+
+==== Rabbit ====
+
+Rabbit is a high-performance stream cipher and a finalist in the eSTREAM Portfolio. It is one of the four designs selected after a 3 1/2-year process where 22 designs were evaluated.
+
+{{{
+<script src="http://crypto-js.googlecode.com/svn/tags/3.1/build/rollups/rabbit.js"></script>
+<script>
+    var encrypted = CryptoJS.Rabbit.encrypt("Message", "Secret Passphrase");
+
+    var decrypted = CryptoJS.Rabbit.decrypt(encrypted, "Secret Passphrase");
+</script>
+}}}
+
+==== RC4, RC4Drop ====
+
+RC4 is a widely-used stream cipher. It's used in popular protocols such as SSL and WEP. Although remarkable for its simplicity and speed, the algorithm's history doesn't inspire confidence in its security.
+
+{{{
+<script src="http://crypto-js.googlecode.com/svn/tags/3.1/build/rollups/rc4.js"></script>
+<script>
+    var encrypted = CryptoJS.RC4.encrypt("Message", "Secret Passphrase");
+
+    var decrypted = CryptoJS.RC4.decrypt(encrypted, "Secret Passphrase");
+</script>
+}}}
+
+It was discovered that the first few bytes of keystream are strongly non-random and leak information about the key. We can defend against this attack by discarding the initial portion of the keystream. This modified algorithm is traditionally called RC4-drop.
+
+By default, 192 words (768 bytes) are dropped, but you can configure the algorithm to drop any number of words.
+
+{{{
+<script src="http://crypto-js.googlecode.com/svn/tags/3.1/build/rollups/rc4.js"></script>
+<script>
+    var encrypted = CryptoJS.RC4Drop.encrypt("Message", "Secret Passphrase");
+
+    var encrypted = CryptoJS.RC4Drop.encrypt("Message", "Secret Passphrase", { drop: 3072/4 });
+
+    var decrypted = CryptoJS.RC4Drop.decrypt(encrypted, "Secret Passphrase", { drop: 3072/4 });
+</script>
+}}}
+
+=== Custom Key and IV ===
+
+{{{
+<script src="http://crypto-js.googlecode.com/svn/tags/3.1/build/rollups/aes.js"></script>
+<script>
+    var key = CryptoJS.enc.Hex.parse('000102030405060708090a0b0c0d0e0f');
+    var iv  = CryptoJS.enc.Hex.parse('101112131415161718191a1b1c1d1e1f');
+
+    var encrypted = CryptoJS.AES.encrypt("Message", key, { iv: iv });
+</script>
+}}}
+
+=== Block Modes and Padding ===
+
+{{{
+<script src="http://crypto-js.googlecode.com/svn/tags/3.1/build/rollups/aes.js"></script>
+<script src="http://crypto-js.googlecode.com/svn/tags/3.1/build/components/mode-cfb-min.js"></script>
+<script src="http://crypto-js.googlecode.com/svn/tags/3.1/build/components/pad-ansix923-min.js"></script>
+<script>
+    var encrypted = CryptoJS.AES.encrypt("Message", "Secret Passphrase", { mode: CryptoJS.mode.CFB, padding: CryptoJS.pad.AnsiX923 });
+</script>
+}}}
+
+CryptoJS supports the following modes:
+
+  * CBC (the default)
+  * CFB
+  * CTR
+  * OFB
+  * ECB
+
+And CryptoJS supports the following padding schemes:
+
+  * Pkcs7 (the default)
+  * Iso97971
+  * AnsiX923
+  * Iso10126
+  * ZeroPadding
+  * NoPadding
+
+=== The Cipher Input ===
+
+For the plaintext message, the cipher algorithms accept either strings or instances of CryptoJS.lib.WordArray.
+
+For the key, when you pass a string, it's treated as a passphrase and used to derive an actual key and IV. Or you can pass a WordArray that represents the actual key. If you pass the actual key, you must also pass the actual IV.
+
+For the ciphertext, the cipher algorithms accept either strings or instances of CryptoJS.lib.CipherParams. A CipherParams object represents a collection of parameters such as the IV, a salt, and the raw ciphertext itself. When you pass a string, it's automatically converted to a CipherParams object according to a configurable format strategy.
+
+=== The Cipher Output ===
+
+The plaintext you get back after decryption is a WordArray object. See Hashers' Output for more detail.
+
+The ciphertext you get back after encryption isn't a string yet. It's a CipherParams object. A CipherParams object gives you access to all the parameters used during encryption. When you use a CipherParams object in a string context, it's automatically converted to a string according to a format strategy. The default is an OpenSSL-compatible format.
+
+{{{
+<script src="http://crypto-js.googlecode.com/svn/tags/3.1/build/rollups/aes.js"></script>
+<script>
+    var encrypted = CryptoJS.AES.encrypt("Message", "Secret Passphrase");
+
+    alert(encrypted.key);        // 74eb593087a982e2a6f5dded54ecd96d1fd0f3d44a58728cdcd40c55227522223
+    alert(encrypted.iv);         // 7781157e2629b094f0e3dd48c4d786115
+    alert(encrypted.salt);       // 7a25f9132ec6a8b34
+    alert(encrypted.ciphertext); // 73e54154a15d1beeb509d9e12f1e462a0
+
+    alert(encrypted);            // U2FsdGVkX1+iX5Ey7GqLND5UFUoV0b7rUJ2eEvHkYqA=
+</script>
+}}}
+
+You can define your own formats in order to be compatible with other crypto implementations. A format is an object with two methods—stringify and parse—that converts between CipherParams objects and ciphertext strings.
+
+Here's how you might write a JSON formatter:
+
+{{{
+<script src="http://crypto-js.googlecode.com/svn/tags/3.1/build/rollups/aes.js"></script>
+<script>
+    var JsonFormatter = {
+        stringify: function (cipherParams) {
+            // create json object with ciphertext
+            var jsonObj = {
+                ct: cipherParams.ciphertext.toString(CryptoJS.enc.Base64)
+            };
+
+            // optionally add iv and salt
+            if (cipherParams.iv) {
+                jsonObj.iv = cipherParams.iv.toString();
+            }
+            if (cipherParams.salt) {
+                jsonObj.s = cipherParams.salt.toString();
+            }
+
+            // stringify json object
+            return JSON.stringify(jsonObj);
+        },
+
+        parse: function (jsonStr) {
+            // parse json string
+            var jsonObj = JSON.parse(jsonStr);
+
+            // extract ciphertext from json object, and create cipher params object
+            var cipherParams = CryptoJS.lib.CipherParams.create({
+                ciphertext: CryptoJS.enc.Base64.parse(jsonObj.ct)
+            });
+
+            // optionally extract iv and salt
+            if (jsonObj.iv) {
+                cipherParams.iv = CryptoJS.enc.Hex.parse(jsonObj.iv)
+            }
+            if (jsonObj.s) {
+                cipherParams.salt = CryptoJS.enc.Hex.parse(jsonObj.s)
+            }
+
+            return cipherParams;
+        }
+    };
+
+    var encrypted = CryptoJS.AES.encrypt("Message", "Secret Passphrase", { format: JsonFormatter });
+
+    alert(encrypted); // {"ct":"tZ4MsEnfbcDOwqau68aOrQ==","iv":"8a8c8fd8fe33743d3638737ea4a00698","s":"ba06373c8f57179c"}
+
+    var decrypted = CryptoJS.AES.decrypt(encrypted, "Secret Passphrase", { format: JsonFormatter });
+
+    alert(decrypted.toString(CryptoJS.enc.Utf8)); // Message
+</script>
+}}}
+
+=== Progressive Ciphering ===
+
+{{{
+<script src="http://crypto-js.googlecode.com/svn/tags/3.1/build/rollups/aes.js"></script>
+<script>
+    var key = CryptoJS.enc.Hex.parse('000102030405060708090a0b0c0d0e0f');
+    var iv  = CryptoJS.enc.Hex.parse('101112131415161718191a1b1c1d1e1f');
+
+    var aesEncryptor = CryptoJS.algo.AES.createEncryptor(key, { iv: iv });
+
+    var ciphertextPart1 = aesEncryptor.process("Message Part 1");
+    var ciphertextPart2 = aesEncryptor.process("Message Part 2");
+    var ciphertextPart3 = aesEncryptor.process("Message Part 3");
+    var ciphertextPart4 = aesEncryptor.finalize();
+
+    var aesDecryptor = CryptoJS.algo.AES.createDecryptor(key, { iv: iv });
+
+    var plaintextPart1 = aesDecryptor.process(ciphertextPart1);
+    var plaintextPart2 = aesDecryptor.process(ciphertextPart2);
+    var plaintextPart3 = aesDecryptor.process(ciphertextPart3);
+    var plaintextPart4 = aesDecryptor.process(ciphertextPart4);
+    var plaintextPart5 = aesDecryptor.finalize();
+</script>
+}}}
+
+=== Interoperability ===
+
+==== With OpenSSL ====
+
+Encrypt with OpenSSL:
+
+{{{
+openssl enc -aes-256-cbc -in infile -out outfile -pass pass:"Secret Passphrase" -e -base64
+}}}
+
+Decrypt with CryptoJS:
+
+{{{
+<script src="http://crypto-js.googlecode.com/svn/tags/3.1/build/rollups/aes.js"></script>
+<script>
+    var decrypted = CryptoJS.AES.decrypt(openSSLEncrypted, "Secret Passphrase");
+</script>
+}}}
+
+== Encoders ==
+
+CryptoJS can convert from encoding formats such as Base64, Latin1 or Hex to WordArray objects and vica versa.
+
+{{{
+<script src="http://crypto-js.googlecode.com/svn/tags/3.1/build/components/core-min.js"></script>
+<script src="http://crypto-js.googlecode.com/svn/tags/3.1/build/components/enc-utf16-min.js"></script>
+<script src="http://crypto-js.googlecode.com/svn/tags/3.1/build/components/enc-base64-min.js"></script>
+<script>
+    var words  = CryptoJS.enc.Base64.parse('SGVsbG8sIFdvcmxkIQ==');
+    var base64 = CryptoJS.enc.Base64.stringify(words);
+
+    var words  = CryptoJS.enc.Latin1.parse('Hello, World!');
+    var latin1 = CryptoJS.enc.Latin1.stringify(words);
+
+    var words = CryptoJS.enc.Hex.parse('48656c6c6f2c20576f726c6421');
+    var hex   = CryptoJS.enc.Hex.stringify(words);
+
+    var words = CryptoJS.enc.Utf8.parse('𤭢');
+    var utf8  = CryptoJS.enc.Utf8.stringify(words);
+
+    var words = CryptoJS.enc.Utf16.parse('Hello, World!');
+    var utf16 = CryptoJS.enc.Utf16.stringify(words);
+
+    var words = CryptoJS.enc.Utf16LE.parse('Hello, World!');
+    var utf16 = CryptoJS.enc.Utf16LE.stringify(words);
+</script>
+}}}
\ No newline at end of file
diff --git a/grunt/config/clean.js b/grunt/config/clean.js
new file mode 100644
index 0000000..6c83318
--- /dev/null
+++ b/grunt/config/clean.js
@@ -0,0 +1,9 @@
+/*jshint node: true*/
+
+'use strict';
+
+module.exports = {
+    build: [
+        '<%= meta.build %>'
+    ]
+};
diff --git a/grunt/config/copy.js b/grunt/config/copy.js
new file mode 100644
index 0000000..2aa74e2
--- /dev/null
+++ b/grunt/config/copy.js
@@ -0,0 +1,19 @@
+/*jshint node: true*/
+
+'use strict';
+
+module.exports = {
+    build: {
+        files: [{
+            expand: false,
+            cwd: '<%= meta.cwd %>',
+            src: [
+                'README.md',
+                'CONTRIBUTING.md',
+                'LICENSE',
+                'docs/**/*'
+            ],
+            dest: '<%= meta.build %>'
+        }]
+    }
+};
diff --git a/grunt/config/jshint.js b/grunt/config/jshint.js
new file mode 100644
index 0000000..1c3cb23
--- /dev/null
+++ b/grunt/config/jshint.js
@@ -0,0 +1,20 @@
+/*jshint node: true*/
+
+'use strict';
+
+module.exports = {
+    dev: {
+        options: {
+            jshintrc: process.cwd() + '/.jshintrc',
+            reporterOutput: ''
+        },
+        files: {
+            src: [
+                '<%= meta.cwdAll %>.js',
+                '!<%= meta.buildAll %>',
+                '!<%= meta.testAll %>',
+                '!<%= meta.npmAll %>'
+            ]
+        }
+    }
+};
diff --git a/grunt/config/jsonlint.js b/grunt/config/jsonlint.js
new file mode 100644
index 0000000..f5405c1
--- /dev/null
+++ b/grunt/config/jsonlint.js
@@ -0,0 +1,15 @@
+/*jshint node: true*/
+
+'use strict';
+
+module.exports = {
+    all: {
+        files: {
+            src: [
+                '<%= meta.cwdAll %>.json',
+                '!<%= meta.buildAll %>',
+                '!<%= meta.npmAll %>'
+            ]
+        }
+    }
+};
diff --git a/grunt/config/modularize.js b/grunt/config/modularize.js
new file mode 100644
index 0000000..33218ee
--- /dev/null
+++ b/grunt/config/modularize.js
@@ -0,0 +1,235 @@
+/*jshint node: true*/
+
+module.exports = {
+    build: {
+        files: [{
+            expand: false,
+            cwd: '<%= meta.cwd %>',
+            src: ['<%= meta.source %>'],
+            dest: '<%= meta.build %>'
+        }],
+        options: {
+            // all
+            "index": {
+                "global": "CryptoJS",
+                "exports": "CryptoJS",
+                "components": ["core", "x64-core", "lib-typedarrays", "enc-utf16", "enc-base64", "enc-base64url", "md5", "sha1", "sha256", "sha224", "sha512", "sha384", "sha3", "ripemd160", "hmac", "pbkdf2", "evpkdf", "cipher-core", "mode-cfb", "mode-ctr", "mode-ctr-gladman", "mode-ofb", "mode-ecb", "pad-ansix923", "pad-iso10126", "pad-iso97971", "pad-zeropadding", "pad-nopadding", "format-hex", "aes", "tripledes", "rc4", "rabbit", "rabbit-legacy","blowfish"]
+            },
+            "crypto-js": {
+                "pack": true,
+                "global": "CryptoJS",
+                "exports": "CryptoJS",
+                "components": ["core", "x64-core", "lib-typedarrays", "enc-utf16", "enc-base64", "enc-base64url", "md5", "sha1", "sha256", "sha224", "sha512", "sha384", "sha3", "ripemd160", "hmac", "pbkdf2", "evpkdf", "cipher-core", "mode-cfb", "mode-ctr", "mode-ctr-gladman", "mode-ofb", "mode-ecb", "pad-ansix923", "pad-iso10126", "pad-iso97971", "pad-zeropadding", "pad-nopadding", "format-hex", "aes", "tripledes", "rc4", "rabbit", "rabbit-legacy","blowfish"]
+            },
+
+            // hash
+            "md5": {
+                "exports": "CryptoJS.MD5",
+                "components": ["core", "md5"]
+            },
+            "sha1": {
+                "exports": "CryptoJS.SHA1",
+                "components": ["core", "sha1"]
+            },
+            "sha256": {
+                "exports": "CryptoJS.SHA256",
+                "components": ["core", "sha256"]
+            },
+            "sha224": {
+                "exports": "CryptoJS.SHA224",
+                "components": ["core", "sha256", "sha224"]
+            },
+            "sha512": {
+                "exports": "CryptoJS.SHA512",
+                "components": ["core", "x64-core", "sha512"]
+            },
+            "sha384": {
+                "exports": "CryptoJS.SHA384",
+                "components": ["core", "x64-core", "sha512", "sha384"]
+            },
+            "sha3": {
+                "exports": "CryptoJS.SHA3",
+                "components": ["core", "x64-core", "sha3"]
+            },
+            "ripemd160": {
+                "exports": "CryptoJS.RIPEMD160",
+                "components": ["core", "ripemd160"]
+            },
+
+            // hmac hash
+            "hmac-md5": {
+                "exports": "CryptoJS.HmacMD5",
+                "components": ["core", "md5", "hmac"]
+            },
+            "hmac-sha1": {
+                "exports": "CryptoJS.HmacSHA1",
+                "components": ["core", "sha1", "hmac"]
+            },
+            "hmac-sha256": {
+                "exports": "CryptoJS.HmacSHA256",
+                "components": ["core", "sha256", "hmac"]
+            },
+            "hmac-sha224": {
+                "exports": "CryptoJS.HmacSHA224",
+                "components": ["core", "sha256", "sha224", "hmac"]
+            },
+            "hmac-sha512": {
+                "exports": "CryptoJS.HmacSHA512",
+                "components": ["core", "x64-core", "sha512", "hmac"]
+            },
+            "hmac-sha384": {
+                "exports": "CryptoJS.HmacSHA384",
+                "components": ["core", "x64-core", "sha512", "sha384", "hmac"]
+            },
+            "hmac-sha3": {
+                "exports": "CryptoJS.HmacSHA3",
+                "components": ["core", "x64-core", "sha3", "hmac"]
+            },
+            "hmac-ripemd160": {
+                "exports": "CryptoJS.HmacRIPEMD160",
+                "components": ["core", "ripemd160", "hmac"]
+            },
+            "pbkdf2": {
+                "exports": "CryptoJS.PBKDF2",
+                "components": ["core", "sha256", "hmac", "pbkdf2"]
+            },
+            "evpkdf": {
+                "exports": "CryptoJS.EvpKDF",
+                "components": ["core", "sha1", "hmac", "evpkdf"]
+            },
+
+            // cipher
+            "aes": {
+                "exports": "CryptoJS.AES",
+                "components": ["core", "enc-base64", "md5", "evpkdf", "cipher-core", "aes"]
+            },
+            "blowfish": {
+                "exports": "CryptoJS.Blowfish",
+                "components": ["core", "enc-base64", "md5", "evpkdf", "cipher-core", "blowfish"]
+            },
+            "tripledes": {
+                "exports": "CryptoJS.TripleDES",
+                "components": ["core", "enc-base64", "md5", "evpkdf", "cipher-core", "tripledes"]
+            },
+            "rc4": {
+                "exports": "CryptoJS.RC4",
+                "components": ["core", "enc-base64", "md5", "evpkdf", "cipher-core", "rc4"]
+            },
+            "rabbit": {
+                "exports": "CryptoJS.Rabbit",
+                "components": ["core", "enc-base64", "md5", "evpkdf", "cipher-core", "rabbit"]
+            },
+            "rabbit-legacy": {
+                "exports": "CryptoJS.RabbitLegacy",
+                "components": ["core", "enc-base64", "md5", "evpkdf", "cipher-core", "rabbit-legacy"]
+            },
+
+            // core
+            "core": {
+                "exports": "CryptoJS",
+                "components": ["core"],
+                "global": "CryptoJS"
+            },
+            "x64-core": {
+                "exports": "CryptoJS",
+                "components": ["core", "x64-core"]
+            },
+            "hmac": {
+                "components": ["core", "hmac"]
+            },
+            "cipher-core": {
+                "components": ["core", "evpkdf", "cipher-core"]
+            },
+
+            // lib
+            "lib-typedarrays": {
+                "exports": "CryptoJS.lib.WordArray",
+                "components": ["core", "lib-typedarrays"]
+            },
+
+            // format
+            "format-openssl": {
+                "exports": "CryptoJS.format.OpenSSL",
+                "components": ["core", "cipher-core"]
+            },
+            "format-hex": {
+                "exports": "CryptoJS.format.Hex",
+                "components": ["core", "cipher-core", "format-hex"]
+            },
+
+            // enc
+            "enc-latin1": {
+                "exports": "CryptoJS.enc.Latin1",
+                "components": ["core"]
+            },
+            "enc-utf8": {
+                "exports": "CryptoJS.enc.Utf8",
+                "components": ["core"]
+            },
+            "enc-hex": {
+                "exports": "CryptoJS.enc.Hex",
+                "components": ["core"]
+            },
+            "enc-utf16": {
+                "exports": "CryptoJS.enc.Utf16",
+                "components": ["core", "enc-utf16"]
+            },
+            "enc-base64": {
+                "exports": "CryptoJS.enc.Base64",
+                "components": ["core", "enc-base64"]
+            },
+            "enc-base64url": {
+                "exports": "CryptoJS.enc.Base64url",
+                "components": ["core", "enc-base64url"]
+            },
+
+            // mode
+            "mode-cfb": {
+                "exports": "CryptoJS.mode.CFB",
+                "components": ["core", "cipher-core", "mode-cfb"]
+            },
+            "mode-ctr": {
+                "exports": "CryptoJS.mode.CTR",
+                "components": ["core", "cipher-core", "mode-ctr"]
+            },
+            "mode-ctr-gladman": {
+                "exports": "CryptoJS.mode.CTRGladman",
+                "components": ["core", "cipher-core", "mode-ctr-gladman"]
+            },
+            "mode-ofb": {
+                "exports": "CryptoJS.mode.OFB",
+                "components": ["core", "cipher-core", "mode-ofb"]
+            },
+            "mode-ecb": {
+                "exports": "CryptoJS.mode.ECB",
+                "components": ["core", "cipher-core", "mode-ecb"]
+            },
+
+            // pad
+            "pad-pkcs7": {
+                "exports": "CryptoJS.pad.Pkcs7",
+                "components": ["core", "cipher-core", "pad-pkcs7"]
+            },
+            "pad-ansix923": {
+                "exports": "CryptoJS.pad.Ansix923",
+                "components": ["core", "cipher-core", "pad-ansix923"]
+            },
+            "pad-iso10126": {
+                "exports": "CryptoJS.pad.Iso10126",
+                "components": ["core", "cipher-core", "pad-iso10126"]
+            },
+            "pad-iso97971": {
+                "exports": "CryptoJS.pad.Iso97971",
+                "components": ["core", "cipher-core", "pad-iso97971"]
+            },
+            "pad-zeropadding": {
+                "exports": "CryptoJS.pad.ZeroPadding",
+                "components": ["core", "cipher-core", "pad-zeropadding"]
+            },
+            "pad-nopadding": {
+                "exports": "CryptoJS.pad.NoPadding",
+                "components": ["core", "cipher-core", "pad-nopadding"]
+            }
+        }
+    }
+};
diff --git a/grunt/config/update_json.js b/grunt/config/update_json.js
new file mode 100644
index 0000000..1b92a78
--- /dev/null
+++ b/grunt/config/update_json.js
@@ -0,0 +1,44 @@
+/*jshint node: true*/
+
+'use strict';
+
+module.exports = {
+    options: {
+        indent: '  '
+    },
+    npm: {
+        src: '<%= meta.cwd %>package.json',
+        dest: '<%= meta.build %>package.json',
+        fields: {
+            'name': null,
+            'version': null,
+            'description': null,
+            'license': null,
+            'author': null,
+            'homepage': null,
+            'repository': null,
+            'keywords': null,
+            'main': null,
+            'dependencies': null,
+            'browser': null
+        }
+    },
+    bower: {
+        src: '<%= meta.cwd %>package.json',
+        dest: '<%= meta.build %>bower.json',
+        fields: {
+            'name': null,
+            'version': null,
+            'description': null,
+            'license': null,
+            'author': 'authors',
+            'homepage': null,
+            'repository': null,
+            'keywords': null,
+            'main': null,
+            'dependencies': null,
+            'browser': null,
+            'ignore': []
+        }
+    }
+};
diff --git a/grunt/tasks/modularize.js b/grunt/tasks/modularize.js
new file mode 100644
index 0000000..228e9ae
--- /dev/null
+++ b/grunt/tasks/modularize.js
@@ -0,0 +1,102 @@
+/*jshint node: true*/
+/*jshint esversion: 6*/
+
+var _ = require("lodash"),
+
+    fmd = require("fmd");
+
+module.exports = function (grunt) {
+
+    grunt.registerMultiTask('modularize', function () {
+        var options = this.options(),
+
+            done = this.async(),
+
+            modules = {},
+
+            config = {
+                target: this.target + '/',
+                factories: ["commonjs", "amd", "global"],
+                trim_whitespace: true,
+                new_line: "unix",
+                indent: "\t"
+            };
+
+        // Prepare Factory-Module-Definition settings
+        _.each(options, (conf, name) => {
+            var sources = [],
+
+                opts = {
+                    depends: {}
+                },
+
+                deps = [];
+
+            if (conf.exports) {
+                opts.exports = conf.exports;
+            }
+
+            if (conf.global) {
+                opts.global = conf.global;
+            }
+
+            // Find and add self as source
+            _.each(this.filesSrc, (source) => {
+                if (grunt.file.exists(source + name + ".js")) {
+                    sources.push(source + name + ".js");
+                }
+            });
+
+            if (conf.pack) {
+                // Collect all components
+                deps = _.chain(conf.components)
+                    .map(depName => options[depName].components)
+                    .flatten()
+                    .uniq()
+                    .without(name)
+                    .sort((a, b) => {
+                        if (options[a].components.includes(b)) {
+                            return 1
+                        }
+
+                        if (options[b].components.includes(a)) {
+                            return -1
+                        }
+
+                        return 0;
+                    })
+                    .value();
+
+                // Add components as source files -> results a single file
+                _.each(this.filesSrc, (source) => {
+                    _.each(deps, (depName) => {
+                        if (grunt.file.exists(source + depName + ".js")) {
+                            sources.push(source + depName + ".js");
+                        }
+                    });
+                });
+            } else {
+                // Read components and add them as dependecies
+                _.each(_.without(conf.components, name), (value, i) => {
+                    opts.depends['./' + value] = value === "core" ? "CryptoJS" : null;
+                });
+            }
+
+            // Remove duplicates
+            sources = _.uniq(sources);
+
+            // Add module settings to fmd definition
+            modules[name] = [sources, opts];
+        });
+
+        // Build packege modules
+        fmd(config)
+            .define(modules)
+            .build(() => {
+
+                done();
+            });
+
+    });
+
+};
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..090bc11
--- /dev/null
+++ b/package.json
@@ -0,0 +1,62 @@
+{
+  "name": "crypto-js",
+  "title": "crypto-js",
+  "description": "JavaScript library of crypto standards.",
+  "version": "4.1.1",
+  "homepage": "http://github.com/brix/crypto-js",
+  "author": {
+    "name": "Evan Vosberg",
+    "url": "http://github.com/evanvosberg"
+  },
+  "repository": {
+    "type": "git",
+    "url": "http://github.com/brix/crypto-js.git"
+  },
+  "bugs": {
+    "url": "http://github.com/brix/crypto-js/issues"
+  },
+  "license": "MIT",
+  "scripts": {
+    "build": "grunt build",
+    "test": "grunt default"
+  },
+  "main": "index.js",
+  "browser": {
+    "crypto": false
+  },
+  "dependencies": {},
+  "devDependencies": {
+    "fmd": "~0.0.3",
+    "grunt": "^1.4.3",
+    "grunt-cli": "^1.4.3",
+    "grunt-contrib-clean": "^2.0.0",
+    "grunt-contrib-copy": "^1.0.0",
+    "grunt-contrib-jshint": "^3.0.0",
+    "grunt-jsonlint": "^2.1.3",
+    "grunt-update-json": "^0.2.2",
+    "load-grunt-config": "^4.0.0",
+    "lodash": "^4.17.21"
+  },
+  "keywords": [
+    "security",
+    "crypto",
+    "Hash",
+    "MD5",
+    "SHA1",
+    "SHA-1",
+    "SHA256",
+    "SHA-256",
+    "RC4",
+    "Rabbit",
+    "AES",
+    "DES",
+    "PBKDF2",
+    "HMAC",
+    "OFB",
+    "CFB",
+    "CTR",
+    "CBC",
+    "Base64",
+    "Base64url"
+  ]
+}
diff --git a/src/aes.js b/src/aes.js
new file mode 100644
index 0000000..2d033c0
--- /dev/null
+++ b/src/aes.js
@@ -0,0 +1,214 @@
+(function () {
+    // Shortcuts
+    var C = CryptoJS;
+    var C_lib = C.lib;
+    var BlockCipher = C_lib.BlockCipher;
+    var C_algo = C.algo;
+
+    // Lookup tables
+    var SBOX = [];
+    var INV_SBOX = [];
+    var SUB_MIX_0 = [];
+    var SUB_MIX_1 = [];
+    var SUB_MIX_2 = [];
+    var SUB_MIX_3 = [];
+    var INV_SUB_MIX_0 = [];
+    var INV_SUB_MIX_1 = [];
+    var INV_SUB_MIX_2 = [];
+    var INV_SUB_MIX_3 = [];
+
+    // Compute lookup tables
+    (function () {
+        // Compute double table
+        var d = [];
+        for (var i = 0; i < 256; i++) {
+            if (i < 128) {
+                d[i] = i << 1;
+            } else {
+                d[i] = (i << 1) ^ 0x11b;
+            }
+        }
+
+        // Walk GF(2^8)
+        var x = 0;
+        var xi = 0;
+        for (var i = 0; i < 256; i++) {
+            // Compute sbox
+            var sx = xi ^ (xi << 1) ^ (xi << 2) ^ (xi << 3) ^ (xi << 4);
+            sx = (sx >>> 8) ^ (sx & 0xff) ^ 0x63;
+            SBOX[x] = sx;
+            INV_SBOX[sx] = x;
+
+            // Compute multiplication
+            var x2 = d[x];
+            var x4 = d[x2];
+            var x8 = d[x4];
+
+            // Compute sub bytes, mix columns tables
+            var t = (d[sx] * 0x101) ^ (sx * 0x1010100);
+            SUB_MIX_0[x] = (t << 24) | (t >>> 8);
+            SUB_MIX_1[x] = (t << 16) | (t >>> 16);
+            SUB_MIX_2[x] = (t << 8)  | (t >>> 24);
+            SUB_MIX_3[x] = t;
+
+            // Compute inv sub bytes, inv mix columns tables
+            var t = (x8 * 0x1010101) ^ (x4 * 0x10001) ^ (x2 * 0x101) ^ (x * 0x1010100);
+            INV_SUB_MIX_0[sx] = (t << 24) | (t >>> 8);
+            INV_SUB_MIX_1[sx] = (t << 16) | (t >>> 16);
+            INV_SUB_MIX_2[sx] = (t << 8)  | (t >>> 24);
+            INV_SUB_MIX_3[sx] = t;
+
+            // Compute next counter
+            if (!x) {
+                x = xi = 1;
+            } else {
+                x = x2 ^ d[d[d[x8 ^ x2]]];
+                xi ^= d[d[xi]];
+            }
+        }
+    }());
+
+    // Precomputed Rcon lookup
+    var RCON = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36];
+
+    /**
+     * AES block cipher algorithm.
+     */
+    var AES = C_algo.AES = BlockCipher.extend({
+        _doReset: function () {
+            var t;
+            
+            // Skip reset of nRounds has been set before and key did not change
+            if (this._nRounds && this._keyPriorReset === this._key) {
+                return;
+            }
+
+            // Shortcuts
+            var key = this._keyPriorReset = this._key;
+            var keyWords = key.words;
+            var keySize = key.sigBytes / 4;
+
+            // Compute number of rounds
+            var nRounds = this._nRounds = keySize + 6;
+
+            // Compute number of key schedule rows
+            var ksRows = (nRounds + 1) * 4;
+
+            // Compute key schedule
+            var keySchedule = this._keySchedule = [];
+            for (var ksRow = 0; ksRow < ksRows; ksRow++) {
+                if (ksRow < keySize) {
+                    keySchedule[ksRow] = keyWords[ksRow];
+                } else {
+                    t = keySchedule[ksRow - 1];
+
+                    if (!(ksRow % keySize)) {
+                        // Rot word
+                        t = (t << 8) | (t >>> 24);
+
+                        // Sub word
+                        t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff];
+
+                        // Mix Rcon
+                        t ^= RCON[(ksRow / keySize) | 0] << 24;
+                    } else if (keySize > 6 && ksRow % keySize == 4) {
+                        // Sub word
+                        t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff];
+                    }
+
+                    keySchedule[ksRow] = keySchedule[ksRow - keySize] ^ t;
+                }
+            }
+
+            // Compute inv key schedule
+            var invKeySchedule = this._invKeySchedule = [];
+            for (var invKsRow = 0; invKsRow < ksRows; invKsRow++) {
+                var ksRow = ksRows - invKsRow;
+
+                if (invKsRow % 4) {
+                    var t = keySchedule[ksRow];
+                } else {
+                    var t = keySchedule[ksRow - 4];
+                }
+
+                if (invKsRow < 4 || ksRow <= 4) {
+                    invKeySchedule[invKsRow] = t;
+                } else {
+                    invKeySchedule[invKsRow] = INV_SUB_MIX_0[SBOX[t >>> 24]] ^ INV_SUB_MIX_1[SBOX[(t >>> 16) & 0xff]] ^
+                                               INV_SUB_MIX_2[SBOX[(t >>> 8) & 0xff]] ^ INV_SUB_MIX_3[SBOX[t & 0xff]];
+                }
+            }
+        },
+
+        encryptBlock: function (M, offset) {
+            this._doCryptBlock(M, offset, this._keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX);
+        },
+
+        decryptBlock: function (M, offset) {
+            // Swap 2nd and 4th rows
+            var t = M[offset + 1];
+            M[offset + 1] = M[offset + 3];
+            M[offset + 3] = t;
+
+            this._doCryptBlock(M, offset, this._invKeySchedule, INV_SUB_MIX_0, INV_SUB_MIX_1, INV_SUB_MIX_2, INV_SUB_MIX_3, INV_SBOX);
+
+            // Inv swap 2nd and 4th rows
+            var t = M[offset + 1];
+            M[offset + 1] = M[offset + 3];
+            M[offset + 3] = t;
+        },
+
+        _doCryptBlock: function (M, offset, keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX) {
+            // Shortcut
+            var nRounds = this._nRounds;
+
+            // Get input, add round key
+            var s0 = M[offset]     ^ keySchedule[0];
+            var s1 = M[offset + 1] ^ keySchedule[1];
+            var s2 = M[offset + 2] ^ keySchedule[2];
+            var s3 = M[offset + 3] ^ keySchedule[3];
+
+            // Key schedule row counter
+            var ksRow = 4;
+
+            // Rounds
+            for (var round = 1; round < nRounds; round++) {
+                // Shift rows, sub bytes, mix columns, add round key
+                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++];
+                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++];
+                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++];
+                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++];
+
+                // Update state
+                s0 = t0;
+                s1 = t1;
+                s2 = t2;
+                s3 = t3;
+            }
+
+            // Shift rows, sub bytes, add round key
+            var t0 = ((SBOX[s0 >>> 24] << 24) | (SBOX[(s1 >>> 16) & 0xff] << 16) | (SBOX[(s2 >>> 8) & 0xff] << 8) | SBOX[s3 & 0xff]) ^ keySchedule[ksRow++];
+            var t1 = ((SBOX[s1 >>> 24] << 24) | (SBOX[(s2 >>> 16) & 0xff] << 16) | (SBOX[(s3 >>> 8) & 0xff] << 8) | SBOX[s0 & 0xff]) ^ keySchedule[ksRow++];
+            var t2 = ((SBOX[s2 >>> 24] << 24) | (SBOX[(s3 >>> 16) & 0xff] << 16) | (SBOX[(s0 >>> 8) & 0xff] << 8) | SBOX[s1 & 0xff]) ^ keySchedule[ksRow++];
+            var t3 = ((SBOX[s3 >>> 24] << 24) | (SBOX[(s0 >>> 16) & 0xff] << 16) | (SBOX[(s1 >>> 8) & 0xff] << 8) | SBOX[s2 & 0xff]) ^ keySchedule[ksRow++];
+
+            // Set output
+            M[offset]     = t0;
+            M[offset + 1] = t1;
+            M[offset + 2] = t2;
+            M[offset + 3] = t3;
+        },
+
+        keySize: 256/32
+    });
+
+    /**
+     * Shortcut functions to the cipher's object interface.
+     *
+     * @example
+     *
+     *     var ciphertext = CryptoJS.AES.encrypt(message, key, cfg);
+     *     var plaintext  = CryptoJS.AES.decrypt(ciphertext, key, cfg);
+     */
+    C.AES = BlockCipher._createHelper(AES);
+}());
diff --git a/src/blowfish.js b/src/blowfish.js
new file mode 100644
index 0000000..60eb220
--- /dev/null
+++ b/src/blowfish.js
@@ -0,0 +1,451 @@
+(function () {
+    // Shortcuts
+    var C = CryptoJS;
+    var C_lib = C.lib;
+    var BlockCipher = C_lib.BlockCipher;
+    var C_algo = C.algo;
+
+    const N = 16;
+    
+    //Origin pbox and sbox, derived from PI
+    const ORIG_P = [
+        0x243F6A88, 0x85A308D3, 0x13198A2E, 0x03707344,
+        0xA4093822, 0x299F31D0, 0x082EFA98, 0xEC4E6C89,
+        0x452821E6, 0x38D01377, 0xBE5466CF, 0x34E90C6C,
+        0xC0AC29B7, 0xC97C50DD, 0x3F84D5B5, 0xB5470917,
+        0x9216D5D9, 0x8979FB1B
+    ];
+
+    const ORIG_S = [
+        [   0xD1310BA6, 0x98DFB5AC, 0x2FFD72DB, 0xD01ADFB7,
+            0xB8E1AFED, 0x6A267E96, 0xBA7C9045, 0xF12C7F99,
+            0x24A19947, 0xB3916CF7, 0x0801F2E2, 0x858EFC16,
+            0x636920D8, 0x71574E69, 0xA458FEA3, 0xF4933D7E,
+            0x0D95748F, 0x728EB658, 0x718BCD58, 0x82154AEE,
+            0x7B54A41D, 0xC25A59B5, 0x9C30D539, 0x2AF26013,
+            0xC5D1B023, 0x286085F0, 0xCA417918, 0xB8DB38EF,
+            0x8E79DCB0, 0x603A180E, 0x6C9E0E8B, 0xB01E8A3E,
+            0xD71577C1, 0xBD314B27, 0x78AF2FDA, 0x55605C60,
+            0xE65525F3, 0xAA55AB94, 0x57489862, 0x63E81440,
+            0x55CA396A, 0x2AAB10B6, 0xB4CC5C34, 0x1141E8CE,
+            0xA15486AF, 0x7C72E993, 0xB3EE1411, 0x636FBC2A,
+            0x2BA9C55D, 0x741831F6, 0xCE5C3E16, 0x9B87931E,
+            0xAFD6BA33, 0x6C24CF5C, 0x7A325381, 0x28958677,
+            0x3B8F4898, 0x6B4BB9AF, 0xC4BFE81B, 0x66282193,
+            0x61D809CC, 0xFB21A991, 0x487CAC60, 0x5DEC8032,
+            0xEF845D5D, 0xE98575B1, 0xDC262302, 0xEB651B88,
+            0x23893E81, 0xD396ACC5, 0x0F6D6FF3, 0x83F44239,
+            0x2E0B4482, 0xA4842004, 0x69C8F04A, 0x9E1F9B5E,
+            0x21C66842, 0xF6E96C9A, 0x670C9C61, 0xABD388F0,
+            0x6A51A0D2, 0xD8542F68, 0x960FA728, 0xAB5133A3,
+            0x6EEF0B6C, 0x137A3BE4, 0xBA3BF050, 0x7EFB2A98,
+            0xA1F1651D, 0x39AF0176, 0x66CA593E, 0x82430E88,
+            0x8CEE8619, 0x456F9FB4, 0x7D84A5C3, 0x3B8B5EBE,
+            0xE06F75D8, 0x85C12073, 0x401A449F, 0x56C16AA6,
+            0x4ED3AA62, 0x363F7706, 0x1BFEDF72, 0x429B023D,
+            0x37D0D724, 0xD00A1248, 0xDB0FEAD3, 0x49F1C09B,
+            0x075372C9, 0x80991B7B, 0x25D479D8, 0xF6E8DEF7,
+            0xE3FE501A, 0xB6794C3B, 0x976CE0BD, 0x04C006BA,
+            0xC1A94FB6, 0x409F60C4, 0x5E5C9EC2, 0x196A2463,
+            0x68FB6FAF, 0x3E6C53B5, 0x1339B2EB, 0x3B52EC6F,
+            0x6DFC511F, 0x9B30952C, 0xCC814544, 0xAF5EBD09,
+            0xBEE3D004, 0xDE334AFD, 0x660F2807, 0x192E4BB3,
+            0xC0CBA857, 0x45C8740F, 0xD20B5F39, 0xB9D3FBDB,
+            0x5579C0BD, 0x1A60320A, 0xD6A100C6, 0x402C7279,
+            0x679F25FE, 0xFB1FA3CC, 0x8EA5E9F8, 0xDB3222F8,
+            0x3C7516DF, 0xFD616B15, 0x2F501EC8, 0xAD0552AB,
+            0x323DB5FA, 0xFD238760, 0x53317B48, 0x3E00DF82,
+            0x9E5C57BB, 0xCA6F8CA0, 0x1A87562E, 0xDF1769DB,
+            0xD542A8F6, 0x287EFFC3, 0xAC6732C6, 0x8C4F5573,
+            0x695B27B0, 0xBBCA58C8, 0xE1FFA35D, 0xB8F011A0,
+            0x10FA3D98, 0xFD2183B8, 0x4AFCB56C, 0x2DD1D35B,
+            0x9A53E479, 0xB6F84565, 0xD28E49BC, 0x4BFB9790,
+            0xE1DDF2DA, 0xA4CB7E33, 0x62FB1341, 0xCEE4C6E8,
+            0xEF20CADA, 0x36774C01, 0xD07E9EFE, 0x2BF11FB4,
+            0x95DBDA4D, 0xAE909198, 0xEAAD8E71, 0x6B93D5A0,
+            0xD08ED1D0, 0xAFC725E0, 0x8E3C5B2F, 0x8E7594B7,
+            0x8FF6E2FB, 0xF2122B64, 0x8888B812, 0x900DF01C,
+            0x4FAD5EA0, 0x688FC31C, 0xD1CFF191, 0xB3A8C1AD,
+            0x2F2F2218, 0xBE0E1777, 0xEA752DFE, 0x8B021FA1,
+            0xE5A0CC0F, 0xB56F74E8, 0x18ACF3D6, 0xCE89E299,
+            0xB4A84FE0, 0xFD13E0B7, 0x7CC43B81, 0xD2ADA8D9,
+            0x165FA266, 0x80957705, 0x93CC7314, 0x211A1477,
+            0xE6AD2065, 0x77B5FA86, 0xC75442F5, 0xFB9D35CF,
+            0xEBCDAF0C, 0x7B3E89A0, 0xD6411BD3, 0xAE1E7E49,
+            0x00250E2D, 0x2071B35E, 0x226800BB, 0x57B8E0AF,
+            0x2464369B, 0xF009B91E, 0x5563911D, 0x59DFA6AA,
+            0x78C14389, 0xD95A537F, 0x207D5BA2, 0x02E5B9C5,
+            0x83260376, 0x6295CFA9, 0x11C81968, 0x4E734A41,
+            0xB3472DCA, 0x7B14A94A, 0x1B510052, 0x9A532915,
+            0xD60F573F, 0xBC9BC6E4, 0x2B60A476, 0x81E67400,
+            0x08BA6FB5, 0x571BE91F, 0xF296EC6B, 0x2A0DD915,
+            0xB6636521, 0xE7B9F9B6, 0xFF34052E, 0xC5855664,
+            0x53B02D5D, 0xA99F8FA1, 0x08BA4799, 0x6E85076A   ],
+        [   0x4B7A70E9, 0xB5B32944, 0xDB75092E, 0xC4192623,
+            0xAD6EA6B0, 0x49A7DF7D, 0x9CEE60B8, 0x8FEDB266,
+            0xECAA8C71, 0x699A17FF, 0x5664526C, 0xC2B19EE1,
+            0x193602A5, 0x75094C29, 0xA0591340, 0xE4183A3E,
+            0x3F54989A, 0x5B429D65, 0x6B8FE4D6, 0x99F73FD6,
+            0xA1D29C07, 0xEFE830F5, 0x4D2D38E6, 0xF0255DC1,
+            0x4CDD2086, 0x8470EB26, 0x6382E9C6, 0x021ECC5E,
+            0x09686B3F, 0x3EBAEFC9, 0x3C971814, 0x6B6A70A1,
+            0x687F3584, 0x52A0E286, 0xB79C5305, 0xAA500737,
+            0x3E07841C, 0x7FDEAE5C, 0x8E7D44EC, 0x5716F2B8,
+            0xB03ADA37, 0xF0500C0D, 0xF01C1F04, 0x0200B3FF,
+            0xAE0CF51A, 0x3CB574B2, 0x25837A58, 0xDC0921BD,
+            0xD19113F9, 0x7CA92FF6, 0x94324773, 0x22F54701,
+            0x3AE5E581, 0x37C2DADC, 0xC8B57634, 0x9AF3DDA7,
+            0xA9446146, 0x0FD0030E, 0xECC8C73E, 0xA4751E41,
+            0xE238CD99, 0x3BEA0E2F, 0x3280BBA1, 0x183EB331,
+            0x4E548B38, 0x4F6DB908, 0x6F420D03, 0xF60A04BF,
+            0x2CB81290, 0x24977C79, 0x5679B072, 0xBCAF89AF,
+            0xDE9A771F, 0xD9930810, 0xB38BAE12, 0xDCCF3F2E,
+            0x5512721F, 0x2E6B7124, 0x501ADDE6, 0x9F84CD87,
+            0x7A584718, 0x7408DA17, 0xBC9F9ABC, 0xE94B7D8C,
+            0xEC7AEC3A, 0xDB851DFA, 0x63094366, 0xC464C3D2,
+            0xEF1C1847, 0x3215D908, 0xDD433B37, 0x24C2BA16,
+            0x12A14D43, 0x2A65C451, 0x50940002, 0x133AE4DD,
+            0x71DFF89E, 0x10314E55, 0x81AC77D6, 0x5F11199B,
+            0x043556F1, 0xD7A3C76B, 0x3C11183B, 0x5924A509,
+            0xF28FE6ED, 0x97F1FBFA, 0x9EBABF2C, 0x1E153C6E,
+            0x86E34570, 0xEAE96FB1, 0x860E5E0A, 0x5A3E2AB3,
+            0x771FE71C, 0x4E3D06FA, 0x2965DCB9, 0x99E71D0F,
+            0x803E89D6, 0x5266C825, 0x2E4CC978, 0x9C10B36A,
+            0xC6150EBA, 0x94E2EA78, 0xA5FC3C53, 0x1E0A2DF4,
+            0xF2F74EA7, 0x361D2B3D, 0x1939260F, 0x19C27960,
+            0x5223A708, 0xF71312B6, 0xEBADFE6E, 0xEAC31F66,
+            0xE3BC4595, 0xA67BC883, 0xB17F37D1, 0x018CFF28,
+            0xC332DDEF, 0xBE6C5AA5, 0x65582185, 0x68AB9802,
+            0xEECEA50F, 0xDB2F953B, 0x2AEF7DAD, 0x5B6E2F84,
+            0x1521B628, 0x29076170, 0xECDD4775, 0x619F1510,
+            0x13CCA830, 0xEB61BD96, 0x0334FE1E, 0xAA0363CF,
+            0xB5735C90, 0x4C70A239, 0xD59E9E0B, 0xCBAADE14,
+            0xEECC86BC, 0x60622CA7, 0x9CAB5CAB, 0xB2F3846E,
+            0x648B1EAF, 0x19BDF0CA, 0xA02369B9, 0x655ABB50,
+            0x40685A32, 0x3C2AB4B3, 0x319EE9D5, 0xC021B8F7,
+            0x9B540B19, 0x875FA099, 0x95F7997E, 0x623D7DA8,
+            0xF837889A, 0x97E32D77, 0x11ED935F, 0x16681281,
+            0x0E358829, 0xC7E61FD6, 0x96DEDFA1, 0x7858BA99,
+            0x57F584A5, 0x1B227263, 0x9B83C3FF, 0x1AC24696,
+            0xCDB30AEB, 0x532E3054, 0x8FD948E4, 0x6DBC3128,
+            0x58EBF2EF, 0x34C6FFEA, 0xFE28ED61, 0xEE7C3C73,
+            0x5D4A14D9, 0xE864B7E3, 0x42105D14, 0x203E13E0,
+            0x45EEE2B6, 0xA3AAABEA, 0xDB6C4F15, 0xFACB4FD0,
+            0xC742F442, 0xEF6ABBB5, 0x654F3B1D, 0x41CD2105,
+            0xD81E799E, 0x86854DC7, 0xE44B476A, 0x3D816250,
+            0xCF62A1F2, 0x5B8D2646, 0xFC8883A0, 0xC1C7B6A3,
+            0x7F1524C3, 0x69CB7492, 0x47848A0B, 0x5692B285,
+            0x095BBF00, 0xAD19489D, 0x1462B174, 0x23820E00,
+            0x58428D2A, 0x0C55F5EA, 0x1DADF43E, 0x233F7061,
+            0x3372F092, 0x8D937E41, 0xD65FECF1, 0x6C223BDB,
+            0x7CDE3759, 0xCBEE7460, 0x4085F2A7, 0xCE77326E,
+            0xA6078084, 0x19F8509E, 0xE8EFD855, 0x61D99735,
+            0xA969A7AA, 0xC50C06C2, 0x5A04ABFC, 0x800BCADC,
+            0x9E447A2E, 0xC3453484, 0xFDD56705, 0x0E1E9EC9,
+            0xDB73DBD3, 0x105588CD, 0x675FDA79, 0xE3674340,
+            0xC5C43465, 0x713E38D8, 0x3D28F89E, 0xF16DFF20,
+            0x153E21E7, 0x8FB03D4A, 0xE6E39F2B, 0xDB83ADF7   ],
+        [   0xE93D5A68, 0x948140F7, 0xF64C261C, 0x94692934,
+            0x411520F7, 0x7602D4F7, 0xBCF46B2E, 0xD4A20068,
+            0xD4082471, 0x3320F46A, 0x43B7D4B7, 0x500061AF,
+            0x1E39F62E, 0x97244546, 0x14214F74, 0xBF8B8840,
+            0x4D95FC1D, 0x96B591AF, 0x70F4DDD3, 0x66A02F45,
+            0xBFBC09EC, 0x03BD9785, 0x7FAC6DD0, 0x31CB8504,
+            0x96EB27B3, 0x55FD3941, 0xDA2547E6, 0xABCA0A9A,
+            0x28507825, 0x530429F4, 0x0A2C86DA, 0xE9B66DFB,
+            0x68DC1462, 0xD7486900, 0x680EC0A4, 0x27A18DEE,
+            0x4F3FFEA2, 0xE887AD8C, 0xB58CE006, 0x7AF4D6B6,
+            0xAACE1E7C, 0xD3375FEC, 0xCE78A399, 0x406B2A42,
+            0x20FE9E35, 0xD9F385B9, 0xEE39D7AB, 0x3B124E8B,
+            0x1DC9FAF7, 0x4B6D1856, 0x26A36631, 0xEAE397B2,
+            0x3A6EFA74, 0xDD5B4332, 0x6841E7F7, 0xCA7820FB,
+            0xFB0AF54E, 0xD8FEB397, 0x454056AC, 0xBA489527,
+            0x55533A3A, 0x20838D87, 0xFE6BA9B7, 0xD096954B,
+            0x55A867BC, 0xA1159A58, 0xCCA92963, 0x99E1DB33,
+            0xA62A4A56, 0x3F3125F9, 0x5EF47E1C, 0x9029317C,
+            0xFDF8E802, 0x04272F70, 0x80BB155C, 0x05282CE3,
+            0x95C11548, 0xE4C66D22, 0x48C1133F, 0xC70F86DC,
+            0x07F9C9EE, 0x41041F0F, 0x404779A4, 0x5D886E17,
+            0x325F51EB, 0xD59BC0D1, 0xF2BCC18F, 0x41113564,
+            0x257B7834, 0x602A9C60, 0xDFF8E8A3, 0x1F636C1B,
+            0x0E12B4C2, 0x02E1329E, 0xAF664FD1, 0xCAD18115,
+            0x6B2395E0, 0x333E92E1, 0x3B240B62, 0xEEBEB922,
+            0x85B2A20E, 0xE6BA0D99, 0xDE720C8C, 0x2DA2F728,
+            0xD0127845, 0x95B794FD, 0x647D0862, 0xE7CCF5F0,
+            0x5449A36F, 0x877D48FA, 0xC39DFD27, 0xF33E8D1E,
+            0x0A476341, 0x992EFF74, 0x3A6F6EAB, 0xF4F8FD37,
+            0xA812DC60, 0xA1EBDDF8, 0x991BE14C, 0xDB6E6B0D,
+            0xC67B5510, 0x6D672C37, 0x2765D43B, 0xDCD0E804,
+            0xF1290DC7, 0xCC00FFA3, 0xB5390F92, 0x690FED0B,
+            0x667B9FFB, 0xCEDB7D9C, 0xA091CF0B, 0xD9155EA3,
+            0xBB132F88, 0x515BAD24, 0x7B9479BF, 0x763BD6EB,
+            0x37392EB3, 0xCC115979, 0x8026E297, 0xF42E312D,
+            0x6842ADA7, 0xC66A2B3B, 0x12754CCC, 0x782EF11C,
+            0x6A124237, 0xB79251E7, 0x06A1BBE6, 0x4BFB6350,
+            0x1A6B1018, 0x11CAEDFA, 0x3D25BDD8, 0xE2E1C3C9,
+            0x44421659, 0x0A121386, 0xD90CEC6E, 0xD5ABEA2A,
+            0x64AF674E, 0xDA86A85F, 0xBEBFE988, 0x64E4C3FE,
+            0x9DBC8057, 0xF0F7C086, 0x60787BF8, 0x6003604D,
+            0xD1FD8346, 0xF6381FB0, 0x7745AE04, 0xD736FCCC,
+            0x83426B33, 0xF01EAB71, 0xB0804187, 0x3C005E5F,
+            0x77A057BE, 0xBDE8AE24, 0x55464299, 0xBF582E61,
+            0x4E58F48F, 0xF2DDFDA2, 0xF474EF38, 0x8789BDC2,
+            0x5366F9C3, 0xC8B38E74, 0xB475F255, 0x46FCD9B9,
+            0x7AEB2661, 0x8B1DDF84, 0x846A0E79, 0x915F95E2,
+            0x466E598E, 0x20B45770, 0x8CD55591, 0xC902DE4C,
+            0xB90BACE1, 0xBB8205D0, 0x11A86248, 0x7574A99E,
+            0xB77F19B6, 0xE0A9DC09, 0x662D09A1, 0xC4324633,
+            0xE85A1F02, 0x09F0BE8C, 0x4A99A025, 0x1D6EFE10,
+            0x1AB93D1D, 0x0BA5A4DF, 0xA186F20F, 0x2868F169,
+            0xDCB7DA83, 0x573906FE, 0xA1E2CE9B, 0x4FCD7F52,
+            0x50115E01, 0xA70683FA, 0xA002B5C4, 0x0DE6D027,
+            0x9AF88C27, 0x773F8641, 0xC3604C06, 0x61A806B5,
+            0xF0177A28, 0xC0F586E0, 0x006058AA, 0x30DC7D62,
+            0x11E69ED7, 0x2338EA63, 0x53C2DD94, 0xC2C21634,
+            0xBBCBEE56, 0x90BCB6DE, 0xEBFC7DA1, 0xCE591D76,
+            0x6F05E409, 0x4B7C0188, 0x39720A3D, 0x7C927C24,
+            0x86E3725F, 0x724D9DB9, 0x1AC15BB4, 0xD39EB8FC,
+            0xED545578, 0x08FCA5B5, 0xD83D7CD3, 0x4DAD0FC4,
+            0x1E50EF5E, 0xB161E6F8, 0xA28514D9, 0x6C51133C,
+            0x6FD5C7E7, 0x56E14EC4, 0x362ABFCE, 0xDDC6C837,
+            0xD79A3234, 0x92638212, 0x670EFA8E, 0x406000E0  ],
+        [   0x3A39CE37, 0xD3FAF5CF, 0xABC27737, 0x5AC52D1B,
+            0x5CB0679E, 0x4FA33742, 0xD3822740, 0x99BC9BBE,
+            0xD5118E9D, 0xBF0F7315, 0xD62D1C7E, 0xC700C47B,
+            0xB78C1B6B, 0x21A19045, 0xB26EB1BE, 0x6A366EB4,
+            0x5748AB2F, 0xBC946E79, 0xC6A376D2, 0x6549C2C8,
+            0x530FF8EE, 0x468DDE7D, 0xD5730A1D, 0x4CD04DC6,
+            0x2939BBDB, 0xA9BA4650, 0xAC9526E8, 0xBE5EE304,
+            0xA1FAD5F0, 0x6A2D519A, 0x63EF8CE2, 0x9A86EE22,
+            0xC089C2B8, 0x43242EF6, 0xA51E03AA, 0x9CF2D0A4,
+            0x83C061BA, 0x9BE96A4D, 0x8FE51550, 0xBA645BD6,
+            0x2826A2F9, 0xA73A3AE1, 0x4BA99586, 0xEF5562E9,
+            0xC72FEFD3, 0xF752F7DA, 0x3F046F69, 0x77FA0A59,
+            0x80E4A915, 0x87B08601, 0x9B09E6AD, 0x3B3EE593,
+            0xE990FD5A, 0x9E34D797, 0x2CF0B7D9, 0x022B8B51,
+            0x96D5AC3A, 0x017DA67D, 0xD1CF3ED6, 0x7C7D2D28,
+            0x1F9F25CF, 0xADF2B89B, 0x5AD6B472, 0x5A88F54C,
+            0xE029AC71, 0xE019A5E6, 0x47B0ACFD, 0xED93FA9B,
+            0xE8D3C48D, 0x283B57CC, 0xF8D56629, 0x79132E28,
+            0x785F0191, 0xED756055, 0xF7960E44, 0xE3D35E8C,
+            0x15056DD4, 0x88F46DBA, 0x03A16125, 0x0564F0BD,
+            0xC3EB9E15, 0x3C9057A2, 0x97271AEC, 0xA93A072A,
+            0x1B3F6D9B, 0x1E6321F5, 0xF59C66FB, 0x26DCF319,
+            0x7533D928, 0xB155FDF5, 0x03563482, 0x8ABA3CBB,
+            0x28517711, 0xC20AD9F8, 0xABCC5167, 0xCCAD925F,
+            0x4DE81751, 0x3830DC8E, 0x379D5862, 0x9320F991,
+            0xEA7A90C2, 0xFB3E7BCE, 0x5121CE64, 0x774FBE32,
+            0xA8B6E37E, 0xC3293D46, 0x48DE5369, 0x6413E680,
+            0xA2AE0810, 0xDD6DB224, 0x69852DFD, 0x09072166,
+            0xB39A460A, 0x6445C0DD, 0x586CDECF, 0x1C20C8AE,
+            0x5BBEF7DD, 0x1B588D40, 0xCCD2017F, 0x6BB4E3BB,
+            0xDDA26A7E, 0x3A59FF45, 0x3E350A44, 0xBCB4CDD5,
+            0x72EACEA8, 0xFA6484BB, 0x8D6612AE, 0xBF3C6F47,
+            0xD29BE463, 0x542F5D9E, 0xAEC2771B, 0xF64E6370,
+            0x740E0D8D, 0xE75B1357, 0xF8721671, 0xAF537D5D,
+            0x4040CB08, 0x4EB4E2CC, 0x34D2466A, 0x0115AF84,
+            0xE1B00428, 0x95983A1D, 0x06B89FB4, 0xCE6EA048,
+            0x6F3F3B82, 0x3520AB82, 0x011A1D4B, 0x277227F8,
+            0x611560B1, 0xE7933FDC, 0xBB3A792B, 0x344525BD,
+            0xA08839E1, 0x51CE794B, 0x2F32C9B7, 0xA01FBAC9,
+            0xE01CC87E, 0xBCC7D1F6, 0xCF0111C3, 0xA1E8AAC7,
+            0x1A908749, 0xD44FBD9A, 0xD0DADECB, 0xD50ADA38,
+            0x0339C32A, 0xC6913667, 0x8DF9317C, 0xE0B12B4F,
+            0xF79E59B7, 0x43F5BB3A, 0xF2D519FF, 0x27D9459C,
+            0xBF97222C, 0x15E6FC2A, 0x0F91FC71, 0x9B941525,
+            0xFAE59361, 0xCEB69CEB, 0xC2A86459, 0x12BAA8D1,
+            0xB6C1075E, 0xE3056A0C, 0x10D25065, 0xCB03A442,
+            0xE0EC6E0E, 0x1698DB3B, 0x4C98A0BE, 0x3278E964,
+            0x9F1F9532, 0xE0D392DF, 0xD3A0342B, 0x8971F21E,
+            0x1B0A7441, 0x4BA3348C, 0xC5BE7120, 0xC37632D8,
+            0xDF359F8D, 0x9B992F2E, 0xE60B6F47, 0x0FE3F11D,
+            0xE54CDA54, 0x1EDAD891, 0xCE6279CF, 0xCD3E7E6F,
+            0x1618B166, 0xFD2C1D05, 0x848FD2C5, 0xF6FB2299,
+            0xF523F357, 0xA6327623, 0x93A83531, 0x56CCCD02,
+            0xACF08162, 0x5A75EBB5, 0x6E163697, 0x88D273CC,
+            0xDE966292, 0x81B949D0, 0x4C50901B, 0x71C65614,
+            0xE6C6C7BD, 0x327A140A, 0x45E1D006, 0xC3F27B9A,
+            0xC9AA53FD, 0x62A80F00, 0xBB25BFE2, 0x35BDD2F6,
+            0x71126905, 0xB2040222, 0xB6CBCF7C, 0xCD769C2B,
+            0x53113EC0, 0x1640E3D3, 0x38ABBD60, 0x2547ADF0,
+            0xBA38209C, 0xF746CE76, 0x77AFA1C5, 0x20756060,
+            0x85CBFE4E, 0x8AE88DD8, 0x7AAAF9B0, 0x4CF9AA7E,
+            0x1948C25C, 0x02FB8A8C, 0x01C36AE4, 0xD6EBE1F9,
+            0x90D4F869, 0xA65CDEA0, 0x3F09252D, 0xC208E69F,
+            0xB74E6132, 0xCE77E25B, 0x578FDFE3, 0x3AC372E6  ]
+    ];
+
+    var BLOWFISH_CTX = {
+        pbox: [],
+        sbox: []
+    }
+
+    function F(ctx, x){
+        let a = (x >> 24) & 0xFF;
+        let b = (x >> 16) & 0xFF;
+        let c = (x >> 8) & 0xFF;
+        let d = x & 0xFF;
+
+        let y = ctx.sbox[0][a] + ctx.sbox[1][b];
+        y = y ^ ctx.sbox[2][c];
+        y = y + ctx.sbox[3][d];
+
+        return y;
+    }
+
+    function BlowFish_Encrypt(ctx, left, right){
+        let Xl = left;
+        let Xr = right;
+        let temp;
+
+        for(let i = 0; i < N; ++i){
+            Xl = Xl ^ ctx.pbox[i];
+            Xr = F(ctx, Xl) ^ Xr;
+
+            temp = Xl;
+            Xl = Xr;
+            Xr = temp;
+        }
+
+        temp = Xl;
+        Xl = Xr;
+        Xr = temp;
+
+        Xr = Xr ^ ctx.pbox[N];
+        Xl = Xl ^ ctx.pbox[N + 1];
+
+        return {left: Xl, right: Xr};
+    }
+
+    function BlowFish_Decrypt(ctx, left, right){
+        let Xl = left;
+        let Xr = right;
+        let temp;
+
+        for(let i = N + 1; i > 1; --i){
+            Xl = Xl ^ ctx.pbox[i];
+            Xr = F(ctx, Xl) ^ Xr;
+
+            temp = Xl;
+            Xl = Xr;
+            Xr = temp;
+        }
+
+        temp = Xl;
+        Xl = Xr;
+        Xr = temp;
+
+        Xr = Xr ^ ctx.pbox[1];
+        Xl = Xl ^ ctx.pbox[0];
+
+        return {left: Xl, right: Xr};
+    }
+
+    /**
+     * Initialization ctx's pbox and sbox.
+     *
+     * @param {Object} ctx The object has pbox and sbox.
+     * @param {Array} key An array of 32-bit words.
+     * @param {int} keysize The length of the key.
+     *
+     * @example
+     *
+     *     BlowFishInit(BLOWFISH_CTX, key, 128/32);
+     */
+    function BlowFishInit(ctx, key, keysize)
+    {
+        for(let Row = 0; Row < 4; Row++)
+        {
+            ctx.sbox[Row] = [];
+            for(let Col = 0; Col < 256; Col++)
+            {
+                ctx.sbox[Row][Col] = ORIG_S[Row][Col];
+            }
+        }
+
+        let keyIndex = 0;
+        for(let index = 0; index < N + 2; index++)
+        {
+            ctx.pbox[index] = ORIG_P[index] ^ key[keyIndex];
+            keyIndex++;
+            if(keyIndex >= keysize)
+            {
+                keyIndex = 0;
+            }
+        }
+
+        let Data1 = 0;
+        let Data2 = 0;
+        let res = 0;
+        for(let i = 0; i < N + 2; i += 2)
+        {
+            res = BlowFish_Encrypt(ctx, Data1, Data2);
+            Data1 = res.left;
+            Data2 = res.right;
+            ctx.pbox[i] = Data1;
+            ctx.pbox[i + 1] = Data2;
+        }
+        
+        for(let i = 0; i < 4; i++)
+        {
+            for(let j = 0; j < 256; j += 2)
+            {
+                res = BlowFish_Encrypt(ctx, Data1, Data2);
+                Data1 = res.left;
+                Data2 = res.right;
+                ctx.sbox[i][j] = Data1;
+                ctx.sbox[i][j + 1] = Data2;
+            }
+        }
+
+        return true;
+    }
+
+    /**
+     * Blowfish block cipher algorithm.
+     */
+    var Blowfish = C_algo.Blowfish = BlockCipher.extend({
+        _doReset: function () {
+            // Skip reset of nRounds has been set before and key did not change
+            if (this._keyPriorReset === this._key) {
+                return;
+            }
+
+            // Shortcuts
+            var key = this._keyPriorReset = this._key;
+            var keyWords = key.words;
+            var keySize = key.sigBytes / 4;
+
+            //Initialization pbox and sbox
+            BlowFishInit(BLOWFISH_CTX, keyWords, keySize);
+        },
+
+        encryptBlock: function (M, offset) {
+            var res = BlowFish_Encrypt(BLOWFISH_CTX, M[offset], M[offset + 1]);
+            M[offset] = res.left;
+            M[offset + 1] = res.right;
+        },
+
+        decryptBlock: function (M, offset) {
+            var res = BlowFish_Decrypt(BLOWFISH_CTX, M[offset], M[offset + 1]);
+            M[offset] = res.left;
+            M[offset + 1] = res.right;
+        },
+
+        blockSize: 64/32,
+
+        keySize: 128/32,
+
+        ivSize: 64/32
+    });
+
+    /**
+     * Shortcut functions to the cipher's object interface.
+     *
+     * @example
+     *
+     *     var ciphertext = CryptoJS.Blowfish.encrypt(message, key, cfg);
+     *     var plaintext  = CryptoJS.Blowfish.decrypt(ciphertext, key, cfg);
+     */
+    C.Blowfish = BlockCipher._createHelper(Blowfish);
+}());
diff --git a/src/cipher-core.js b/src/cipher-core.js
new file mode 100644
index 0000000..125632c
--- /dev/null
+++ b/src/cipher-core.js
@@ -0,0 +1,877 @@
+/**
+ * Cipher core components.
+ */
+CryptoJS.lib.Cipher || (function (undefined) {
+    // Shortcuts
+    var C = CryptoJS;
+    var C_lib = C.lib;
+    var Base = C_lib.Base;
+    var WordArray = C_lib.WordArray;
+    var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm;
+    var C_enc = C.enc;
+    var Utf8 = C_enc.Utf8;
+    var Base64 = C_enc.Base64;
+    var C_algo = C.algo;
+    var EvpKDF = C_algo.EvpKDF;
+
+    /**
+     * Abstract base cipher template.
+     *
+     * @property {number} keySize This cipher's key size. Default: 4 (128 bits)
+     * @property {number} ivSize This cipher's IV size. Default: 4 (128 bits)
+     * @property {number} _ENC_XFORM_MODE A constant representing encryption mode.
+     * @property {number} _DEC_XFORM_MODE A constant representing decryption mode.
+     */
+    var Cipher = C_lib.Cipher = BufferedBlockAlgorithm.extend({
+        /**
+         * Configuration options.
+         *
+         * @property {WordArray} iv The IV to use for this operation.
+         */
+        cfg: Base.extend(),
+
+        /**
+         * Creates this cipher in encryption mode.
+         *
+         * @param {WordArray} key The key.
+         * @param {Object} cfg (Optional) The configuration options to use for this operation.
+         *
+         * @return {Cipher} A cipher instance.
+         *
+         * @static
+         *
+         * @example
+         *
+         *     var cipher = CryptoJS.algo.AES.createEncryptor(keyWordArray, { iv: ivWordArray });
+         */
+        createEncryptor: function (key, cfg) {
+            return this.create(this._ENC_XFORM_MODE, key, cfg);
+        },
+
+        /**
+         * Creates this cipher in decryption mode.
+         *
+         * @param {WordArray} key The key.
+         * @param {Object} cfg (Optional) The configuration options to use for this operation.
+         *
+         * @return {Cipher} A cipher instance.
+         *
+         * @static
+         *
+         * @example
+         *
+         *     var cipher = CryptoJS.algo.AES.createDecryptor(keyWordArray, { iv: ivWordArray });
+         */
+        createDecryptor: function (key, cfg) {
+            return this.create(this._DEC_XFORM_MODE, key, cfg);
+        },
+
+        /**
+         * Initializes a newly created cipher.
+         *
+         * @param {number} xformMode Either the encryption or decryption transormation mode constant.
+         * @param {WordArray} key The key.
+         * @param {Object} cfg (Optional) The configuration options to use for this operation.
+         *
+         * @example
+         *
+         *     var cipher = CryptoJS.algo.AES.create(CryptoJS.algo.AES._ENC_XFORM_MODE, keyWordArray, { iv: ivWordArray });
+         */
+        init: function (xformMode, key, cfg) {
+            // Apply config defaults
+            this.cfg = this.cfg.extend(cfg);
+
+            // Store transform mode and key
+            this._xformMode = xformMode;
+            this._key = key;
+
+            // Set initial values
+            this.reset();
+        },
+
+        /**
+         * Resets this cipher to its initial state.
+         *
+         * @example
+         *
+         *     cipher.reset();
+         */
+        reset: function () {
+            // Reset data buffer
+            BufferedBlockAlgorithm.reset.call(this);
+
+            // Perform concrete-cipher logic
+            this._doReset();
+        },
+
+        /**
+         * Adds data to be encrypted or decrypted.
+         *
+         * @param {WordArray|string} dataUpdate The data to encrypt or decrypt.
+         *
+         * @return {WordArray} The data after processing.
+         *
+         * @example
+         *
+         *     var encrypted = cipher.process('data');
+         *     var encrypted = cipher.process(wordArray);
+         */
+        process: function (dataUpdate) {
+            // Append
+            this._append(dataUpdate);
+
+            // Process available blocks
+            return this._process();
+        },
+
+        /**
+         * Finalizes the encryption or decryption process.
+         * Note that the finalize operation is effectively a destructive, read-once operation.
+         *
+         * @param {WordArray|string} dataUpdate The final data to encrypt or decrypt.
+         *
+         * @return {WordArray} The data after final processing.
+         *
+         * @example
+         *
+         *     var encrypted = cipher.finalize();
+         *     var encrypted = cipher.finalize('data');
+         *     var encrypted = cipher.finalize(wordArray);
+         */
+        finalize: function (dataUpdate) {
+            // Final data update
+            if (dataUpdate) {
+                this._append(dataUpdate);
+            }
+
+            // Perform concrete-cipher logic
+            var finalProcessedData = this._doFinalize();
+
+            return finalProcessedData;
+        },
+
+        keySize: 128/32,
+
+        ivSize: 128/32,
+
+        _ENC_XFORM_MODE: 1,
+
+        _DEC_XFORM_MODE: 2,
+
+        /**
+         * Creates shortcut functions to a cipher's object interface.
+         *
+         * @param {Cipher} cipher The cipher to create a helper for.
+         *
+         * @return {Object} An object with encrypt and decrypt shortcut functions.
+         *
+         * @static
+         *
+         * @example
+         *
+         *     var AES = CryptoJS.lib.Cipher._createHelper(CryptoJS.algo.AES);
+         */
+        _createHelper: (function () {
+            function selectCipherStrategy(key) {
+                if (typeof key == 'string') {
+                    return PasswordBasedCipher;
+                } else {
+                    return SerializableCipher;
+                }
+            }
+
+            return function (cipher) {
+                return {
+                    encrypt: function (message, key, cfg) {
+                        return selectCipherStrategy(key).encrypt(cipher, message, key, cfg);
+                    },
+
+                    decrypt: function (ciphertext, key, cfg) {
+                        return selectCipherStrategy(key).decrypt(cipher, ciphertext, key, cfg);
+                    }
+                };
+            };
+        }())
+    });
+
+    /**
+     * Abstract base stream cipher template.
+     *
+     * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 1 (32 bits)
+     */
+    var StreamCipher = C_lib.StreamCipher = Cipher.extend({
+        _doFinalize: function () {
+            // Process partial blocks
+            var finalProcessedBlocks = this._process(!!'flush');
+
+            return finalProcessedBlocks;
+        },
+
+        blockSize: 1
+    });
+
+    /**
+     * Mode namespace.
+     */
+    var C_mode = C.mode = {};
+
+    /**
+     * Abstract base block cipher mode template.
+     */
+    var BlockCipherMode = C_lib.BlockCipherMode = Base.extend({
+        /**
+         * Creates this mode for encryption.
+         *
+         * @param {Cipher} cipher A block cipher instance.
+         * @param {Array} iv The IV words.
+         *
+         * @static
+         *
+         * @example
+         *
+         *     var mode = CryptoJS.mode.CBC.createEncryptor(cipher, iv.words);
+         */
+        createEncryptor: function (cipher, iv) {
+            return this.Encryptor.create(cipher, iv);
+        },
+
+        /**
+         * Creates this mode for decryption.
+         *
+         * @param {Cipher} cipher A block cipher instance.
+         * @param {Array} iv The IV words.
+         *
+         * @static
+         *
+         * @example
+         *
+         *     var mode = CryptoJS.mode.CBC.createDecryptor(cipher, iv.words);
+         */
+        createDecryptor: function (cipher, iv) {
+            return this.Decryptor.create(cipher, iv);
+        },
+
+        /**
+         * Initializes a newly created mode.
+         *
+         * @param {Cipher} cipher A block cipher instance.
+         * @param {Array} iv The IV words.
+         *
+         * @example
+         *
+         *     var mode = CryptoJS.mode.CBC.Encryptor.create(cipher, iv.words);
+         */
+        init: function (cipher, iv) {
+            this._cipher = cipher;
+            this._iv = iv;
+        }
+    });
+
+    /**
+     * Cipher Block Chaining mode.
+     */
+    var CBC = C_mode.CBC = (function () {
+        /**
+         * Abstract base CBC mode.
+         */
+        var CBC = BlockCipherMode.extend();
+
+        /**
+         * CBC encryptor.
+         */
+        CBC.Encryptor = CBC.extend({
+            /**
+             * Processes the data block at offset.
+             *
+             * @param {Array} words The data words to operate on.
+             * @param {number} offset The offset where the block starts.
+             *
+             * @example
+             *
+             *     mode.processBlock(data.words, offset);
+             */
+            processBlock: function (words, offset) {
+                // Shortcuts
+                var cipher = this._cipher;
+                var blockSize = cipher.blockSize;
+
+                // XOR and encrypt
+                xorBlock.call(this, words, offset, blockSize);
+                cipher.encryptBlock(words, offset);
+
+                // Remember this block to use with next block
+                this._prevBlock = words.slice(offset, offset + blockSize);
+            }
+        });
+
+        /**
+         * CBC decryptor.
+         */
+        CBC.Decryptor = CBC.extend({
+            /**
+             * Processes the data block at offset.
+             *
+             * @param {Array} words The data words to operate on.
+             * @param {number} offset The offset where the block starts.
+             *
+             * @example
+             *
+             *     mode.processBlock(data.words, offset);
+             */
+            processBlock: function (words, offset) {
+                // Shortcuts
+                var cipher = this._cipher;
+                var blockSize = cipher.blockSize;
+
+                // Remember this block to use with next block
+                var thisBlock = words.slice(offset, offset + blockSize);
+
+                // Decrypt and XOR
+                cipher.decryptBlock(words, offset);
+                xorBlock.call(this, words, offset, blockSize);
+
+                // This block becomes the previous block
+                this._prevBlock = thisBlock;
+            }
+        });
+
+        function xorBlock(words, offset, blockSize) {
+            var block;
+
+            // Shortcut
+            var iv = this._iv;
+
+            // Choose mixing block
+            if (iv) {
+                block = iv;
+
+                // Remove IV for subsequent blocks
+                this._iv = undefined;
+            } else {
+                block = this._prevBlock;
+            }
+
+            // XOR blocks
+            for (var i = 0; i < blockSize; i++) {
+                words[offset + i] ^= block[i];
+            }
+        }
+
+        return CBC;
+    }());
+
+    /**
+     * Padding namespace.
+     */
+    var C_pad = C.pad = {};
+
+    /**
+     * PKCS #5/7 padding strategy.
+     */
+    var Pkcs7 = C_pad.Pkcs7 = {
+        /**
+         * Pads data using the algorithm defined in PKCS #5/7.
+         *
+         * @param {WordArray} data The data to pad.
+         * @param {number} blockSize The multiple that the data should be padded to.
+         *
+         * @static
+         *
+         * @example
+         *
+         *     CryptoJS.pad.Pkcs7.pad(wordArray, 4);
+         */
+        pad: function (data, blockSize) {
+            // Shortcut
+            var blockSizeBytes = blockSize * 4;
+
+            // Count padding bytes
+            var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes;
+
+            // Create padding word
+            var paddingWord = (nPaddingBytes << 24) | (nPaddingBytes << 16) | (nPaddingBytes << 8) | nPaddingBytes;
+
+            // Create padding
+            var paddingWords = [];
+            for (var i = 0; i < nPaddingBytes; i += 4) {
+                paddingWords.push(paddingWord);
+            }
+            var padding = WordArray.create(paddingWords, nPaddingBytes);
+
+            // Add padding
+            data.concat(padding);
+        },
+
+        /**
+         * Unpads data that had been padded using the algorithm defined in PKCS #5/7.
+         *
+         * @param {WordArray} data The data to unpad.
+         *
+         * @static
+         *
+         * @example
+         *
+         *     CryptoJS.pad.Pkcs7.unpad(wordArray);
+         */
+        unpad: function (data) {
+            // Get number of padding bytes from last byte
+            var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;
+
+            // Remove padding
+            data.sigBytes -= nPaddingBytes;
+        }
+    };
+
+    /**
+     * Abstract base block cipher template.
+     *
+     * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 4 (128 bits)
+     */
+    var BlockCipher = C_lib.BlockCipher = Cipher.extend({
+        /**
+         * Configuration options.
+         *
+         * @property {Mode} mode The block mode to use. Default: CBC
+         * @property {Padding} padding The padding strategy to use. Default: Pkcs7
+         */
+        cfg: Cipher.cfg.extend({
+            mode: CBC,
+            padding: Pkcs7
+        }),
+
+        reset: function () {
+            var modeCreator;
+
+            // Reset cipher
+            Cipher.reset.call(this);
+
+            // Shortcuts
+            var cfg = this.cfg;
+            var iv = cfg.iv;
+            var mode = cfg.mode;
+
+            // Reset block mode
+            if (this._xformMode == this._ENC_XFORM_MODE) {
+                modeCreator = mode.createEncryptor;
+            } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {
+                modeCreator = mode.createDecryptor;
+                // Keep at least one block in the buffer for unpadding
+                this._minBufferSize = 1;
+            }
+
+            if (this._mode && this._mode.__creator == modeCreator) {
+                this._mode.init(this, iv && iv.words);
+            } else {
+                this._mode = modeCreator.call(mode, this, iv && iv.words);
+                this._mode.__creator = modeCreator;
+            }
+        },
+
+        _doProcessBlock: function (words, offset) {
+            this._mode.processBlock(words, offset);
+        },
+
+        _doFinalize: function () {
+            var finalProcessedBlocks;
+
+            // Shortcut
+            var padding = this.cfg.padding;
+
+            // Finalize
+            if (this._xformMode == this._ENC_XFORM_MODE) {
+                // Pad data
+                padding.pad(this._data, this.blockSize);
+
+                // Process final blocks
+                finalProcessedBlocks = this._process(!!'flush');
+            } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {
+                // Process final blocks
+                finalProcessedBlocks = this._process(!!'flush');
+
+                // Unpad data
+                padding.unpad(finalProcessedBlocks);
+            }
+
+            return finalProcessedBlocks;
+        },
+
+        blockSize: 128/32
+    });
+
+    /**
+     * A collection of cipher parameters.
+     *
+     * @property {WordArray} ciphertext The raw ciphertext.
+     * @property {WordArray} key The key to this ciphertext.
+     * @property {WordArray} iv The IV used in the ciphering operation.
+     * @property {WordArray} salt The salt used with a key derivation function.
+     * @property {Cipher} algorithm The cipher algorithm.
+     * @property {Mode} mode The block mode used in the ciphering operation.
+     * @property {Padding} padding The padding scheme used in the ciphering operation.
+     * @property {number} blockSize The block size of the cipher.
+     * @property {Format} formatter The default formatting strategy to convert this cipher params object to a string.
+     */
+    var CipherParams = C_lib.CipherParams = Base.extend({
+        /**
+         * Initializes a newly created cipher params object.
+         *
+         * @param {Object} cipherParams An object with any of the possible cipher parameters.
+         *
+         * @example
+         *
+         *     var cipherParams = CryptoJS.lib.CipherParams.create({
+         *         ciphertext: ciphertextWordArray,
+         *         key: keyWordArray,
+         *         iv: ivWordArray,
+         *         salt: saltWordArray,
+         *         algorithm: CryptoJS.algo.AES,
+         *         mode: CryptoJS.mode.CBC,
+         *         padding: CryptoJS.pad.PKCS7,
+         *         blockSize: 4,
+         *         formatter: CryptoJS.format.OpenSSL
+         *     });
+         */
+        init: function (cipherParams) {
+            this.mixIn(cipherParams);
+        },
+
+        /**
+         * Converts this cipher params object to a string.
+         *
+         * @param {Format} formatter (Optional) The formatting strategy to use.
+         *
+         * @return {string} The stringified cipher params.
+         *
+         * @throws Error If neither the formatter nor the default formatter is set.
+         *
+         * @example
+         *
+         *     var string = cipherParams + '';
+         *     var string = cipherParams.toString();
+         *     var string = cipherParams.toString(CryptoJS.format.OpenSSL);
+         */
+        toString: function (formatter) {
+            return (formatter || this.formatter).stringify(this);
+        }
+    });
+
+    /**
+     * Format namespace.
+     */
+    var C_format = C.format = {};
+
+    /**
+     * OpenSSL formatting strategy.
+     */
+    var OpenSSLFormatter = C_format.OpenSSL = {
+        /**
+         * Converts a cipher params object to an OpenSSL-compatible string.
+         *
+         * @param {CipherParams} cipherParams The cipher params object.
+         *
+         * @return {string} The OpenSSL-compatible string.
+         *
+         * @static
+         *
+         * @example
+         *
+         *     var openSSLString = CryptoJS.format.OpenSSL.stringify(cipherParams);
+         */
+        stringify: function (cipherParams) {
+            var wordArray;
+
+            // Shortcuts
+            var ciphertext = cipherParams.ciphertext;
+            var salt = cipherParams.salt;
+
+            // Format
+            if (salt) {
+                wordArray = WordArray.create([0x53616c74, 0x65645f5f]).concat(salt).concat(ciphertext);
+            } else {
+                wordArray = ciphertext;
+            }
+
+            return wordArray.toString(Base64);
+        },
+
+        /**
+         * Converts an OpenSSL-compatible string to a cipher params object.
+         *
+         * @param {string} openSSLStr The OpenSSL-compatible string.
+         *
+         * @return {CipherParams} The cipher params object.
+         *
+         * @static
+         *
+         * @example
+         *
+         *     var cipherParams = CryptoJS.format.OpenSSL.parse(openSSLString);
+         */
+        parse: function (openSSLStr) {
+            var salt;
+
+            // Parse base64
+            var ciphertext = Base64.parse(openSSLStr);
+
+            // Shortcut
+            var ciphertextWords = ciphertext.words;
+
+            // Test for salt
+            if (ciphertextWords[0] == 0x53616c74 && ciphertextWords[1] == 0x65645f5f) {
+                // Extract salt
+                salt = WordArray.create(ciphertextWords.slice(2, 4));
+
+                // Remove salt from ciphertext
+                ciphertextWords.splice(0, 4);
+                ciphertext.sigBytes -= 16;
+            }
+
+            return CipherParams.create({ ciphertext: ciphertext, salt: salt });
+        }
+    };
+
+    /**
+     * A cipher wrapper that returns ciphertext as a serializable cipher params object.
+     */
+    var SerializableCipher = C_lib.SerializableCipher = Base.extend({
+        /**
+         * Configuration options.
+         *
+         * @property {Formatter} format The formatting strategy to convert cipher param objects to and from a string. Default: OpenSSL
+         */
+        cfg: Base.extend({
+            format: OpenSSLFormatter
+        }),
+
+        /**
+         * Encrypts a message.
+         *
+         * @param {Cipher} cipher The cipher algorithm to use.
+         * @param {WordArray|string} message The message to encrypt.
+         * @param {WordArray} key The key.
+         * @param {Object} cfg (Optional) The configuration options to use for this operation.
+         *
+         * @return {CipherParams} A cipher params object.
+         *
+         * @static
+         *
+         * @example
+         *
+         *     var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key);
+         *     var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv });
+         *     var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv, format: CryptoJS.format.OpenSSL });
+         */
+        encrypt: function (cipher, message, key, cfg) {
+            // Apply config defaults
+            cfg = this.cfg.extend(cfg);
+
+            // Encrypt
+            var encryptor = cipher.createEncryptor(key, cfg);
+            var ciphertext = encryptor.finalize(message);
+
+            // Shortcut
+            var cipherCfg = encryptor.cfg;
+
+            // Create and return serializable cipher params
+            return CipherParams.create({
+                ciphertext: ciphertext,
+                key: key,
+                iv: cipherCfg.iv,
+                algorithm: cipher,
+                mode: cipherCfg.mode,
+                padding: cipherCfg.padding,
+                blockSize: cipher.blockSize,
+                formatter: cfg.format
+            });
+        },
+
+        /**
+         * Decrypts serialized ciphertext.
+         *
+         * @param {Cipher} cipher The cipher algorithm to use.
+         * @param {CipherParams|string} ciphertext The ciphertext to decrypt.
+         * @param {WordArray} key The key.
+         * @param {Object} cfg (Optional) The configuration options to use for this operation.
+         *
+         * @return {WordArray} The plaintext.
+         *
+         * @static
+         *
+         * @example
+         *
+         *     var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, key, { iv: iv, format: CryptoJS.format.OpenSSL });
+         *     var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, key, { iv: iv, format: CryptoJS.format.OpenSSL });
+         */
+        decrypt: function (cipher, ciphertext, key, cfg) {
+            // Apply config defaults
+            cfg = this.cfg.extend(cfg);
+
+            // Convert string to CipherParams
+            ciphertext = this._parse(ciphertext, cfg.format);
+
+            // Decrypt
+            var plaintext = cipher.createDecryptor(key, cfg).finalize(ciphertext.ciphertext);
+
+            return plaintext;
+        },
+
+        /**
+         * Converts serialized ciphertext to CipherParams,
+         * else assumed CipherParams already and returns ciphertext unchanged.
+         *
+         * @param {CipherParams|string} ciphertext The ciphertext.
+         * @param {Formatter} format The formatting strategy to use to parse serialized ciphertext.
+         *
+         * @return {CipherParams} The unserialized ciphertext.
+         *
+         * @static
+         *
+         * @example
+         *
+         *     var ciphertextParams = CryptoJS.lib.SerializableCipher._parse(ciphertextStringOrParams, format);
+         */
+        _parse: function (ciphertext, format) {
+            if (typeof ciphertext == 'string') {
+                return format.parse(ciphertext, this);
+            } else {
+                return ciphertext;
+            }
+        }
+    });
+
+    /**
+     * Key derivation function namespace.
+     */
+    var C_kdf = C.kdf = {};
+
+    /**
+     * OpenSSL key derivation function.
+     */
+    var OpenSSLKdf = C_kdf.OpenSSL = {
+        /**
+         * Derives a key and IV from a password.
+         *
+         * @param {string} password The password to derive from.
+         * @param {number} keySize The size in words of the key to generate.
+         * @param {number} ivSize The size in words of the IV to generate.
+         * @param {WordArray|string} salt (Optional) A 64-bit salt to use. If omitted, a salt will be generated randomly.
+         *
+         * @return {CipherParams} A cipher params object with the key, IV, and salt.
+         *
+         * @static
+         *
+         * @example
+         *
+         *     var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32);
+         *     var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32, 'saltsalt');
+         */
+        execute: function (password, keySize, ivSize, salt, hasher) {
+            // Generate random salt
+            if (!salt) {
+                salt = WordArray.random(64/8);
+            }
+
+            // Derive key and IV
+            if (!hasher) {
+                var key = EvpKDF.create({ keySize: keySize + ivSize }).compute(password, salt);
+            } else {
+                var key = EvpKDF.create({ keySize: keySize + ivSize, hasher: hasher }).compute(password, salt);
+            }
+            
+
+            // Separate key and IV
+            var iv = WordArray.create(key.words.slice(keySize), ivSize * 4);
+            key.sigBytes = keySize * 4;
+
+            // Return params
+            return CipherParams.create({ key: key, iv: iv, salt: salt });
+        }
+    };
+
+    /**
+     * A serializable cipher wrapper that derives the key from a password,
+     * and returns ciphertext as a serializable cipher params object.
+     */
+    var PasswordBasedCipher = C_lib.PasswordBasedCipher = SerializableCipher.extend({
+        /**
+         * Configuration options.
+         *
+         * @property {KDF} kdf The key derivation function to use to generate a key and IV from a password. Default: OpenSSL
+         */
+        cfg: SerializableCipher.cfg.extend({
+            kdf: OpenSSLKdf
+        }),
+
+        /**
+         * Encrypts a message using a password.
+         *
+         * @param {Cipher} cipher The cipher algorithm to use.
+         * @param {WordArray|string} message The message to encrypt.
+         * @param {string} password The password.
+         * @param {Object} cfg (Optional) The configuration options to use for this operation.
+         *
+         * @return {CipherParams} A cipher params object.
+         *
+         * @static
+         *
+         * @example
+         *
+         *     var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password');
+         *     var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password', { format: CryptoJS.format.OpenSSL });
+         */
+        encrypt: function (cipher, message, password, cfg) {
+            // Apply config defaults
+            cfg = this.cfg.extend(cfg);
+
+            // Derive key and other params
+            var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize, cfg.salt, cfg.hasher);
+
+            // Add IV to config
+            cfg.iv = derivedParams.iv;
+
+            // Encrypt
+            var ciphertext = SerializableCipher.encrypt.call(this, cipher, message, derivedParams.key, cfg);
+
+            // Mix in derived params
+            ciphertext.mixIn(derivedParams);
+
+            return ciphertext;
+        },
+
+        /**
+         * Decrypts serialized ciphertext using a password.
+         *
+         * @param {Cipher} cipher The cipher algorithm to use.
+         * @param {CipherParams|string} ciphertext The ciphertext to decrypt.
+         * @param {string} password The password.
+         * @param {Object} cfg (Optional) The configuration options to use for this operation.
+         *
+         * @return {WordArray} The plaintext.
+         *
+         * @static
+         *
+         * @example
+         *
+         *     var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, 'password', { format: CryptoJS.format.OpenSSL });
+         *     var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, 'password', { format: CryptoJS.format.OpenSSL });
+         */
+        decrypt: function (cipher, ciphertext, password, cfg) {
+            // Apply config defaults
+            cfg = this.cfg.extend(cfg);
+
+            // Convert string to CipherParams
+            ciphertext = this._parse(ciphertext, cfg.format);
+
+            // Derive key and other params
+            var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize, ciphertext.salt, cfg.hasher);
+
+            // Add IV to config
+            cfg.iv = derivedParams.iv;
+
+            // Decrypt
+            var plaintext = SerializableCipher.decrypt.call(this, cipher, ciphertext, derivedParams.key, cfg);
+
+            return plaintext;
+        }
+    });
+}());
diff --git a/src/core.js b/src/core.js
new file mode 100644
index 0000000..e1330e7
--- /dev/null
+++ b/src/core.js
@@ -0,0 +1,787 @@
+/*globals window, global, require*/
+
+/**
+ * CryptoJS core components.
+ */
+var CryptoJS = CryptoJS || (function (Math, undefined) {
+
+    var crypto;
+
+    // Native crypto from window (Browser)
+    if (typeof window !== 'undefined' && window.crypto) {
+        crypto = window.crypto;
+    }
+
+    // Native crypto in web worker (Browser)
+    if (typeof self !== 'undefined' && self.crypto) {
+        crypto = self.crypto;
+    }
+
+    // Native crypto from worker
+    if (typeof globalThis !== 'undefined' && globalThis.crypto) {
+        crypto = globalThis.crypto;
+    }
+
+    // Native (experimental IE 11) crypto from window (Browser)
+    if (!crypto && typeof window !== 'undefined' && window.msCrypto) {
+        crypto = window.msCrypto;
+    }
+
+    // Native crypto from global (NodeJS)
+    if (!crypto && typeof global !== 'undefined' && global.crypto) {
+        crypto = global.crypto;
+    }
+
+    // Native crypto import via require (NodeJS)
+    if (!crypto && typeof require === 'function') {
+        try {
+            crypto = require('crypto');
+        } catch (err) {}
+    }
+
+    /*
+     * Cryptographically secure pseudorandom number generator
+     *
+     * As Math.random() is cryptographically not safe to use
+     */
+    var cryptoSecureRandomInt = function () {
+        if (crypto) {
+            // Use getRandomValues method (Browser)
+            if (typeof crypto.getRandomValues === 'function') {
+                try {
+                    return crypto.getRandomValues(new Uint32Array(1))[0];
+                } catch (err) {}
+            }
+
+            // Use randomBytes method (NodeJS)
+            if (typeof crypto.randomBytes === 'function') {
+                try {
+                    return crypto.randomBytes(4).readInt32LE();
+                } catch (err) {}
+            }
+        }
+
+        throw new Error('Native crypto module could not be used to get secure random number.');
+    };
+
+    /*
+     * Local polyfill of Object.create
+
+     */
+    var create = Object.create || (function () {
+        function F() {}
+
+        return function (obj) {
+            var subtype;
+
+            F.prototype = obj;
+
+            subtype = new F();
+
+            F.prototype = null;
+
+            return subtype;
+        };
+    }());
+
+    /**
+     * CryptoJS namespace.
+     */
+    var C = {};
+
+    /**
+     * Library namespace.
+     */
+    var C_lib = C.lib = {};
+
+    /**
+     * Base object for prototypal inheritance.
+     */
+    var Base = C_lib.Base = (function () {
+
+
+        return {
+            /**
+             * Creates a new object that inherits from this object.
+             *
+             * @param {Object} overrides Properties to copy into the new object.
+             *
+             * @return {Object} The new object.
+             *
+             * @static
+             *
+             * @example
+             *
+             *     var MyType = CryptoJS.lib.Base.extend({
+             *         field: 'value',
+             *
+             *         method: function () {
+             *         }
+             *     });
+             */
+            extend: function (overrides) {
+                // Spawn
+                var subtype = create(this);
+
+                // Augment
+                if (overrides) {
+                    subtype.mixIn(overrides);
+                }
+
+                // Create default initializer
+                if (!subtype.hasOwnProperty('init') || this.init === subtype.init) {
+                    subtype.init = function () {
+                        subtype.$super.init.apply(this, arguments);
+                    };
+                }
+
+                // Initializer's prototype is the subtype object
+                subtype.init.prototype = subtype;
+
+                // Reference supertype
+                subtype.$super = this;
+
+                return subtype;
+            },
+
+            /**
+             * Extends this object and runs the init method.
+             * Arguments to create() will be passed to init().
+             *
+             * @return {Object} The new object.
+             *
+             * @static
+             *
+             * @example
+             *
+             *     var instance = MyType.create();
+             */
+            create: function () {
+                var instance = this.extend();
+                instance.init.apply(instance, arguments);
+
+                return instance;
+            },
+
+            /**
+             * Initializes a newly created object.
+             * Override this method to add some logic when your objects are created.
+             *
+             * @example
+             *
+             *     var MyType = CryptoJS.lib.Base.extend({
+             *         init: function () {
+             *             // ...
+             *         }
+             *     });
+             */
+            init: function () {
+            },
+
+            /**
+             * Copies properties into this object.
+             *
+             * @param {Object} properties The properties to mix in.
+             *
+             * @example
+             *
+             *     MyType.mixIn({
+             *         field: 'value'
+             *     });
+             */
+            mixIn: function (properties) {
+                for (var propertyName in properties) {
+                    if (properties.hasOwnProperty(propertyName)) {
+                        this[propertyName] = properties[propertyName];
+                    }
+                }
+
+                // IE won't copy toString using the loop above
+                if (properties.hasOwnProperty('toString')) {
+                    this.toString = properties.toString;
+                }
+            },
+
+            /**
+             * Creates a copy of this object.
+             *
+             * @return {Object} The clone.
+             *
+             * @example
+             *
+             *     var clone = instance.clone();
+             */
+            clone: function () {
+                return this.init.prototype.extend(this);
+            }
+        };
+    }());
+
+    /**
+     * An array of 32-bit words.
+     *
+     * @property {Array} words The array of 32-bit words.
+     * @property {number} sigBytes The number of significant bytes in this word array.
+     */
+    var WordArray = C_lib.WordArray = Base.extend({
+        /**
+         * Initializes a newly created word array.
+         *
+         * @param {Array} words (Optional) An array of 32-bit words.
+         * @param {number} sigBytes (Optional) The number of significant bytes in the words.
+         *
+         * @example
+         *
+         *     var wordArray = CryptoJS.lib.WordArray.create();
+         *     var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]);
+         *     var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6);
+         */
+        init: function (words, sigBytes) {
+            words = this.words = words || [];
+
+            if (sigBytes != undefined) {
+                this.sigBytes = sigBytes;
+            } else {
+                this.sigBytes = words.length * 4;
+            }
+        },
+
+        /**
+         * Converts this word array to a string.
+         *
+         * @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex
+         *
+         * @return {string} The stringified word array.
+         *
+         * @example
+         *
+         *     var string = wordArray + '';
+         *     var string = wordArray.toString();
+         *     var string = wordArray.toString(CryptoJS.enc.Utf8);
+         */
+        toString: function (encoder) {
+            return (encoder || Hex).stringify(this);
+        },
+
+        /**
+         * Concatenates a word array to this word array.
+         *
+         * @param {WordArray} wordArray The word array to append.
+         *
+         * @return {WordArray} This word array.
+         *
+         * @example
+         *
+         *     wordArray1.concat(wordArray2);
+         */
+        concat: function (wordArray) {
+            // Shortcuts
+            var thisWords = this.words;
+            var thatWords = wordArray.words;
+            var thisSigBytes = this.sigBytes;
+            var thatSigBytes = wordArray.sigBytes;
+
+            // Clamp excess bits
+            this.clamp();
+
+            // Concat
+            if (thisSigBytes % 4) {
+                // Copy one byte at a time
+                for (var i = 0; i < thatSigBytes; i++) {
+                    var thatByte = (thatWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
+                    thisWords[(thisSigBytes + i) >>> 2] |= thatByte << (24 - ((thisSigBytes + i) % 4) * 8);
+                }
+            } else {
+                // Copy one word at a time
+                for (var j = 0; j < thatSigBytes; j += 4) {
+                    thisWords[(thisSigBytes + j) >>> 2] = thatWords[j >>> 2];
+                }
+            }
+            this.sigBytes += thatSigBytes;
+
+            // Chainable
+            return this;
+        },
+
+        /**
+         * Removes insignificant bits.
+         *
+         * @example
+         *
+         *     wordArray.clamp();
+         */
+        clamp: function () {
+            // Shortcuts
+            var words = this.words;
+            var sigBytes = this.sigBytes;
+
+            // Clamp
+            words[sigBytes >>> 2] &= 0xffffffff << (32 - (sigBytes % 4) * 8);
+            words.length = Math.ceil(sigBytes / 4);
+        },
+
+        /**
+         * Creates a copy of this word array.
+         *
+         * @return {WordArray} The clone.
+         *
+         * @example
+         *
+         *     var clone = wordArray.clone();
+         */
+        clone: function () {
+            var clone = Base.clone.call(this);
+            clone.words = this.words.slice(0);
+
+            return clone;
+        },
+
+        /**
+         * Creates a word array filled with random bytes.
+         *
+         * @param {number} nBytes The number of random bytes to generate.
+         *
+         * @return {WordArray} The random word array.
+         *
+         * @static
+         *
+         * @example
+         *
+         *     var wordArray = CryptoJS.lib.WordArray.random(16);
+         */
+        random: function (nBytes) {
+            var words = [];
+
+            for (var i = 0; i < nBytes; i += 4) {
+                words.push(cryptoSecureRandomInt());
+            }
+
+            return new WordArray.init(words, nBytes);
+        }
+    });
+
+    /**
+     * Encoder namespace.
+     */
+    var C_enc = C.enc = {};
+
+    /**
+     * Hex encoding strategy.
+     */
+    var Hex = C_enc.Hex = {
+        /**
+         * Converts a word array to a hex string.
+         *
+         * @param {WordArray} wordArray The word array.
+         *
+         * @return {string} The hex string.
+         *
+         * @static
+         *
+         * @example
+         *
+         *     var hexString = CryptoJS.enc.Hex.stringify(wordArray);
+         */
+        stringify: function (wordArray) {
+            // Shortcuts
+            var words = wordArray.words;
+            var sigBytes = wordArray.sigBytes;
+
+            // Convert
+            var hexChars = [];
+            for (var i = 0; i < sigBytes; i++) {
+                var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
+                hexChars.push((bite >>> 4).toString(16));
+                hexChars.push((bite & 0x0f).toString(16));
+            }
+
+            return hexChars.join('');
+        },
+
+        /**
+         * Converts a hex string to a word array.
+         *
+         * @param {string} hexStr The hex string.
+         *
+         * @return {WordArray} The word array.
+         *
+         * @static
+         *
+         * @example
+         *
+         *     var wordArray = CryptoJS.enc.Hex.parse(hexString);
+         */
+        parse: function (hexStr) {
+            // Shortcut
+            var hexStrLength = hexStr.length;
+
+            // Convert
+            var words = [];
+            for (var i = 0; i < hexStrLength; i += 2) {
+                words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << (24 - (i % 8) * 4);
+            }
+
+            return new WordArray.init(words, hexStrLength / 2);
+        }
+    };
+
+    /**
+     * Latin1 encoding strategy.
+     */
+    var Latin1 = C_enc.Latin1 = {
+        /**
+         * Converts a word array to a Latin1 string.
+         *
+         * @param {WordArray} wordArray The word array.
+         *
+         * @return {string} The Latin1 string.
+         *
+         * @static
+         *
+         * @example
+         *
+         *     var latin1String = CryptoJS.enc.Latin1.stringify(wordArray);
+         */
+        stringify: function (wordArray) {
+            // Shortcuts
+            var words = wordArray.words;
+            var sigBytes = wordArray.sigBytes;
+
+            // Convert
+            var latin1Chars = [];
+            for (var i = 0; i < sigBytes; i++) {
+                var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
+                latin1Chars.push(String.fromCharCode(bite));
+            }
+
+            return latin1Chars.join('');
+        },
+
+        /**
+         * Converts a Latin1 string to a word array.
+         *
+         * @param {string} latin1Str The Latin1 string.
+         *
+         * @return {WordArray} The word array.
+         *
+         * @static
+         *
+         * @example
+         *
+         *     var wordArray = CryptoJS.enc.Latin1.parse(latin1String);
+         */
+        parse: function (latin1Str) {
+            // Shortcut
+            var latin1StrLength = latin1Str.length;
+
+            // Convert
+            var words = [];
+            for (var i = 0; i < latin1StrLength; i++) {
+                words[i >>> 2] |= (latin1Str.charCodeAt(i) & 0xff) << (24 - (i % 4) * 8);
+            }
+
+            return new WordArray.init(words, latin1StrLength);
+        }
+    };
+
+    /**
+     * UTF-8 encoding strategy.
+     */
+    var Utf8 = C_enc.Utf8 = {
+        /**
+         * Converts a word array to a UTF-8 string.
+         *
+         * @param {WordArray} wordArray The word array.
+         *
+         * @return {string} The UTF-8 string.
+         *
+         * @static
+         *
+         * @example
+         *
+         *     var utf8String = CryptoJS.enc.Utf8.stringify(wordArray);
+         */
+        stringify: function (wordArray) {
+            try {
+                return decodeURIComponent(escape(Latin1.stringify(wordArray)));
+            } catch (e) {
+                throw new Error('Malformed UTF-8 data');
+            }
+        },
+
+        /**
+         * Converts a UTF-8 string to a word array.
+         *
+         * @param {string} utf8Str The UTF-8 string.
+         *
+         * @return {WordArray} The word array.
+         *
+         * @static
+         *
+         * @example
+         *
+         *     var wordArray = CryptoJS.enc.Utf8.parse(utf8String);
+         */
+        parse: function (utf8Str) {
+            return Latin1.parse(unescape(encodeURIComponent(utf8Str)));
+        }
+    };
+
+    /**
+     * Abstract buffered block algorithm template.
+     *
+     * The property blockSize must be implemented in a concrete subtype.
+     *
+     * @property {number} _minBufferSize The number of blocks that should be kept unprocessed in the buffer. Default: 0
+     */
+    var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({
+        /**
+         * Resets this block algorithm's data buffer to its initial state.
+         *
+         * @example
+         *
+         *     bufferedBlockAlgorithm.reset();
+         */
+        reset: function () {
+            // Initial values
+            this._data = new WordArray.init();
+            this._nDataBytes = 0;
+        },
+
+        /**
+         * Adds new data to this block algorithm's buffer.
+         *
+         * @param {WordArray|string} data The data to append. Strings are converted to a WordArray using UTF-8.
+         *
+         * @example
+         *
+         *     bufferedBlockAlgorithm._append('data');
+         *     bufferedBlockAlgorithm._append(wordArray);
+         */
+        _append: function (data) {
+            // Convert string to WordArray, else assume WordArray already
+            if (typeof data == 'string') {
+                data = Utf8.parse(data);
+            }
+
+            // Append
+            this._data.concat(data);
+            this._nDataBytes += data.sigBytes;
+        },
+
+        /**
+         * Processes available data blocks.
+         *
+         * This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype.
+         *
+         * @param {boolean} doFlush Whether all blocks and partial blocks should be processed.
+         *
+         * @return {WordArray} The processed data.
+         *
+         * @example
+         *
+         *     var processedData = bufferedBlockAlgorithm._process();
+         *     var processedData = bufferedBlockAlgorithm._process(!!'flush');
+         */
+        _process: function (doFlush) {
+            var processedWords;
+
+            // Shortcuts
+            var data = this._data;
+            var dataWords = data.words;
+            var dataSigBytes = data.sigBytes;
+            var blockSize = this.blockSize;
+            var blockSizeBytes = blockSize * 4;
+
+            // Count blocks ready
+            var nBlocksReady = dataSigBytes / blockSizeBytes;
+            if (doFlush) {
+                // Round up to include partial blocks
+                nBlocksReady = Math.ceil(nBlocksReady);
+            } else {
+                // Round down to include only full blocks,
+                // less the number of blocks that must remain in the buffer
+                nBlocksReady = Math.max((nBlocksReady | 0) - this._minBufferSize, 0);
+            }
+
+            // Count words ready
+            var nWordsReady = nBlocksReady * blockSize;
+
+            // Count bytes ready
+            var nBytesReady = Math.min(nWordsReady * 4, dataSigBytes);
+
+            // Process blocks
+            if (nWordsReady) {
+                for (var offset = 0; offset < nWordsReady; offset += blockSize) {
+                    // Perform concrete-algorithm logic
+                    this._doProcessBlock(dataWords, offset);
+                }
+
+                // Remove processed words
+                processedWords = dataWords.splice(0, nWordsReady);
+                data.sigBytes -= nBytesReady;
+            }
+
+            // Return processed words
+            return new WordArray.init(processedWords, nBytesReady);
+        },
+
+        /**
+         * Creates a copy of this object.
+         *
+         * @return {Object} The clone.
+         *
+         * @example
+         *
+         *     var clone = bufferedBlockAlgorithm.clone();
+         */
+        clone: function () {
+            var clone = Base.clone.call(this);
+            clone._data = this._data.clone();
+
+            return clone;
+        },
+
+        _minBufferSize: 0
+    });
+
+    /**
+     * Abstract hasher template.
+     *
+     * @property {number} blockSize The number of 32-bit words this hasher operates on. Default: 16 (512 bits)
+     */
+    var Hasher = C_lib.Hasher = BufferedBlockAlgorithm.extend({
+        /**
+         * Configuration options.
+         */
+        cfg: Base.extend(),
+
+        /**
+         * Initializes a newly created hasher.
+         *
+         * @param {Object} cfg (Optional) The configuration options to use for this hash computation.
+         *
+         * @example
+         *
+         *     var hasher = CryptoJS.algo.SHA256.create();
+         */
+        init: function (cfg) {
+            // Apply config defaults
+            this.cfg = this.cfg.extend(cfg);
+
+            // Set initial values
+            this.reset();
+        },
+
+        /**
+         * Resets this hasher to its initial state.
+         *
+         * @example
+         *
+         *     hasher.reset();
+         */
+        reset: function () {
+            // Reset data buffer
+            BufferedBlockAlgorithm.reset.call(this);
+
+            // Perform concrete-hasher logic
+            this._doReset();
+        },
+
+        /**
+         * Updates this hasher with a message.
+         *
+         * @param {WordArray|string} messageUpdate The message to append.
+         *
+         * @return {Hasher} This hasher.
+         *
+         * @example
+         *
+         *     hasher.update('message');
+         *     hasher.update(wordArray);
+         */
+        update: function (messageUpdate) {
+            // Append
+            this._append(messageUpdate);
+
+            // Update the hash
+            this._process();
+
+            // Chainable
+            return this;
+        },
+
+        /**
+         * Finalizes the hash computation.
+         * Note that the finalize operation is effectively a destructive, read-once operation.
+         *
+         * @param {WordArray|string} messageUpdate (Optional) A final message update.
+         *
+         * @return {WordArray} The hash.
+         *
+         * @example
+         *
+         *     var hash = hasher.finalize();
+         *     var hash = hasher.finalize('message');
+         *     var hash = hasher.finalize(wordArray);
+         */
+        finalize: function (messageUpdate) {
+            // Final message update
+            if (messageUpdate) {
+                this._append(messageUpdate);
+            }
+
+            // Perform concrete-hasher logic
+            var hash = this._doFinalize();
+
+            return hash;
+        },
+
+        blockSize: 512/32,
+
+        /**
+         * Creates a shortcut function to a hasher's object interface.
+         *
+         * @param {Hasher} hasher The hasher to create a helper for.
+         *
+         * @return {Function} The shortcut function.
+         *
+         * @static
+         *
+         * @example
+         *
+         *     var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256);
+         */
+        _createHelper: function (hasher) {
+            return function (message, cfg) {
+                return new hasher.init(cfg).finalize(message);
+            };
+        },
+
+        /**
+         * Creates a shortcut function to the HMAC's object interface.
+         *
+         * @param {Hasher} hasher The hasher to use in this HMAC helper.
+         *
+         * @return {Function} The shortcut function.
+         *
+         * @static
+         *
+         * @example
+         *
+         *     var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256);
+         */
+        _createHmacHelper: function (hasher) {
+            return function (message, key) {
+                return new C_algo.HMAC.init(hasher, key).finalize(message);
+            };
+        }
+    });
+
+    /**
+     * Algorithm namespace.
+     */
+    var C_algo = C.algo = {};
+
+    return C;
+}(Math));
diff --git a/src/enc-base64.js b/src/enc-base64.js
new file mode 100644
index 0000000..a32b9a4
--- /dev/null
+++ b/src/enc-base64.js
@@ -0,0 +1,116 @@
+(function () {
+    // Shortcuts
+    var C = CryptoJS;
+    var C_lib = C.lib;
+    var WordArray = C_lib.WordArray;
+    var C_enc = C.enc;
+
+    /**
+     * Base64 encoding strategy.
+     */
+    var Base64 = C_enc.Base64 = {
+        /**
+         * Converts a word array to a Base64 string.
+         *
+         * @param {WordArray} wordArray The word array.
+         *
+         * @return {string} The Base64 string.
+         *
+         * @static
+         *
+         * @example
+         *
+         *     var base64String = CryptoJS.enc.Base64.stringify(wordArray);
+         */
+        stringify: function (wordArray) {
+            // Shortcuts
+            var words = wordArray.words;
+            var sigBytes = wordArray.sigBytes;
+            var map = this._map;
+
+            // Clamp excess bits
+            wordArray.clamp();
+
+            // Convert
+            var base64Chars = [];
+            for (var i = 0; i < sigBytes; i += 3) {
+                var byte1 = (words[i >>> 2]       >>> (24 - (i % 4) * 8))       & 0xff;
+                var byte2 = (words[(i + 1) >>> 2] >>> (24 - ((i + 1) % 4) * 8)) & 0xff;
+                var byte3 = (words[(i + 2) >>> 2] >>> (24 - ((i + 2) % 4) * 8)) & 0xff;
+
+                var triplet = (byte1 << 16) | (byte2 << 8) | byte3;
+
+                for (var j = 0; (j < 4) && (i + j * 0.75 < sigBytes); j++) {
+                    base64Chars.push(map.charAt((triplet >>> (6 * (3 - j))) & 0x3f));
+                }
+            }
+
+            // Add padding
+            var paddingChar = map.charAt(64);
+            if (paddingChar) {
+                while (base64Chars.length % 4) {
+                    base64Chars.push(paddingChar);
+                }
+            }
+
+            return base64Chars.join('');
+        },
+
+        /**
+         * Converts a Base64 string to a word array.
+         *
+         * @param {string} base64Str The Base64 string.
+         *
+         * @return {WordArray} The word array.
+         *
+         * @static
+         *
+         * @example
+         *
+         *     var wordArray = CryptoJS.enc.Base64.parse(base64String);
+         */
+        parse: function (base64Str) {
+            // Shortcuts
+            var base64StrLength = base64Str.length;
+            var map = this._map;
+            var reverseMap = this._reverseMap;
+
+            if (!reverseMap) {
+                    reverseMap = this._reverseMap = [];
+                    for (var j = 0; j < map.length; j++) {
+                        reverseMap[map.charCodeAt(j)] = j;
+                    }
+            }
+
+            // Ignore padding
+            var paddingChar = map.charAt(64);
+            if (paddingChar) {
+                var paddingIndex = base64Str.indexOf(paddingChar);
+                if (paddingIndex !== -1) {
+                    base64StrLength = paddingIndex;
+                }
+            }
+
+            // Convert
+            return parseLoop(base64Str, base64StrLength, reverseMap);
+
+        },
+
+        _map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='
+    };
+
+    function parseLoop(base64Str, base64StrLength, reverseMap) {
+      var words = [];
+      var nBytes = 0;
+      for (var i = 0; i < base64StrLength; i++) {
+          if (i % 4) {
+              var bits1 = reverseMap[base64Str.charCodeAt(i - 1)] << ((i % 4) * 2);
+              var bits2 = reverseMap[base64Str.charCodeAt(i)] >>> (6 - (i % 4) * 2);
+              var bitsCombined = bits1 | bits2;
+              words[nBytes >>> 2] |= bitsCombined << (24 - (nBytes % 4) * 8);
+              nBytes++;
+          }
+      }
+      return WordArray.create(words, nBytes);
+    }
+}());
diff --git a/src/enc-base64url.js b/src/enc-base64url.js
new file mode 100644
index 0000000..73b6262
--- /dev/null
+++ b/src/enc-base64url.js
@@ -0,0 +1,128 @@
+(function () {
+    // Shortcuts
+    var C = CryptoJS;
+    var C_lib = C.lib;
+    var WordArray = C_lib.WordArray;
+    var C_enc = C.enc;
+
+    /**
+     * Base64url encoding strategy.
+     */
+    var Base64url = C_enc.Base64url = {
+        /**
+         * Converts a word array to a Base64url string.
+         *
+         * @param {WordArray} wordArray The word array.
+         *
+         * @param {boolean} urlSafe Whether to use url safe
+         *
+         * @return {string} The Base64url string.
+         *
+         * @static
+         *
+         * @example
+         *
+         *     var base64String = CryptoJS.enc.Base64url.stringify(wordArray);
+         */
+        stringify: function (wordArray, urlSafe) {
+            if (urlSafe === undefined) {
+                urlSafe = true
+            }
+            // Shortcuts
+            var words = wordArray.words;
+            var sigBytes = wordArray.sigBytes;
+            var map = urlSafe ? this._safe_map : this._map;
+
+            // Clamp excess bits
+            wordArray.clamp();
+
+            // Convert
+            var base64Chars = [];
+            for (var i = 0; i < sigBytes; i += 3) {
+                var byte1 = (words[i >>> 2]       >>> (24 - (i % 4) * 8))       & 0xff;
+                var byte2 = (words[(i + 1) >>> 2] >>> (24 - ((i + 1) % 4) * 8)) & 0xff;
+                var byte3 = (words[(i + 2) >>> 2] >>> (24 - ((i + 2) % 4) * 8)) & 0xff;
+
+                var triplet = (byte1 << 16) | (byte2 << 8) | byte3;
+
+                for (var j = 0; (j < 4) && (i + j * 0.75 < sigBytes); j++) {
+                    base64Chars.push(map.charAt((triplet >>> (6 * (3 - j))) & 0x3f));
+                }
+            }
+
+            // Add padding
+            var paddingChar = map.charAt(64);
+            if (paddingChar) {
+                while (base64Chars.length % 4) {
+                    base64Chars.push(paddingChar);
+                }
+            }
+
+            return base64Chars.join('');
+        },
+
+        /**
+         * Converts a Base64url string to a word array.
+         *
+         * @param {string} base64Str The Base64url string.
+         *
+         * @param {boolean} urlSafe Whether to use url safe
+         *
+         * @return {WordArray} The word array.
+         *
+         * @static
+         *
+         * @example
+         *
+         *     var wordArray = CryptoJS.enc.Base64url.parse(base64String);
+         */
+        parse: function (base64Str, urlSafe) {
+            if (urlSafe === undefined) {
+                urlSafe = true
+            }
+
+            // Shortcuts
+            var base64StrLength = base64Str.length;
+            var map = urlSafe ? this._safe_map : this._map;
+            var reverseMap = this._reverseMap;
+
+            if (!reverseMap) {
+                reverseMap = this._reverseMap = [];
+                for (var j = 0; j < map.length; j++) {
+                    reverseMap[map.charCodeAt(j)] = j;
+                }
+            }
+
+            // Ignore padding
+            var paddingChar = map.charAt(64);
+            if (paddingChar) {
+                var paddingIndex = base64Str.indexOf(paddingChar);
+                if (paddingIndex !== -1) {
+                    base64StrLength = paddingIndex;
+                }
+            }
+
+            // Convert
+            return parseLoop(base64Str, base64StrLength, reverseMap);
+
+        },
+
+        _map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=',
+        _safe_map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_',
+    };
+
+    function parseLoop(base64Str, base64StrLength, reverseMap) {
+        var words = [];
+        var nBytes = 0;
+        for (var i = 0; i < base64StrLength; i++) {
+            if (i % 4) {
+                var bits1 = reverseMap[base64Str.charCodeAt(i - 1)] << ((i % 4) * 2);
+                var bits2 = reverseMap[base64Str.charCodeAt(i)] >>> (6 - (i % 4) * 2);
+                var bitsCombined = bits1 | bits2;
+                words[nBytes >>> 2] |= bitsCombined << (24 - (nBytes % 4) * 8);
+                nBytes++;
+            }
+        }
+        return WordArray.create(words, nBytes);
+    }
+}());
diff --git a/src/enc-utf16.js b/src/enc-utf16.js
new file mode 100644
index 0000000..a13cf20
--- /dev/null
+++ b/src/enc-utf16.js
@@ -0,0 +1,129 @@
+(function () {
+    // Shortcuts
+    var C = CryptoJS;
+    var C_lib = C.lib;
+    var WordArray = C_lib.WordArray;
+    var C_enc = C.enc;
+
+    /**
+     * UTF-16 BE encoding strategy.
+     */
+    var Utf16BE = C_enc.Utf16 = C_enc.Utf16BE = {
+        /**
+         * Converts a word array to a UTF-16 BE string.
+         *
+         * @param {WordArray} wordArray The word array.
+         *
+         * @return {string} The UTF-16 BE string.
+         *
+         * @static
+         *
+         * @example
+         *
+         *     var utf16String = CryptoJS.enc.Utf16.stringify(wordArray);
+         */
+        stringify: function (wordArray) {
+            // Shortcuts
+            var words = wordArray.words;
+            var sigBytes = wordArray.sigBytes;
+
+            // Convert
+            var utf16Chars = [];
+            for (var i = 0; i < sigBytes; i += 2) {
+                var codePoint = (words[i >>> 2] >>> (16 - (i % 4) * 8)) & 0xffff;
+                utf16Chars.push(String.fromCharCode(codePoint));
+            }
+
+            return utf16Chars.join('');
+        },
+
+        /**
+         * Converts a UTF-16 BE string to a word array.
+         *
+         * @param {string} utf16Str The UTF-16 BE string.
+         *
+         * @return {WordArray} The word array.
+         *
+         * @static
+         *
+         * @example
+         *
+         *     var wordArray = CryptoJS.enc.Utf16.parse(utf16String);
+         */
+        parse: function (utf16Str) {
+            // Shortcut
+            var utf16StrLength = utf16Str.length;
+
+            // Convert
+            var words = [];
+            for (var i = 0; i < utf16StrLength; i++) {
+                words[i >>> 1] |= utf16Str.charCodeAt(i) << (16 - (i % 2) * 16);
+            }
+
+            return WordArray.create(words, utf16StrLength * 2);
+        }
+    };
+
+    /**
+     * UTF-16 LE encoding strategy.
+     */
+    C_enc.Utf16LE = {
+        /**
+         * Converts a word array to a UTF-16 LE string.
+         *
+         * @param {WordArray} wordArray The word array.
+         *
+         * @return {string} The UTF-16 LE string.
+         *
+         * @static
+         *
+         * @example
+         *
+         *     var utf16Str = CryptoJS.enc.Utf16LE.stringify(wordArray);
+         */
+        stringify: function (wordArray) {
+            // Shortcuts
+            var words = wordArray.words;
+            var sigBytes = wordArray.sigBytes;
+
+            // Convert
+            var utf16Chars = [];
+            for (var i = 0; i < sigBytes; i += 2) {
+                var codePoint = swapEndian((words[i >>> 2] >>> (16 - (i % 4) * 8)) & 0xffff);
+                utf16Chars.push(String.fromCharCode(codePoint));
+            }
+
+            return utf16Chars.join('');
+        },
+
+        /**
+         * Converts a UTF-16 LE string to a word array.
+         *
+         * @param {string} utf16Str The UTF-16 LE string.
+         *
+         * @return {WordArray} The word array.
+         *
+         * @static
+         *
+         * @example
+         *
+         *     var wordArray = CryptoJS.enc.Utf16LE.parse(utf16Str);
+         */
+        parse: function (utf16Str) {
+            // Shortcut
+            var utf16StrLength = utf16Str.length;
+
+            // Convert
+            var words = [];
+            for (var i = 0; i < utf16StrLength; i++) {
+                words[i >>> 1] |= swapEndian(utf16Str.charCodeAt(i) << (16 - (i % 2) * 16));
+            }
+
+            return WordArray.create(words, utf16StrLength * 2);
+        }
+    };
+
+    function swapEndian(word) {
+        return ((word << 8) & 0xff00ff00) | ((word >>> 8) & 0x00ff00ff);
+    }
+}());
diff --git a/src/evpkdf.js b/src/evpkdf.js
new file mode 100644
index 0000000..2bc993e
--- /dev/null
+++ b/src/evpkdf.js
@@ -0,0 +1,114 @@
+(function () {
+    // Shortcuts
+    var C = CryptoJS;
+    var C_lib = C.lib;
+    var Base = C_lib.Base;
+    var WordArray = C_lib.WordArray;
+    var C_algo = C.algo;
+    var MD5 = C_algo.MD5;
+
+    /**
+     * This key derivation function is meant to conform with EVP_BytesToKey.
+     * www.openssl.org/docs/crypto/EVP_BytesToKey.html
+     */
+    var EvpKDF = C_algo.EvpKDF = Base.extend({
+        /**
+         * Configuration options.
+         *
+         * @property {number} keySize The key size in words to generate. Default: 4 (128 bits)
+         * @property {Hasher} hasher The hash algorithm to use. Default: MD5
+         * @property {number} iterations The number of iterations to perform. Default: 1
+         */
+        cfg: Base.extend({
+            keySize: 128/32,
+            hasher: MD5,
+            iterations: 1
+        }),
+
+        /**
+         * Initializes a newly created key derivation function.
+         *
+         * @param {Object} cfg (Optional) The configuration options to use for the derivation.
+         *
+         * @example
+         *
+         *     var kdf = CryptoJS.algo.EvpKDF.create();
+         *     var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8 });
+         *     var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8, iterations: 1000 });
+         */
+        init: function (cfg) {
+            this.cfg = this.cfg.extend(cfg);
+        },
+
+        /**
+         * Derives a key from a password.
+         *
+         * @param {WordArray|string} password The password.
+         * @param {WordArray|string} salt A salt.
+         *
+         * @return {WordArray} The derived key.
+         *
+         * @example
+         *
+         *     var key = kdf.compute(password, salt);
+         */
+        compute: function (password, salt) {
+            var block;
+
+            // Shortcut
+            var cfg = this.cfg;
+
+            // Init hasher
+            var hasher = cfg.hasher.create();
+
+            // Initial values
+            var derivedKey = WordArray.create();
+
+            // Shortcuts
+            var derivedKeyWords = derivedKey.words;
+            var keySize = cfg.keySize;
+            var iterations = cfg.iterations;
+
+            // Generate key
+            while (derivedKeyWords.length < keySize) {
+                if (block) {
+                    hasher.update(block);
+                }
+                block = hasher.update(password).finalize(salt);
+                hasher.reset();
+
+                // Iterations
+                for (var i = 1; i < iterations; i++) {
+                    block = hasher.finalize(block);
+                    hasher.reset();
+                }
+
+                derivedKey.concat(block);
+            }
+            derivedKey.sigBytes = keySize * 4;
+
+            return derivedKey;
+        }
+    });
+
+    /**
+     * Derives a key from a password.
+     *
+     * @param {WordArray|string} password The password.
+     * @param {WordArray|string} salt A salt.
+     * @param {Object} cfg (Optional) The configuration options to use for this computation.
+     *
+     * @return {WordArray} The derived key.
+     *
+     * @static
+     *
+     * @example
+     *
+     *     var key = CryptoJS.EvpKDF(password, salt);
+     *     var key = CryptoJS.EvpKDF(password, salt, { keySize: 8 });
+     *     var key = CryptoJS.EvpKDF(password, salt, { keySize: 8, iterations: 1000 });
+     */
+    C.EvpKDF = function (password, salt, cfg) {
+        return EvpKDF.create(cfg).compute(password, salt);
+    };
+}());
diff --git a/src/format-hex.js b/src/format-hex.js
new file mode 100644
index 0000000..d967034
--- /dev/null
+++ b/src/format-hex.js
@@ -0,0 +1,46 @@
+(function (undefined) {
+    // Shortcuts
+    var C = CryptoJS;
+    var C_lib = C.lib;
+    var CipherParams = C_lib.CipherParams;
+    var C_enc = C.enc;
+    var Hex = C_enc.Hex;
+    var C_format = C.format;
+
+    var HexFormatter = C_format.Hex = {
+        /**
+         * Converts the ciphertext of a cipher params object to a hexadecimally encoded string.
+         *
+         * @param {CipherParams} cipherParams The cipher params object.
+         *
+         * @return {string} The hexadecimally encoded string.
+         *
+         * @static
+         *
+         * @example
+         *
+         *     var hexString = CryptoJS.format.Hex.stringify(cipherParams);
+         */
+        stringify: function (cipherParams) {
+            return cipherParams.ciphertext.toString(Hex);
+        },
+
+        /**
+         * Converts a hexadecimally encoded ciphertext string to a cipher params object.
+         *
+         * @param {string} input The hexadecimally encoded string.
+         *
+         * @return {CipherParams} The cipher params object.
+         *
+         * @static
+         *
+         * @example
+         *
+         *     var cipherParams = CryptoJS.format.Hex.parse(hexString);
+         */
+        parse: function (input) {
+            var ciphertext = Hex.parse(input);
+            return CipherParams.create({ ciphertext: ciphertext });
+        }
+    };
+}());
diff --git a/src/hmac.js b/src/hmac.js
new file mode 100644
index 0000000..24762a9
--- /dev/null
+++ b/src/hmac.js
@@ -0,0 +1,125 @@
+(function () {
+    // Shortcuts
+    var C = CryptoJS;
+    var C_lib = C.lib;
+    var Base = C_lib.Base;
+    var C_enc = C.enc;
+    var Utf8 = C_enc.Utf8;
+    var C_algo = C.algo;
+
+    /**
+     * HMAC algorithm.
+     */
+    var HMAC = C_algo.HMAC = Base.extend({
+        /**
+         * Initializes a newly created HMAC.
+         *
+         * @param {Hasher} hasher The hash algorithm to use.
+         * @param {WordArray|string} key The secret key.
+         *
+         * @example
+         *
+         *     var hmacHasher = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA256, key);
+         */
+        init: function (hasher, key) {
+            // Init hasher
+            hasher = this._hasher = new hasher.init();
+
+            // Convert string to WordArray, else assume WordArray already
+            if (typeof key == 'string') {
+                key = Utf8.parse(key);
+            }
+
+            // Shortcuts
+            var hasherBlockSize = hasher.blockSize;
+            var hasherBlockSizeBytes = hasherBlockSize * 4;
+
+            // Allow arbitrary length keys
+            if (key.sigBytes > hasherBlockSizeBytes) {
+                key = hasher.finalize(key);
+            }
+
+            // Clamp excess bits
+            key.clamp();
+
+            // Clone key for inner and outer pads
+            var oKey = this._oKey = key.clone();
+            var iKey = this._iKey = key.clone();
+
+            // Shortcuts
+            var oKeyWords = oKey.words;
+            var iKeyWords = iKey.words;
+
+            // XOR keys with pad constants
+            for (var i = 0; i < hasherBlockSize; i++) {
+                oKeyWords[i] ^= 0x5c5c5c5c;
+                iKeyWords[i] ^= 0x36363636;
+            }
+            oKey.sigBytes = iKey.sigBytes = hasherBlockSizeBytes;
+
+            // Set initial values
+            this.reset();
+        },
+
+        /**
+         * Resets this HMAC to its initial state.
+         *
+         * @example
+         *
+         *     hmacHasher.reset();
+         */
+        reset: function () {
+            // Shortcut
+            var hasher = this._hasher;
+
+            // Reset
+            hasher.reset();
+            hasher.update(this._iKey);
+        },
+
+        /**
+         * Updates this HMAC with a message.
+         *
+         * @param {WordArray|string} messageUpdate The message to append.
+         *
+         * @return {HMAC} This HMAC instance.
+         *
+         * @example
+         *
+         *     hmacHasher.update('message');
+         *     hmacHasher.update(wordArray);
+         */
+        update: function (messageUpdate) {
+            this._hasher.update(messageUpdate);
+
+            // Chainable
+            return this;
+        },
+
+        /**
+         * Finalizes the HMAC computation.
+         * Note that the finalize operation is effectively a destructive, read-once operation.
+         *
+         * @param {WordArray|string} messageUpdate (Optional) A final message update.
+         *
+         * @return {WordArray} The HMAC.
+         *
+         * @example
+         *
+         *     var hmac = hmacHasher.finalize();
+         *     var hmac = hmacHasher.finalize('message');
+         *     var hmac = hmacHasher.finalize(wordArray);
+         */
+        finalize: function (messageUpdate) {
+            // Shortcut
+            var hasher = this._hasher;
+
+            // Compute HMAC
+            var innerHash = hasher.finalize(messageUpdate);
+            hasher.reset();
+            var hmac = hasher.finalize(this._oKey.clone().concat(innerHash));
+
+            return hmac;
+        }
+    });
+}());
diff --git a/src/lib-typedarrays.js b/src/lib-typedarrays.js
new file mode 100644
index 0000000..01e4428
--- /dev/null
+++ b/src/lib-typedarrays.js
@@ -0,0 +1,56 @@
+(function () {
+    // Check if typed arrays are supported
+    if (typeof ArrayBuffer != 'function') {
+        return;
+    }
+
+    // Shortcuts
+    var C = CryptoJS;
+    var C_lib = C.lib;
+    var WordArray = C_lib.WordArray;
+
+    // Reference original init
+    var superInit = WordArray.init;
+
+    // Augment WordArray.init to handle typed arrays
+    var subInit = WordArray.init = function (typedArray) {
+        // Convert buffers to uint8
+        if (typedArray instanceof ArrayBuffer) {
+            typedArray = new Uint8Array(typedArray);
+        }
+
+        // Convert other array views to uint8
+        if (
+            typedArray instanceof Int8Array ||
+            (typeof Uint8ClampedArray !== "undefined" && typedArray instanceof Uint8ClampedArray) ||
+            typedArray instanceof Int16Array ||
+            typedArray instanceof Uint16Array ||
+            typedArray instanceof Int32Array ||
+            typedArray instanceof Uint32Array ||
+            typedArray instanceof Float32Array ||
+            typedArray instanceof Float64Array
+        ) {
+            typedArray = new Uint8Array(typedArray.buffer, typedArray.byteOffset, typedArray.byteLength);
+        }
+
+        // Handle Uint8Array
+        if (typedArray instanceof Uint8Array) {
+            // Shortcut
+            var typedArrayByteLength = typedArray.byteLength;
+
+            // Extract bytes
+            var words = [];
+            for (var i = 0; i < typedArrayByteLength; i++) {
+                words[i >>> 2] |= typedArray[i] << (24 - (i % 4) * 8);
+            }
+
+            // Initialize this word array
+            superInit.call(this, words, typedArrayByteLength);
+        } else {
+            // Else call normal init
+            superInit.apply(this, arguments);
+        }
+    };
+
+    subInit.prototype = WordArray;
+}());
diff --git a/src/md5.js b/src/md5.js
new file mode 100644
index 0000000..77ae69d
--- /dev/null
+++ b/src/md5.js
@@ -0,0 +1,248 @@
+(function (Math) {
+    // Shortcuts
+    var C = CryptoJS;
+    var C_lib = C.lib;
+    var WordArray = C_lib.WordArray;
+    var Hasher = C_lib.Hasher;
+    var C_algo = C.algo;
+
+    // Constants table
+    var T = [];
+
+    // Compute constants
+    (function () {
+        for (var i = 0; i < 64; i++) {
+            T[i] = (Math.abs(Math.sin(i + 1)) * 0x100000000) | 0;
+        }
+    }());
+
+    /**
+     * MD5 hash algorithm.
+     */
+    var MD5 = C_algo.MD5 = Hasher.extend({
+        _doReset: function () {
+            this._hash = new WordArray.init([
+                0x67452301, 0xefcdab89,
+                0x98badcfe, 0x10325476
+            ]);
+        },
+
+        _doProcessBlock: function (M, offset) {
+            // Swap endian
+            for (var i = 0; i < 16; i++) {
+                // Shortcuts
+                var offset_i = offset + i;
+                var M_offset_i = M[offset_i];
+
+                M[offset_i] = (
+                    (((M_offset_i << 8)  | (M_offset_i >>> 24)) & 0x00ff00ff) |
+                    (((M_offset_i << 24) | (M_offset_i >>> 8))  & 0xff00ff00)
+                );
+            }
+
+            // Shortcuts
+            var H = this._hash.words;
+
+            var M_offset_0  = M[offset + 0];
+            var M_offset_1  = M[offset + 1];
+            var M_offset_2  = M[offset + 2];
+            var M_offset_3  = M[offset + 3];
+            var M_offset_4  = M[offset + 4];
+            var M_offset_5  = M[offset + 5];
+            var M_offset_6  = M[offset + 6];
+            var M_offset_7  = M[offset + 7];
+            var M_offset_8  = M[offset + 8];
+            var M_offset_9  = M[offset + 9];
+            var M_offset_10 = M[offset + 10];
+            var M_offset_11 = M[offset + 11];
+            var M_offset_12 = M[offset + 12];
+            var M_offset_13 = M[offset + 13];
+            var M_offset_14 = M[offset + 14];
+            var M_offset_15 = M[offset + 15];
+
+            // Working variables
+            var a = H[0];
+            var b = H[1];
+            var c = H[2];
+            var d = H[3];
+
+            // Computation
+            a = FF(a, b, c, d, M_offset_0,  7,  T[0]);
+            d = FF(d, a, b, c, M_offset_1,  12, T[1]);
+            c = FF(c, d, a, b, M_offset_2,  17, T[2]);
+            b = FF(b, c, d, a, M_offset_3,  22, T[3]);
+            a = FF(a, b, c, d, M_offset_4,  7,  T[4]);
+            d = FF(d, a, b, c, M_offset_5,  12, T[5]);
+            c = FF(c, d, a, b, M_offset_6,  17, T[6]);
+            b = FF(b, c, d, a, M_offset_7,  22, T[7]);
+            a = FF(a, b, c, d, M_offset_8,  7,  T[8]);
+            d = FF(d, a, b, c, M_offset_9,  12, T[9]);
+            c = FF(c, d, a, b, M_offset_10, 17, T[10]);
+            b = FF(b, c, d, a, M_offset_11, 22, T[11]);
+            a = FF(a, b, c, d, M_offset_12, 7,  T[12]);
+            d = FF(d, a, b, c, M_offset_13, 12, T[13]);
+            c = FF(c, d, a, b, M_offset_14, 17, T[14]);
+            b = FF(b, c, d, a, M_offset_15, 22, T[15]);
+
+            a = GG(a, b, c, d, M_offset_1,  5,  T[16]);
+            d = GG(d, a, b, c, M_offset_6,  9,  T[17]);
+            c = GG(c, d, a, b, M_offset_11, 14, T[18]);
+            b = GG(b, c, d, a, M_offset_0,  20, T[19]);
+            a = GG(a, b, c, d, M_offset_5,  5,  T[20]);
+            d = GG(d, a, b, c, M_offset_10, 9,  T[21]);
+            c = GG(c, d, a, b, M_offset_15, 14, T[22]);
+            b = GG(b, c, d, a, M_offset_4,  20, T[23]);
+            a = GG(a, b, c, d, M_offset_9,  5,  T[24]);
+            d = GG(d, a, b, c, M_offset_14, 9,  T[25]);
+            c = GG(c, d, a, b, M_offset_3,  14, T[26]);
+            b = GG(b, c, d, a, M_offset_8,  20, T[27]);
+            a = GG(a, b, c, d, M_offset_13, 5,  T[28]);
+            d = GG(d, a, b, c, M_offset_2,  9,  T[29]);
+            c = GG(c, d, a, b, M_offset_7,  14, T[30]);
+            b = GG(b, c, d, a, M_offset_12, 20, T[31]);
+
+            a = HH(a, b, c, d, M_offset_5,  4,  T[32]);
+            d = HH(d, a, b, c, M_offset_8,  11, T[33]);
+            c = HH(c, d, a, b, M_offset_11, 16, T[34]);
+            b = HH(b, c, d, a, M_offset_14, 23, T[35]);
+            a = HH(a, b, c, d, M_offset_1,  4,  T[36]);
+            d = HH(d, a, b, c, M_offset_4,  11, T[37]);
+            c = HH(c, d, a, b, M_offset_7,  16, T[38]);
+            b = HH(b, c, d, a, M_offset_10, 23, T[39]);
+            a = HH(a, b, c, d, M_offset_13, 4,  T[40]);
+            d = HH(d, a, b, c, M_offset_0,  11, T[41]);
+            c = HH(c, d, a, b, M_offset_3,  16, T[42]);
+            b = HH(b, c, d, a, M_offset_6,  23, T[43]);
+            a = HH(a, b, c, d, M_offset_9,  4,  T[44]);
+            d = HH(d, a, b, c, M_offset_12, 11, T[45]);
+            c = HH(c, d, a, b, M_offset_15, 16, T[46]);
+            b = HH(b, c, d, a, M_offset_2,  23, T[47]);
+
+            a = II(a, b, c, d, M_offset_0,  6,  T[48]);
+            d = II(d, a, b, c, M_offset_7,  10, T[49]);
+            c = II(c, d, a, b, M_offset_14, 15, T[50]);
+            b = II(b, c, d, a, M_offset_5,  21, T[51]);
+            a = II(a, b, c, d, M_offset_12, 6,  T[52]);
+            d = II(d, a, b, c, M_offset_3,  10, T[53]);
+            c = II(c, d, a, b, M_offset_10, 15, T[54]);
+            b = II(b, c, d, a, M_offset_1,  21, T[55]);
+            a = II(a, b, c, d, M_offset_8,  6,  T[56]);
+            d = II(d, a, b, c, M_offset_15, 10, T[57]);
+            c = II(c, d, a, b, M_offset_6,  15, T[58]);
+            b = II(b, c, d, a, M_offset_13, 21, T[59]);
+            a = II(a, b, c, d, M_offset_4,  6,  T[60]);
+            d = II(d, a, b, c, M_offset_11, 10, T[61]);
+            c = II(c, d, a, b, M_offset_2,  15, T[62]);
+            b = II(b, c, d, a, M_offset_9,  21, T[63]);
+
+            // Intermediate hash value
+            H[0] = (H[0] + a) | 0;
+            H[1] = (H[1] + b) | 0;
+            H[2] = (H[2] + c) | 0;
+            H[3] = (H[3] + d) | 0;
+        },
+
+        _doFinalize: function () {
+            // Shortcuts
+            var data = this._data;
+            var dataWords = data.words;
+
+            var nBitsTotal = this._nDataBytes * 8;
+            var nBitsLeft = data.sigBytes * 8;
+
+            // Add padding
+            dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
+
+            var nBitsTotalH = Math.floor(nBitsTotal / 0x100000000);
+            var nBitsTotalL = nBitsTotal;
+            dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = (
+                (((nBitsTotalH << 8)  | (nBitsTotalH >>> 24)) & 0x00ff00ff) |
+                (((nBitsTotalH << 24) | (nBitsTotalH >>> 8))  & 0xff00ff00)
+            );
+            dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = (
+                (((nBitsTotalL << 8)  | (nBitsTotalL >>> 24)) & 0x00ff00ff) |
+                (((nBitsTotalL << 24) | (nBitsTotalL >>> 8))  & 0xff00ff00)
+            );
+
+            data.sigBytes = (dataWords.length + 1) * 4;
+
+            // Hash final blocks
+            this._process();
+
+            // Shortcuts
+            var hash = this._hash;
+            var H = hash.words;
+
+            // Swap endian
+            for (var i = 0; i < 4; i++) {
+                // Shortcut
+                var H_i = H[i];
+
+                H[i] = (((H_i << 8)  | (H_i >>> 24)) & 0x00ff00ff) |
+                       (((H_i << 24) | (H_i >>> 8))  & 0xff00ff00);
+            }
+
+            // Return final computed hash
+            return hash;
+        },
+
+        clone: function () {
+            var clone = Hasher.clone.call(this);
+            clone._hash = this._hash.clone();
+
+            return clone;
+        }
+    });
+
+    function FF(a, b, c, d, x, s, t) {
+        var n = a + ((b & c) | (~b & d)) + x + t;
+        return ((n << s) | (n >>> (32 - s))) + b;
+    }
+
+    function GG(a, b, c, d, x, s, t) {
+        var n = a + ((b & d) | (c & ~d)) + x + t;
+        return ((n << s) | (n >>> (32 - s))) + b;
+    }
+
+    function HH(a, b, c, d, x, s, t) {
+        var n = a + (b ^ c ^ d) + x + t;
+        return ((n << s) | (n >>> (32 - s))) + b;
+    }
+
+    function II(a, b, c, d, x, s, t) {
+        var n = a + (c ^ (b | ~d)) + x + t;
+        return ((n << s) | (n >>> (32 - s))) + b;
+    }
+
+    /**
+     * Shortcut function to the hasher's object interface.
+     *
+     * @param {WordArray|string} message The message to hash.
+     *
+     * @return {WordArray} The hash.
+     *
+     * @static
+     *
+     * @example
+     *
+     *     var hash = CryptoJS.MD5('message');
+     *     var hash = CryptoJS.MD5(wordArray);
+     */
+    C.MD5 = Hasher._createHelper(MD5);
+
+    /**
+     * Shortcut function to the HMAC's object interface.
+     *
+     * @param {WordArray|string} message The message to hash.
+     * @param {WordArray|string} key The secret key.
+     *
+     * @return {WordArray} The HMAC.
+     *
+     * @static
+     *
+     * @example
+     *
+     *     var hmac = CryptoJS.HmacMD5(message, key);
+     */
+    C.HmacMD5 = Hasher._createHmacHelper(MD5);
+}(Math));
diff --git a/src/mode-cfb.js b/src/mode-cfb.js
new file mode 100644
index 0000000..e750620
--- /dev/null
+++ b/src/mode-cfb.js
@@ -0,0 +1,60 @@
+/**
+ * Cipher Feedback block mode.
+ */
+CryptoJS.mode.CFB = (function () {
+    var CFB = CryptoJS.lib.BlockCipherMode.extend();
+
+    CFB.Encryptor = CFB.extend({
+        processBlock: function (words, offset) {
+            // Shortcuts
+            var cipher = this._cipher;
+            var blockSize = cipher.blockSize;
+
+            generateKeystreamAndEncrypt.call(this, words, offset, blockSize, cipher);
+
+            // Remember this block to use with next block
+            this._prevBlock = words.slice(offset, offset + blockSize);
+        }
+    });
+
+    CFB.Decryptor = CFB.extend({
+        processBlock: function (words, offset) {
+            // Shortcuts
+            var cipher = this._cipher;
+            var blockSize = cipher.blockSize;
+
+            // Remember this block to use with next block
+            var thisBlock = words.slice(offset, offset + blockSize);
+
+            generateKeystreamAndEncrypt.call(this, words, offset, blockSize, cipher);
+
+            // This block becomes the previous block
+            this._prevBlock = thisBlock;
+        }
+    });
+
+    function generateKeystreamAndEncrypt(words, offset, blockSize, cipher) {
+        var keystream;
+
+        // Shortcut
+        var iv = this._iv;
+
+        // Generate keystream
+        if (iv) {
+            keystream = iv.slice(0);
+
+            // Remove IV for subsequent blocks
+            this._iv = undefined;
+        } else {
+            keystream = this._prevBlock;
+        }
+        cipher.encryptBlock(keystream, 0);
+
+        // Encrypt
+        for (var i = 0; i < blockSize; i++) {
+            words[offset + i] ^= keystream[i];
+        }
+    }
+
+    return CFB;
+}());
diff --git a/src/mode-ctr-gladman.js b/src/mode-ctr-gladman.js
new file mode 100644
index 0000000..67dd933
--- /dev/null
+++ b/src/mode-ctr-gladman.js
@@ -0,0 +1,96 @@
+/** @preserve
+ * Counter block mode compatible with  Dr Brian Gladman fileenc.c
+ * derived from CryptoJS.mode.CTR 
+ * Jan Hruby jhruby.web@gmail.com
+ */
+CryptoJS.mode.CTRGladman = (function () {
+    var CTRGladman = CryptoJS.lib.BlockCipherMode.extend();
+
+	function incWord(word)
+	{	
+		if (((word >> 24) & 0xff) === 0xff) { //overflow
+		var b1 = (word >> 16)&0xff;
+		var b2 = (word >> 8)&0xff;
+		var b3 = word & 0xff;
+
+		if (b1 === 0xff) // overflow b1
+		{		 
+		b1 = 0;
+		if (b2 === 0xff)
+		{
+			b2 = 0;
+			if (b3 === 0xff)
+			{
+				b3 = 0;
+			}
+			else
+			{
+				++b3;
+			}
+		}
+		else
+		{
+			++b2;
+		}
+		}
+		else
+		{
+		++b1;
+		}
+
+		word = 0;	  	  
+		word += (b1 << 16);
+		word += (b2 << 8);
+		word += b3;	  
+		}
+		else
+		{
+		word += (0x01 << 24);
+		}
+		return word;
+	}
+
+	function incCounter(counter)
+	{
+		if ((counter[0] = incWord(counter[0])) === 0)
+		{
+			// encr_data in fileenc.c from  Dr Brian Gladman's counts only with DWORD j < 8
+			counter[1] = incWord(counter[1]);
+		}
+		return counter;
+	}
+	
+    var Encryptor = CTRGladman.Encryptor = CTRGladman.extend({
+        processBlock: function (words, offset) {
+            // Shortcuts
+            var cipher = this._cipher
+            var blockSize = cipher.blockSize;
+            var iv = this._iv;
+            var counter = this._counter;
+
+            // Generate keystream
+            if (iv) {
+                counter = this._counter = iv.slice(0);
+
+                // Remove IV for subsequent blocks
+                this._iv = undefined;
+            }
+            
+			incCounter(counter);
+			
+			var keystream = counter.slice(0);
+            cipher.encryptBlock(keystream, 0);
+
+            // Encrypt
+            for (var i = 0; i < blockSize; i++) {
+                words[offset + i] ^= keystream[i];
+            }
+        }
+    });
+
+    CTRGladman.Decryptor = Encryptor;
+
+    return CTRGladman;
+}());
+
+
diff --git a/src/mode-ctr.js b/src/mode-ctr.js
new file mode 100644
index 0000000..59c8bff
--- /dev/null
+++ b/src/mode-ctr.js
@@ -0,0 +1,38 @@
+/**
+ * Counter block mode.
+ */
+CryptoJS.mode.CTR = (function () {
+    var CTR = CryptoJS.lib.BlockCipherMode.extend();
+
+    var Encryptor = CTR.Encryptor = CTR.extend({
+        processBlock: function (words, offset) {
+            // Shortcuts
+            var cipher = this._cipher
+            var blockSize = cipher.blockSize;
+            var iv = this._iv;
+            var counter = this._counter;
+
+            // Generate keystream
+            if (iv) {
+                counter = this._counter = iv.slice(0);
+
+                // Remove IV for subsequent blocks
+                this._iv = undefined;
+            }
+            var keystream = counter.slice(0);
+            cipher.encryptBlock(keystream, 0);
+
+            // Increment counter
+            counter[blockSize - 1] = (counter[blockSize - 1] + 1) | 0
+
+            // Encrypt
+            for (var i = 0; i < blockSize; i++) {
+                words[offset + i] ^= keystream[i];
+            }
+        }
+    });
+
+    CTR.Decryptor = Encryptor;
+
+    return CTR;
+}());
diff --git a/src/mode-ecb.js b/src/mode-ecb.js
new file mode 100644
index 0000000..786ae2e
--- /dev/null
+++ b/src/mode-ecb.js
@@ -0,0 +1,20 @@
+/**
+ * Electronic Codebook block mode.
+ */
+CryptoJS.mode.ECB = (function () {
+    var ECB = CryptoJS.lib.BlockCipherMode.extend();
+
+    ECB.Encryptor = ECB.extend({
+        processBlock: function (words, offset) {
+            this._cipher.encryptBlock(words, offset);
+        }
+    });
+
+    ECB.Decryptor = ECB.extend({
+        processBlock: function (words, offset) {
+            this._cipher.decryptBlock(words, offset);
+        }
+    });
+
+    return ECB;
+}());
diff --git a/src/mode-ofb.js b/src/mode-ofb.js
new file mode 100644
index 0000000..78f0cbe
--- /dev/null
+++ b/src/mode-ofb.js
@@ -0,0 +1,34 @@
+/**
+ * Output Feedback block mode.
+ */
+CryptoJS.mode.OFB = (function () {
+    var OFB = CryptoJS.lib.BlockCipherMode.extend();
+
+    var Encryptor = OFB.Encryptor = OFB.extend({
+        processBlock: function (words, offset) {
+            // Shortcuts
+            var cipher = this._cipher
+            var blockSize = cipher.blockSize;
+            var iv = this._iv;
+            var keystream = this._keystream;
+
+            // Generate keystream
+            if (iv) {
+                keystream = this._keystream = iv.slice(0);
+
+                // Remove IV for subsequent blocks
+                this._iv = undefined;
+            }
+            cipher.encryptBlock(keystream, 0);
+
+            // Encrypt
+            for (var i = 0; i < blockSize; i++) {
+                words[offset + i] ^= keystream[i];
+            }
+        }
+    });
+
+    OFB.Decryptor = Encryptor;
+
+    return OFB;
+}());
diff --git a/src/pad-ansix923.js b/src/pad-ansix923.js
new file mode 100644
index 0000000..deb0472
--- /dev/null
+++ b/src/pad-ansix923.js
@@ -0,0 +1,29 @@
+/**
+ * ANSI X.923 padding strategy.
+ */
+CryptoJS.pad.AnsiX923 = {
+    pad: function (data, blockSize) {
+        // Shortcuts
+        var dataSigBytes = data.sigBytes;
+        var blockSizeBytes = blockSize * 4;
+
+        // Count padding bytes
+        var nPaddingBytes = blockSizeBytes - dataSigBytes % blockSizeBytes;
+
+        // Compute last byte position
+        var lastBytePos = dataSigBytes + nPaddingBytes - 1;
+
+        // Pad
+        data.clamp();
+        data.words[lastBytePos >>> 2] |= nPaddingBytes << (24 - (lastBytePos % 4) * 8);
+        data.sigBytes += nPaddingBytes;
+    },
+
+    unpad: function (data) {
+        // Get number of padding bytes from last byte
+        var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;
+
+        // Remove padding
+        data.sigBytes -= nPaddingBytes;
+    }
+};
diff --git a/src/pad-iso10126.js b/src/pad-iso10126.js
new file mode 100644
index 0000000..7ed9a21
--- /dev/null
+++ b/src/pad-iso10126.js
@@ -0,0 +1,24 @@
+/**
+ * ISO 10126 padding strategy.
+ */
+CryptoJS.pad.Iso10126 = {
+    pad: function (data, blockSize) {
+        // Shortcut
+        var blockSizeBytes = blockSize * 4;
+
+        // Count padding bytes
+        var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes;
+
+        // Pad
+        data.concat(CryptoJS.lib.WordArray.random(nPaddingBytes - 1)).
+             concat(CryptoJS.lib.WordArray.create([nPaddingBytes << 24], 1));
+    },
+
+    unpad: function (data) {
+        // Get number of padding bytes from last byte
+        var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;
+
+        // Remove padding
+        data.sigBytes -= nPaddingBytes;
+    }
+};
diff --git a/src/pad-iso97971.js b/src/pad-iso97971.js
new file mode 100644
index 0000000..d42c104
--- /dev/null
+++ b/src/pad-iso97971.js
@@ -0,0 +1,20 @@
+/**
+ * ISO/IEC 9797-1 Padding Method 2.
+ */
+CryptoJS.pad.Iso97971 = {
+    pad: function (data, blockSize) {
+        // Add 0x80 byte
+        data.concat(CryptoJS.lib.WordArray.create([0x80000000], 1));
+
+        // Zero pad the rest
+        CryptoJS.pad.ZeroPadding.pad(data, blockSize);
+    },
+
+    unpad: function (data) {
+        // Remove zero padding
+        CryptoJS.pad.ZeroPadding.unpad(data);
+
+        // Remove one more byte -- the 0x80 byte
+        data.sigBytes--;
+    }
+};
diff --git a/src/pad-nopadding.js b/src/pad-nopadding.js
new file mode 100644
index 0000000..81fb38b
--- /dev/null
+++ b/src/pad-nopadding.js
@@ -0,0 +1,10 @@
+/**
+ * A noop padding strategy.
+ */
+CryptoJS.pad.NoPadding = {
+    pad: function () {
+    },
+
+    unpad: function () {
+    }
+};
diff --git a/src/pad-zeropadding.js b/src/pad-zeropadding.js
new file mode 100644
index 0000000..2b82b58
--- /dev/null
+++ b/src/pad-zeropadding.js
@@ -0,0 +1,27 @@
+/**
+ * Zero padding strategy.
+ */
+CryptoJS.pad.ZeroPadding = {
+    pad: function (data, blockSize) {
+        // Shortcut
+        var blockSizeBytes = blockSize * 4;
+
+        // Pad
+        data.clamp();
+        data.sigBytes += blockSizeBytes - ((data.sigBytes % blockSizeBytes) || blockSizeBytes);
+    },
+
+    unpad: function (data) {
+        // Shortcut
+        var dataWords = data.words;
+
+        // Unpad
+        var i = data.sigBytes - 1;
+        for (var i = data.sigBytes - 1; i >= 0; i--) {
+            if (((dataWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff)) {
+                data.sigBytes = i + 1;
+                break;
+            }
+        }
+    }
+};
diff --git a/src/pbkdf2.js b/src/pbkdf2.js
new file mode 100644
index 0000000..92ecf6b
--- /dev/null
+++ b/src/pbkdf2.js
@@ -0,0 +1,125 @@
+(function () {
+    // Shortcuts
+    var C = CryptoJS;
+    var C_lib = C.lib;
+    var Base = C_lib.Base;
+    var WordArray = C_lib.WordArray;
+    var C_algo = C.algo;
+    var SHA256 = C_algo.SHA256;
+    var HMAC = C_algo.HMAC;
+
+    /**
+     * Password-Based Key Derivation Function 2 algorithm.
+     */
+    var PBKDF2 = C_algo.PBKDF2 = Base.extend({
+        /**
+         * Configuration options.
+         *
+         * @property {number} keySize The key size in words to generate. Default: 4 (128 bits)
+         * @property {Hasher} hasher The hasher to use. Default: SHA256
+         * @property {number} iterations The number of iterations to perform. Default: 250000
+         */
+        cfg: Base.extend({
+            keySize: 128/32,
+            hasher: SHA256,
+            iterations: 250000
+        }),
+
+        /**
+         * Initializes a newly created key derivation function.
+         *
+         * @param {Object} cfg (Optional) The configuration options to use for the derivation.
+         *
+         * @example
+         *
+         *     var kdf = CryptoJS.algo.PBKDF2.create();
+         *     var kdf = CryptoJS.algo.PBKDF2.create({ keySize: 8 });
+         *     var kdf = CryptoJS.algo.PBKDF2.create({ keySize: 8, iterations: 1000 });
+         */
+        init: function (cfg) {
+            this.cfg = this.cfg.extend(cfg);
+        },
+
+        /**
+         * Computes the Password-Based Key Derivation Function 2.
+         *
+         * @param {WordArray|string} password The password.
+         * @param {WordArray|string} salt A salt.
+         *
+         * @return {WordArray} The derived key.
+         *
+         * @example
+         *
+         *     var key = kdf.compute(password, salt);
+         */
+        compute: function (password, salt) {
+            // Shortcut
+            var cfg = this.cfg;
+
+            // Init HMAC
+            var hmac = HMAC.create(cfg.hasher, password);
+
+            // Initial values
+            var derivedKey = WordArray.create();
+            var blockIndex = WordArray.create([0x00000001]);
+
+            // Shortcuts
+            var derivedKeyWords = derivedKey.words;
+            var blockIndexWords = blockIndex.words;
+            var keySize = cfg.keySize;
+            var iterations = cfg.iterations;
+
+            // Generate key
+            while (derivedKeyWords.length < keySize) {
+                var block = hmac.update(salt).finalize(blockIndex);
+                hmac.reset();
+
+                // Shortcuts
+                var blockWords = block.words;
+                var blockWordsLength = blockWords.length;
+
+                // Iterations
+                var intermediate = block;
+                for (var i = 1; i < iterations; i++) {
+                    intermediate = hmac.finalize(intermediate);
+                    hmac.reset();
+
+                    // Shortcut
+                    var intermediateWords = intermediate.words;
+
+                    // XOR intermediate with block
+                    for (var j = 0; j < blockWordsLength; j++) {
+                        blockWords[j] ^= intermediateWords[j];
+                    }
+                }
+
+                derivedKey.concat(block);
+                blockIndexWords[0]++;
+            }
+            derivedKey.sigBytes = keySize * 4;
+
+            return derivedKey;
+        }
+    });
+
+    /**
+     * Computes the Password-Based Key Derivation Function 2.
+     *
+     * @param {WordArray|string} password The password.
+     * @param {WordArray|string} salt A salt.
+     * @param {Object} cfg (Optional) The configuration options to use for this computation.
+     *
+     * @return {WordArray} The derived key.
+     *
+     * @static
+     *
+     * @example
+     *
+     *     var key = CryptoJS.PBKDF2(password, salt);
+     *     var key = CryptoJS.PBKDF2(password, salt, { keySize: 8 });
+     *     var key = CryptoJS.PBKDF2(password, salt, { keySize: 8, iterations: 1000 });
+     */
+    C.PBKDF2 = function (password, salt, cfg) {
+        return PBKDF2.create(cfg).compute(password, salt);
+    };
+}());
diff --git a/src/rabbit-legacy.js b/src/rabbit-legacy.js
new file mode 100644
index 0000000..ff02aef
--- /dev/null
+++ b/src/rabbit-legacy.js
@@ -0,0 +1,170 @@
+(function () {
+    // Shortcuts
+    var C = CryptoJS;
+    var C_lib = C.lib;
+    var StreamCipher = C_lib.StreamCipher;
+    var C_algo = C.algo;
+
+    // Reusable objects
+    var S  = [];
+    var C_ = [];
+    var G  = [];
+
+    /**
+     * Rabbit stream cipher algorithm.
+     *
+     * This is a legacy version that neglected to convert the key to little-endian.
+     * This error doesn't affect the cipher's security,
+     * but it does affect its compatibility with other implementations.
+     */
+    var RabbitLegacy = C_algo.RabbitLegacy = StreamCipher.extend({
+        _doReset: function () {
+            // Shortcuts
+            var K = this._key.words;
+            var iv = this.cfg.iv;
+
+            // Generate initial state values
+            var X = this._X = [
+                K[0], (K[3] << 16) | (K[2] >>> 16),
+                K[1], (K[0] << 16) | (K[3] >>> 16),
+                K[2], (K[1] << 16) | (K[0] >>> 16),
+                K[3], (K[2] << 16) | (K[1] >>> 16)
+            ];
+
+            // Generate initial counter values
+            var C = this._C = [
+                (K[2] << 16) | (K[2] >>> 16), (K[0] & 0xffff0000) | (K[1] & 0x0000ffff),
+                (K[3] << 16) | (K[3] >>> 16), (K[1] & 0xffff0000) | (K[2] & 0x0000ffff),
+                (K[0] << 16) | (K[0] >>> 16), (K[2] & 0xffff0000) | (K[3] & 0x0000ffff),
+                (K[1] << 16) | (K[1] >>> 16), (K[3] & 0xffff0000) | (K[0] & 0x0000ffff)
+            ];
+
+            // Carry bit
+            this._b = 0;
+
+            // Iterate the system four times
+            for (var i = 0; i < 4; i++) {
+                nextState.call(this);
+            }
+
+            // Modify the counters
+            for (var i = 0; i < 8; i++) {
+                C[i] ^= X[(i + 4) & 7];
+            }
+
+            // IV setup
+            if (iv) {
+                // Shortcuts
+                var IV = iv.words;
+                var IV_0 = IV[0];
+                var IV_1 = IV[1];
+
+                // Generate four subvectors
+                var i0 = (((IV_0 << 8) | (IV_0 >>> 24)) & 0x00ff00ff) | (((IV_0 << 24) | (IV_0 >>> 8)) & 0xff00ff00);
+                var i2 = (((IV_1 << 8) | (IV_1 >>> 24)) & 0x00ff00ff) | (((IV_1 << 24) | (IV_1 >>> 8)) & 0xff00ff00);
+                var i1 = (i0 >>> 16) | (i2 & 0xffff0000);
+                var i3 = (i2 << 16)  | (i0 & 0x0000ffff);
+
+                // Modify counter values
+                C[0] ^= i0;
+                C[1] ^= i1;
+                C[2] ^= i2;
+                C[3] ^= i3;
+                C[4] ^= i0;
+                C[5] ^= i1;
+                C[6] ^= i2;
+                C[7] ^= i3;
+
+                // Iterate the system four times
+                for (var i = 0; i < 4; i++) {
+                    nextState.call(this);
+                }
+            }
+        },
+
+        _doProcessBlock: function (M, offset) {
+            // Shortcut
+            var X = this._X;
+
+            // Iterate the system
+            nextState.call(this);
+
+            // Generate four keystream words
+            S[0] = X[0] ^ (X[5] >>> 16) ^ (X[3] << 16);
+            S[1] = X[2] ^ (X[7] >>> 16) ^ (X[5] << 16);
+            S[2] = X[4] ^ (X[1] >>> 16) ^ (X[7] << 16);
+            S[3] = X[6] ^ (X[3] >>> 16) ^ (X[1] << 16);
+
+            for (var i = 0; i < 4; i++) {
+                // Swap endian
+                S[i] = (((S[i] << 8)  | (S[i] >>> 24)) & 0x00ff00ff) |
+                       (((S[i] << 24) | (S[i] >>> 8))  & 0xff00ff00);
+
+                // Encrypt
+                M[offset + i] ^= S[i];
+            }
+        },
+
+        blockSize: 128/32,
+
+        ivSize: 64/32
+    });
+
+    function nextState() {
+        // Shortcuts
+        var X = this._X;
+        var C = this._C;
+
+        // Save old counter values
+        for (var i = 0; i < 8; i++) {
+            C_[i] = C[i];
+        }
+
+        // Calculate new counter values
+        C[0] = (C[0] + 0x4d34d34d + this._b) | 0;
+        C[1] = (C[1] + 0xd34d34d3 + ((C[0] >>> 0) < (C_[0] >>> 0) ? 1 : 0)) | 0;
+        C[2] = (C[2] + 0x34d34d34 + ((C[1] >>> 0) < (C_[1] >>> 0) ? 1 : 0)) | 0;
+        C[3] = (C[3] + 0x4d34d34d + ((C[2] >>> 0) < (C_[2] >>> 0) ? 1 : 0)) | 0;
+        C[4] = (C[4] + 0xd34d34d3 + ((C[3] >>> 0) < (C_[3] >>> 0) ? 1 : 0)) | 0;
+        C[5] = (C[5] + 0x34d34d34 + ((C[4] >>> 0) < (C_[4] >>> 0) ? 1 : 0)) | 0;
+        C[6] = (C[6] + 0x4d34d34d + ((C[5] >>> 0) < (C_[5] >>> 0) ? 1 : 0)) | 0;
+        C[7] = (C[7] + 0xd34d34d3 + ((C[6] >>> 0) < (C_[6] >>> 0) ? 1 : 0)) | 0;
+        this._b = (C[7] >>> 0) < (C_[7] >>> 0) ? 1 : 0;
+
+        // Calculate the g-values
+        for (var i = 0; i < 8; i++) {
+            var gx = X[i] + C[i];
+
+            // Construct high and low argument for squaring
+            var ga = gx & 0xffff;
+            var gb = gx >>> 16;
+
+            // Calculate high and low result of squaring
+            var gh = ((((ga * ga) >>> 17) + ga * gb) >>> 15) + gb * gb;
+            var gl = (((gx & 0xffff0000) * gx) | 0) + (((gx & 0x0000ffff) * gx) | 0);
+
+            // High XOR low
+            G[i] = gh ^ gl;
+        }
+
+        // Calculate new state values
+        X[0] = (G[0] + ((G[7] << 16) | (G[7] >>> 16)) + ((G[6] << 16) | (G[6] >>> 16))) | 0;
+        X[1] = (G[1] + ((G[0] << 8)  | (G[0] >>> 24)) + G[7]) | 0;
+        X[2] = (G[2] + ((G[1] << 16) | (G[1] >>> 16)) + ((G[0] << 16) | (G[0] >>> 16))) | 0;
+        X[3] = (G[3] + ((G[2] << 8)  | (G[2] >>> 24)) + G[1]) | 0;
+        X[4] = (G[4] + ((G[3] << 16) | (G[3] >>> 16)) + ((G[2] << 16) | (G[2] >>> 16))) | 0;
+        X[5] = (G[5] + ((G[4] << 8)  | (G[4] >>> 24)) + G[3]) | 0;
+        X[6] = (G[6] + ((G[5] << 16) | (G[5] >>> 16)) + ((G[4] << 16) | (G[4] >>> 16))) | 0;
+        X[7] = (G[7] + ((G[6] << 8)  | (G[6] >>> 24)) + G[5]) | 0;
+    }
+
+    /**
+     * Shortcut functions to the cipher's object interface.
+     *
+     * @example
+     *
+     *     var ciphertext = CryptoJS.RabbitLegacy.encrypt(message, key, cfg);
+     *     var plaintext  = CryptoJS.RabbitLegacy.decrypt(ciphertext, key, cfg);
+     */
+    C.RabbitLegacy = StreamCipher._createHelper(RabbitLegacy);
+}());
diff --git a/src/rabbit.js b/src/rabbit.js
new file mode 100644
index 0000000..e12e759
--- /dev/null
+++ b/src/rabbit.js
@@ -0,0 +1,172 @@
+(function () {
+    // Shortcuts
+    var C = CryptoJS;
+    var C_lib = C.lib;
+    var StreamCipher = C_lib.StreamCipher;
+    var C_algo = C.algo;
+
+    // Reusable objects
+    var S  = [];
+    var C_ = [];
+    var G  = [];
+
+    /**
+     * Rabbit stream cipher algorithm
+     */
+    var Rabbit = C_algo.Rabbit = StreamCipher.extend({
+        _doReset: function () {
+            // Shortcuts
+            var K = this._key.words;
+            var iv = this.cfg.iv;
+
+            // Swap endian
+            for (var i = 0; i < 4; i++) {
+                K[i] = (((K[i] << 8)  | (K[i] >>> 24)) & 0x00ff00ff) |
+                       (((K[i] << 24) | (K[i] >>> 8))  & 0xff00ff00);
+            }
+
+            // Generate initial state values
+            var X = this._X = [
+                K[0], (K[3] << 16) | (K[2] >>> 16),
+                K[1], (K[0] << 16) | (K[3] >>> 16),
+                K[2], (K[1] << 16) | (K[0] >>> 16),
+                K[3], (K[2] << 16) | (K[1] >>> 16)
+            ];
+
+            // Generate initial counter values
+            var C = this._C = [
+                (K[2] << 16) | (K[2] >>> 16), (K[0] & 0xffff0000) | (K[1] & 0x0000ffff),
+                (K[3] << 16) | (K[3] >>> 16), (K[1] & 0xffff0000) | (K[2] & 0x0000ffff),
+                (K[0] << 16) | (K[0] >>> 16), (K[2] & 0xffff0000) | (K[3] & 0x0000ffff),
+                (K[1] << 16) | (K[1] >>> 16), (K[3] & 0xffff0000) | (K[0] & 0x0000ffff)
+            ];
+
+            // Carry bit
+            this._b = 0;
+
+            // Iterate the system four times
+            for (var i = 0; i < 4; i++) {
+                nextState.call(this);
+            }
+
+            // Modify the counters
+            for (var i = 0; i < 8; i++) {
+                C[i] ^= X[(i + 4) & 7];
+            }
+
+            // IV setup
+            if (iv) {
+                // Shortcuts
+                var IV = iv.words;
+                var IV_0 = IV[0];
+                var IV_1 = IV[1];
+
+                // Generate four subvectors
+                var i0 = (((IV_0 << 8) | (IV_0 >>> 24)) & 0x00ff00ff) | (((IV_0 << 24) | (IV_0 >>> 8)) & 0xff00ff00);
+                var i2 = (((IV_1 << 8) | (IV_1 >>> 24)) & 0x00ff00ff) | (((IV_1 << 24) | (IV_1 >>> 8)) & 0xff00ff00);
+                var i1 = (i0 >>> 16) | (i2 & 0xffff0000);
+                var i3 = (i2 << 16)  | (i0 & 0x0000ffff);
+
+                // Modify counter values
+                C[0] ^= i0;
+                C[1] ^= i1;
+                C[2] ^= i2;
+                C[3] ^= i3;
+                C[4] ^= i0;
+                C[5] ^= i1;
+                C[6] ^= i2;
+                C[7] ^= i3;
+
+                // Iterate the system four times
+                for (var i = 0; i < 4; i++) {
+                    nextState.call(this);
+                }
+            }
+        },
+
+        _doProcessBlock: function (M, offset) {
+            // Shortcut
+            var X = this._X;
+
+            // Iterate the system
+            nextState.call(this);
+
+            // Generate four keystream words
+            S[0] = X[0] ^ (X[5] >>> 16) ^ (X[3] << 16);
+            S[1] = X[2] ^ (X[7] >>> 16) ^ (X[5] << 16);
+            S[2] = X[4] ^ (X[1] >>> 16) ^ (X[7] << 16);
+            S[3] = X[6] ^ (X[3] >>> 16) ^ (X[1] << 16);
+
+            for (var i = 0; i < 4; i++) {
+                // Swap endian
+                S[i] = (((S[i] << 8)  | (S[i] >>> 24)) & 0x00ff00ff) |
+                       (((S[i] << 24) | (S[i] >>> 8))  & 0xff00ff00);
+
+                // Encrypt
+                M[offset + i] ^= S[i];
+            }
+        },
+
+        blockSize: 128/32,
+
+        ivSize: 64/32
+    });
+
+    function nextState() {
+        // Shortcuts
+        var X = this._X;
+        var C = this._C;
+
+        // Save old counter values
+        for (var i = 0; i < 8; i++) {
+            C_[i] = C[i];
+        }
+
+        // Calculate new counter values
+        C[0] = (C[0] + 0x4d34d34d + this._b) | 0;
+        C[1] = (C[1] + 0xd34d34d3 + ((C[0] >>> 0) < (C_[0] >>> 0) ? 1 : 0)) | 0;
+        C[2] = (C[2] + 0x34d34d34 + ((C[1] >>> 0) < (C_[1] >>> 0) ? 1 : 0)) | 0;
+        C[3] = (C[3] + 0x4d34d34d + ((C[2] >>> 0) < (C_[2] >>> 0) ? 1 : 0)) | 0;
+        C[4] = (C[4] + 0xd34d34d3 + ((C[3] >>> 0) < (C_[3] >>> 0) ? 1 : 0)) | 0;
+        C[5] = (C[5] + 0x34d34d34 + ((C[4] >>> 0) < (C_[4] >>> 0) ? 1 : 0)) | 0;
+        C[6] = (C[6] + 0x4d34d34d + ((C[5] >>> 0) < (C_[5] >>> 0) ? 1 : 0)) | 0;
+        C[7] = (C[7] + 0xd34d34d3 + ((C[6] >>> 0) < (C_[6] >>> 0) ? 1 : 0)) | 0;
+        this._b = (C[7] >>> 0) < (C_[7] >>> 0) ? 1 : 0;
+
+        // Calculate the g-values
+        for (var i = 0; i < 8; i++) {
+            var gx = X[i] + C[i];
+
+            // Construct high and low argument for squaring
+            var ga = gx & 0xffff;
+            var gb = gx >>> 16;
+
+            // Calculate high and low result of squaring
+            var gh = ((((ga * ga) >>> 17) + ga * gb) >>> 15) + gb * gb;
+            var gl = (((gx & 0xffff0000) * gx) | 0) + (((gx & 0x0000ffff) * gx) | 0);
+
+            // High XOR low
+            G[i] = gh ^ gl;
+        }
+
+        // Calculate new state values
+        X[0] = (G[0] + ((G[7] << 16) | (G[7] >>> 16)) + ((G[6] << 16) | (G[6] >>> 16))) | 0;
+        X[1] = (G[1] + ((G[0] << 8)  | (G[0] >>> 24)) + G[7]) | 0;
+        X[2] = (G[2] + ((G[1] << 16) | (G[1] >>> 16)) + ((G[0] << 16) | (G[0] >>> 16))) | 0;
+        X[3] = (G[3] + ((G[2] << 8)  | (G[2] >>> 24)) + G[1]) | 0;
+        X[4] = (G[4] + ((G[3] << 16) | (G[3] >>> 16)) + ((G[2] << 16) | (G[2] >>> 16))) | 0;
+        X[5] = (G[5] + ((G[4] << 8)  | (G[4] >>> 24)) + G[3]) | 0;
+        X[6] = (G[6] + ((G[5] << 16) | (G[5] >>> 16)) + ((G[4] << 16) | (G[4] >>> 16))) | 0;
+        X[7] = (G[7] + ((G[6] << 8)  | (G[6] >>> 24)) + G[5]) | 0;
+    }
+
+    /**
+     * Shortcut functions to the cipher's object interface.
+     *
+     * @example
+     *
+     *     var ciphertext = CryptoJS.Rabbit.encrypt(message, key, cfg);
+     *     var plaintext  = CryptoJS.Rabbit.decrypt(ciphertext, key, cfg);
+     */
+    C.Rabbit = StreamCipher._createHelper(Rabbit);
+}());
diff --git a/src/rc4.js b/src/rc4.js
new file mode 100644
index 0000000..cc891d2
--- /dev/null
+++ b/src/rc4.js
@@ -0,0 +1,119 @@
+(function () {
+    // Shortcuts
+    var C = CryptoJS;
+    var C_lib = C.lib;
+    var StreamCipher = C_lib.StreamCipher;
+    var C_algo = C.algo;
+
+    /**
+     * RC4 stream cipher algorithm.
+     */
+    var RC4 = C_algo.RC4 = StreamCipher.extend({
+        _doReset: function () {
+            // Shortcuts
+            var key = this._key;
+            var keyWords = key.words;
+            var keySigBytes = key.sigBytes;
+
+            // Init sbox
+            var S = this._S = [];
+            for (var i = 0; i < 256; i++) {
+                S[i] = i;
+            }
+
+            // Key setup
+            for (var i = 0, j = 0; i < 256; i++) {
+                var keyByteIndex = i % keySigBytes;
+                var keyByte = (keyWords[keyByteIndex >>> 2] >>> (24 - (keyByteIndex % 4) * 8)) & 0xff;
+
+                j = (j + S[i] + keyByte) % 256;
+
+                // Swap
+                var t = S[i];
+                S[i] = S[j];
+                S[j] = t;
+            }
+
+            // Counters
+            this._i = this._j = 0;
+        },
+
+        _doProcessBlock: function (M, offset) {
+            M[offset] ^= generateKeystreamWord.call(this);
+        },
+
+        keySize: 256/32,
+
+        ivSize: 0
+    });
+
+    function generateKeystreamWord() {
+        // Shortcuts
+        var S = this._S;
+        var i = this._i;
+        var j = this._j;
+
+        // Generate keystream word
+        var keystreamWord = 0;
+        for (var n = 0; n < 4; n++) {
+            i = (i + 1) % 256;
+            j = (j + S[i]) % 256;
+
+            // Swap
+            var t = S[i];
+            S[i] = S[j];
+            S[j] = t;
+
+            keystreamWord |= S[(S[i] + S[j]) % 256] << (24 - n * 8);
+        }
+
+        // Update counters
+        this._i = i;
+        this._j = j;
+
+        return keystreamWord;
+    }
+
+    /**
+     * Shortcut functions to the cipher's object interface.
+     *
+     * @example
+     *
+     *     var ciphertext = CryptoJS.RC4.encrypt(message, key, cfg);
+     *     var plaintext  = CryptoJS.RC4.decrypt(ciphertext, key, cfg);
+     */
+    C.RC4 = StreamCipher._createHelper(RC4);
+
+    /**
+     * Modified RC4 stream cipher algorithm.
+     */
+    var RC4Drop = C_algo.RC4Drop = RC4.extend({
+        /**
+         * Configuration options.
+         *
+         * @property {number} drop The number of keystream words to drop. Default 192
+         */
+        cfg: RC4.cfg.extend({
+            drop: 192
+        }),
+
+        _doReset: function () {
+            RC4._doReset.call(this);
+
+            // Drop
+            for (var i = this.cfg.drop; i > 0; i--) {
+                generateKeystreamWord.call(this);
+            }
+        }
+    });
+
+    /**
+     * Shortcut functions to the cipher's object interface.
+     *
+     * @example
+     *
+     *     var ciphertext = CryptoJS.RC4Drop.encrypt(message, key, cfg);
+     *     var plaintext  = CryptoJS.RC4Drop.decrypt(ciphertext, key, cfg);
+     */
+    C.RC4Drop = StreamCipher._createHelper(RC4Drop);
+}());
diff --git a/src/ripemd160.js b/src/ripemd160.js
new file mode 100644
index 0000000..3336bc8
--- /dev/null
+++ b/src/ripemd160.js
@@ -0,0 +1,247 @@
+/** @preserve
+(c) 2012 by Cédric Mesnil. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+    - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+    - 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.
+
+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.
+*/
+
+(function (Math) {
+    // Shortcuts
+    var C = CryptoJS;
+    var C_lib = C.lib;
+    var WordArray = C_lib.WordArray;
+    var Hasher = C_lib.Hasher;
+    var C_algo = C.algo;
+
+    // Constants table
+    var _zl = WordArray.create([
+        0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15,
+        7,  4, 13,  1, 10,  6, 15,  3, 12,  0,  9,  5,  2, 14, 11,  8,
+        3, 10, 14,  4,  9, 15,  8,  1,  2,  7,  0,  6, 13, 11,  5, 12,
+        1,  9, 11, 10,  0,  8, 12,  4, 13,  3,  7, 15, 14,  5,  6,  2,
+        4,  0,  5,  9,  7, 12,  2, 10, 14,  1,  3,  8, 11,  6, 15, 13]);
+    var _zr = WordArray.create([
+        5, 14,  7,  0,  9,  2, 11,  4, 13,  6, 15,  8,  1, 10,  3, 12,
+        6, 11,  3,  7,  0, 13,  5, 10, 14, 15,  8, 12,  4,  9,  1,  2,
+        15,  5,  1,  3,  7, 14,  6,  9, 11,  8, 12,  2, 10,  0,  4, 13,
+        8,  6,  4,  1,  3, 11, 15,  0,  5, 12,  2, 13,  9,  7, 10, 14,
+        12, 15, 10,  4,  1,  5,  8,  7,  6,  2, 13, 14,  0,  3,  9, 11]);
+    var _sl = WordArray.create([
+         11, 14, 15, 12,  5,  8,  7,  9, 11, 13, 14, 15,  6,  7,  9,  8,
+        7, 6,   8, 13, 11,  9,  7, 15,  7, 12, 15,  9, 11,  7, 13, 12,
+        11, 13,  6,  7, 14,  9, 13, 15, 14,  8, 13,  6,  5, 12,  7,  5,
+          11, 12, 14, 15, 14, 15,  9,  8,  9, 14,  5,  6,  8,  6,  5, 12,
+        9, 15,  5, 11,  6,  8, 13, 12,  5, 12, 13, 14, 11,  8,  5,  6 ]);
+    var _sr = WordArray.create([
+        8,  9,  9, 11, 13, 15, 15,  5,  7,  7,  8, 11, 14, 14, 12,  6,
+        9, 13, 15,  7, 12,  8,  9, 11,  7,  7, 12,  7,  6, 15, 13, 11,
+        9,  7, 15, 11,  8,  6,  6, 14, 12, 13,  5, 14, 13, 13,  7,  5,
+        15,  5,  8, 11, 14, 14,  6, 14,  6,  9, 12,  9, 12,  5, 15,  8,
+        8,  5, 12,  9, 12,  5, 14,  6,  8, 13,  6,  5, 15, 13, 11, 11 ]);
+
+    var _hl =  WordArray.create([ 0x00000000, 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xA953FD4E]);
+    var _hr =  WordArray.create([ 0x50A28BE6, 0x5C4DD124, 0x6D703EF3, 0x7A6D76E9, 0x00000000]);
+
+    /**
+     * RIPEMD160 hash algorithm.
+     */
+    var RIPEMD160 = C_algo.RIPEMD160 = Hasher.extend({
+        _doReset: function () {
+            this._hash  = WordArray.create([0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0]);
+        },
+
+        _doProcessBlock: function (M, offset) {
+
+            // Swap endian
+            for (var i = 0; i < 16; i++) {
+                // Shortcuts
+                var offset_i = offset + i;
+                var M_offset_i = M[offset_i];
+
+                // Swap
+                M[offset_i] = (
+                    (((M_offset_i << 8)  | (M_offset_i >>> 24)) & 0x00ff00ff) |
+                    (((M_offset_i << 24) | (M_offset_i >>> 8))  & 0xff00ff00)
+                );
+            }
+            // Shortcut
+            var H  = this._hash.words;
+            var hl = _hl.words;
+            var hr = _hr.words;
+            var zl = _zl.words;
+            var zr = _zr.words;
+            var sl = _sl.words;
+            var sr = _sr.words;
+
+            // Working variables
+            var al, bl, cl, dl, el;
+            var ar, br, cr, dr, er;
+
+            ar = al = H[0];
+            br = bl = H[1];
+            cr = cl = H[2];
+            dr = dl = H[3];
+            er = el = H[4];
+            // Computation
+            var t;
+            for (var i = 0; i < 80; i += 1) {
+                t = (al +  M[offset+zl[i]])|0;
+                if (i<16){
+	            t +=  f1(bl,cl,dl) + hl[0];
+                } else if (i<32) {
+	            t +=  f2(bl,cl,dl) + hl[1];
+                } else if (i<48) {
+	            t +=  f3(bl,cl,dl) + hl[2];
+                } else if (i<64) {
+	            t +=  f4(bl,cl,dl) + hl[3];
+                } else {// if (i<80) {
+	            t +=  f5(bl,cl,dl) + hl[4];
+                }
+                t = t|0;
+                t =  rotl(t,sl[i]);
+                t = (t+el)|0;
+                al = el;
+                el = dl;
+                dl = rotl(cl, 10);
+                cl = bl;
+                bl = t;
+
+                t = (ar + M[offset+zr[i]])|0;
+                if (i<16){
+	            t +=  f5(br,cr,dr) + hr[0];
+                } else if (i<32) {
+	            t +=  f4(br,cr,dr) + hr[1];
+                } else if (i<48) {
+	            t +=  f3(br,cr,dr) + hr[2];
+                } else if (i<64) {
+	            t +=  f2(br,cr,dr) + hr[3];
+                } else {// if (i<80) {
+	            t +=  f1(br,cr,dr) + hr[4];
+                }
+                t = t|0;
+                t =  rotl(t,sr[i]) ;
+                t = (t+er)|0;
+                ar = er;
+                er = dr;
+                dr = rotl(cr, 10);
+                cr = br;
+                br = t;
+            }
+            // Intermediate hash value
+            t    = (H[1] + cl + dr)|0;
+            H[1] = (H[2] + dl + er)|0;
+            H[2] = (H[3] + el + ar)|0;
+            H[3] = (H[4] + al + br)|0;
+            H[4] = (H[0] + bl + cr)|0;
+            H[0] =  t;
+        },
+
+        _doFinalize: function () {
+            // Shortcuts
+            var data = this._data;
+            var dataWords = data.words;
+
+            var nBitsTotal = this._nDataBytes * 8;
+            var nBitsLeft = data.sigBytes * 8;
+
+            // Add padding
+            dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
+            dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = (
+                (((nBitsTotal << 8)  | (nBitsTotal >>> 24)) & 0x00ff00ff) |
+                (((nBitsTotal << 24) | (nBitsTotal >>> 8))  & 0xff00ff00)
+            );
+            data.sigBytes = (dataWords.length + 1) * 4;
+
+            // Hash final blocks
+            this._process();
+
+            // Shortcuts
+            var hash = this._hash;
+            var H = hash.words;
+
+            // Swap endian
+            for (var i = 0; i < 5; i++) {
+                // Shortcut
+                var H_i = H[i];
+
+                // Swap
+                H[i] = (((H_i << 8)  | (H_i >>> 24)) & 0x00ff00ff) |
+                       (((H_i << 24) | (H_i >>> 8))  & 0xff00ff00);
+            }
+
+            // Return final computed hash
+            return hash;
+        },
+
+        clone: function () {
+            var clone = Hasher.clone.call(this);
+            clone._hash = this._hash.clone();
+
+            return clone;
+        }
+    });
+
+
+    function f1(x, y, z) {
+        return ((x) ^ (y) ^ (z));
+
+    }
+
+    function f2(x, y, z) {
+        return (((x)&(y)) | ((~x)&(z)));
+    }
+
+    function f3(x, y, z) {
+        return (((x) | (~(y))) ^ (z));
+    }
+
+    function f4(x, y, z) {
+        return (((x) & (z)) | ((y)&(~(z))));
+    }
+
+    function f5(x, y, z) {
+        return ((x) ^ ((y) |(~(z))));
+
+    }
+
+    function rotl(x,n) {
+        return (x<<n) | (x>>>(32-n));
+    }
+
+
+    /**
+     * Shortcut function to the hasher's object interface.
+     *
+     * @param {WordArray|string} message The message to hash.
+     *
+     * @return {WordArray} The hash.
+     *
+     * @static
+     *
+     * @example
+     *
+     *     var hash = CryptoJS.RIPEMD160('message');
+     *     var hash = CryptoJS.RIPEMD160(wordArray);
+     */
+    C.RIPEMD160 = Hasher._createHelper(RIPEMD160);
+
+    /**
+     * Shortcut function to the HMAC's object interface.
+     *
+     * @param {WordArray|string} message The message to hash.
+     * @param {WordArray|string} key The secret key.
+     *
+     * @return {WordArray} The HMAC.
+     *
+     * @static
+     *
+     * @example
+     *
+     *     var hmac = CryptoJS.HmacRIPEMD160(message, key);
+     */
+    C.HmacRIPEMD160 = Hasher._createHmacHelper(RIPEMD160);
+}(Math));
diff --git a/src/sha1.js b/src/sha1.js
new file mode 100644
index 0000000..d052aeb
--- /dev/null
+++ b/src/sha1.js
@@ -0,0 +1,130 @@
+(function () {
+    // Shortcuts
+    var C = CryptoJS;
+    var C_lib = C.lib;
+    var WordArray = C_lib.WordArray;
+    var Hasher = C_lib.Hasher;
+    var C_algo = C.algo;
+
+    // Reusable object
+    var W = [];
+
+    /**
+     * SHA-1 hash algorithm.
+     */
+    var SHA1 = C_algo.SHA1 = Hasher.extend({
+        _doReset: function () {
+            this._hash = new WordArray.init([
+                0x67452301, 0xefcdab89,
+                0x98badcfe, 0x10325476,
+                0xc3d2e1f0
+            ]);
+        },
+
+        _doProcessBlock: function (M, offset) {
+            // Shortcut
+            var H = this._hash.words;
+
+            // Working variables
+            var a = H[0];
+            var b = H[1];
+            var c = H[2];
+            var d = H[3];
+            var e = H[4];
+
+            // Computation
+            for (var i = 0; i < 80; i++) {
+                if (i < 16) {
+                    W[i] = M[offset + i] | 0;
+                } else {
+                    var n = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16];
+                    W[i] = (n << 1) | (n >>> 31);
+                }
+
+                var t = ((a << 5) | (a >>> 27)) + e + W[i];
+                if (i < 20) {
+                    t += ((b & c) | (~b & d)) + 0x5a827999;
+                } else if (i < 40) {
+                    t += (b ^ c ^ d) + 0x6ed9eba1;
+                } else if (i < 60) {
+                    t += ((b & c) | (b & d) | (c & d)) - 0x70e44324;
+                } else /* if (i < 80) */ {
+                    t += (b ^ c ^ d) - 0x359d3e2a;
+                }
+
+                e = d;
+                d = c;
+                c = (b << 30) | (b >>> 2);
+                b = a;
+                a = t;
+            }
+
+            // Intermediate hash value
+            H[0] = (H[0] + a) | 0;
+            H[1] = (H[1] + b) | 0;
+            H[2] = (H[2] + c) | 0;
+            H[3] = (H[3] + d) | 0;
+            H[4] = (H[4] + e) | 0;
+        },
+
+        _doFinalize: function () {
+            // Shortcuts
+            var data = this._data;
+            var dataWords = data.words;
+
+            var nBitsTotal = this._nDataBytes * 8;
+            var nBitsLeft = data.sigBytes * 8;
+
+            // Add padding
+            dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
+            dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000);
+            dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal;
+            data.sigBytes = dataWords.length * 4;
+
+            // Hash final blocks
+            this._process();
+
+            // Return final computed hash
+            return this._hash;
+        },
+
+        clone: function () {
+            var clone = Hasher.clone.call(this);
+            clone._hash = this._hash.clone();
+
+            return clone;
+        }
+    });
+
+    /**
+     * Shortcut function to the hasher's object interface.
+     *
+     * @param {WordArray|string} message The message to hash.
+     *
+     * @return {WordArray} The hash.
+     *
+     * @static
+     *
+     * @example
+     *
+     *     var hash = CryptoJS.SHA1('message');
+     *     var hash = CryptoJS.SHA1(wordArray);
+     */
+    C.SHA1 = Hasher._createHelper(SHA1);
+
+    /**
+     * Shortcut function to the HMAC's object interface.
+     *
+     * @param {WordArray|string} message The message to hash.
+     * @param {WordArray|string} key The secret key.
+     *
+     * @return {WordArray} The HMAC.
+     *
+     * @static
+     *
+     * @example
+     *
+     *     var hmac = CryptoJS.HmacSHA1(message, key);
+     */
+    C.HmacSHA1 = Hasher._createHmacHelper(SHA1);
+}());
diff --git a/src/sha224.js b/src/sha224.js
new file mode 100644
index 0000000..6bd2533
--- /dev/null
+++ b/src/sha224.js
@@ -0,0 +1,60 @@
+(function () {
+    // Shortcuts
+    var C = CryptoJS;
+    var C_lib = C.lib;
+    var WordArray = C_lib.WordArray;
+    var C_algo = C.algo;
+    var SHA256 = C_algo.SHA256;
+
+    /**
+     * SHA-224 hash algorithm.
+     */
+    var SHA224 = C_algo.SHA224 = SHA256.extend({
+        _doReset: function () {
+            this._hash = new WordArray.init([
+                0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939,
+                0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4
+            ]);
+        },
+
+        _doFinalize: function () {
+            var hash = SHA256._doFinalize.call(this);
+
+            hash.sigBytes -= 4;
+
+            return hash;
+        }
+    });
+
+    /**
+     * Shortcut function to the hasher's object interface.
+     *
+     * @param {WordArray|string} message The message to hash.
+     *
+     * @return {WordArray} The hash.
+     *
+     * @static
+     *
+     * @example
+     *
+     *     var hash = CryptoJS.SHA224('message');
+     *     var hash = CryptoJS.SHA224(wordArray);
+     */
+    C.SHA224 = SHA256._createHelper(SHA224);
+
+    /**
+     * Shortcut function to the HMAC's object interface.
+     *
+     * @param {WordArray|string} message The message to hash.
+     * @param {WordArray|string} key The secret key.
+     *
+     * @return {WordArray} The HMAC.
+     *
+     * @static
+     *
+     * @example
+     *
+     *     var hmac = CryptoJS.HmacSHA224(message, key);
+     */
+    C.HmacSHA224 = SHA256._createHmacHelper(SHA224);
+}());
diff --git a/src/sha256.js b/src/sha256.js
new file mode 100644
index 0000000..ce5525d
--- /dev/null
+++ b/src/sha256.js
@@ -0,0 +1,179 @@
+(function (Math) {
+    // Shortcuts
+    var C = CryptoJS;
+    var C_lib = C.lib;
+    var WordArray = C_lib.WordArray;
+    var Hasher = C_lib.Hasher;
+    var C_algo = C.algo;
+
+    // Initialization and round constants tables
+    var H = [];
+    var K = [];
+
+    // Compute constants
+    (function () {
+        function isPrime(n) {
+            var sqrtN = Math.sqrt(n);
+            for (var factor = 2; factor <= sqrtN; factor++) {
+                if (!(n % factor)) {
+                    return false;
+                }
+            }
+
+            return true;
+        }
+
+        function getFractionalBits(n) {
+            return ((n - (n | 0)) * 0x100000000) | 0;
+        }
+
+        var n = 2;
+        var nPrime = 0;
+        while (nPrime < 64) {
+            if (isPrime(n)) {
+                if (nPrime < 8) {
+                    H[nPrime] = getFractionalBits(Math.pow(n, 1 / 2));
+                }
+                K[nPrime] = getFractionalBits(Math.pow(n, 1 / 3));
+
+                nPrime++;
+            }
+
+            n++;
+        }
+    }());
+
+    // Reusable object
+    var W = [];
+
+    /**
+     * SHA-256 hash algorithm.
+     */
+    var SHA256 = C_algo.SHA256 = Hasher.extend({
+        _doReset: function () {
+            this._hash = new WordArray.init(H.slice(0));
+        },
+
+        _doProcessBlock: function (M, offset) {
+            // Shortcut
+            var H = this._hash.words;
+
+            // Working variables
+            var a = H[0];
+            var b = H[1];
+            var c = H[2];
+            var d = H[3];
+            var e = H[4];
+            var f = H[5];
+            var g = H[6];
+            var h = H[7];
+
+            // Computation
+            for (var i = 0; i < 64; i++) {
+                if (i < 16) {
+                    W[i] = M[offset + i] | 0;
+                } else {
+                    var gamma0x = W[i - 15];
+                    var gamma0  = ((gamma0x << 25) | (gamma0x >>> 7))  ^
+                                  ((gamma0x << 14) | (gamma0x >>> 18)) ^
+                                   (gamma0x >>> 3);
+
+                    var gamma1x = W[i - 2];
+                    var gamma1  = ((gamma1x << 15) | (gamma1x >>> 17)) ^
+                                  ((gamma1x << 13) | (gamma1x >>> 19)) ^
+                                   (gamma1x >>> 10);
+
+                    W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16];
+                }
+
+                var ch  = (e & f) ^ (~e & g);
+                var maj = (a & b) ^ (a & c) ^ (b & c);
+
+                var sigma0 = ((a << 30) | (a >>> 2)) ^ ((a << 19) | (a >>> 13)) ^ ((a << 10) | (a >>> 22));
+                var sigma1 = ((e << 26) | (e >>> 6)) ^ ((e << 21) | (e >>> 11)) ^ ((e << 7)  | (e >>> 25));
+
+                var t1 = h + sigma1 + ch + K[i] + W[i];
+                var t2 = sigma0 + maj;
+
+                h = g;
+                g = f;
+                f = e;
+                e = (d + t1) | 0;
+                d = c;
+                c = b;
+                b = a;
+                a = (t1 + t2) | 0;
+            }
+
+            // Intermediate hash value
+            H[0] = (H[0] + a) | 0;
+            H[1] = (H[1] + b) | 0;
+            H[2] = (H[2] + c) | 0;
+            H[3] = (H[3] + d) | 0;
+            H[4] = (H[4] + e) | 0;
+            H[5] = (H[5] + f) | 0;
+            H[6] = (H[6] + g) | 0;
+            H[7] = (H[7] + h) | 0;
+        },
+
+        _doFinalize: function () {
+            // Shortcuts
+            var data = this._data;
+            var dataWords = data.words;
+
+            var nBitsTotal = this._nDataBytes * 8;
+            var nBitsLeft = data.sigBytes * 8;
+
+            // Add padding
+            dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
+            dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000);
+            dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal;
+            data.sigBytes = dataWords.length * 4;
+
+            // Hash final blocks
+            this._process();
+
+            // Return final computed hash
+            return this._hash;
+        },
+
+        clone: function () {
+            var clone = Hasher.clone.call(this);
+            clone._hash = this._hash.clone();
+
+            return clone;
+        }
+    });
+
+    /**
+     * Shortcut function to the hasher's object interface.
+     *
+     * @param {WordArray|string} message The message to hash.
+     *
+     * @return {WordArray} The hash.
+     *
+     * @static
+     *
+     * @example
+     *
+     *     var hash = CryptoJS.SHA256('message');
+     *     var hash = CryptoJS.SHA256(wordArray);
+     */
+    C.SHA256 = Hasher._createHelper(SHA256);
+
+    /**
+     * Shortcut function to the HMAC's object interface.
+     *
+     * @param {WordArray|string} message The message to hash.
+     * @param {WordArray|string} key The secret key.
+     *
+     * @return {WordArray} The HMAC.
+     *
+     * @static
+     *
+     * @example
+     *
+     *     var hmac = CryptoJS.HmacSHA256(message, key);
+     */
+    C.HmacSHA256 = Hasher._createHmacHelper(SHA256);
+}(Math));
diff --git a/src/sha3.js b/src/sha3.js
new file mode 100644
index 0000000..9545fcd
--- /dev/null
+++ b/src/sha3.js
@@ -0,0 +1,306 @@
+(function (Math) {
+    // Shortcuts
+    var C = CryptoJS;
+    var C_lib = C.lib;
+    var WordArray = C_lib.WordArray;
+    var Hasher = C_lib.Hasher;
+    var C_x64 = C.x64;
+    var X64Word = C_x64.Word;
+    var C_algo = C.algo;
+
+    // Constants tables
+    var RHO_OFFSETS = [];
+    var PI_INDEXES  = [];
+    var ROUND_CONSTANTS = [];
+
+    // Compute Constants
+    (function () {
+        // Compute rho offset constants
+        var x = 1, y = 0;
+        for (var t = 0; t < 24; t++) {
+            RHO_OFFSETS[x + 5 * y] = ((t + 1) * (t + 2) / 2) % 64;
+
+            var newX = y % 5;
+            var newY = (2 * x + 3 * y) % 5;
+            x = newX;
+            y = newY;
+        }
+
+        // Compute pi index constants
+        for (var x = 0; x < 5; x++) {
+            for (var y = 0; y < 5; y++) {
+                PI_INDEXES[x + 5 * y] = y + ((2 * x + 3 * y) % 5) * 5;
+            }
+        }
+
+        // Compute round constants
+        var LFSR = 0x01;
+        for (var i = 0; i < 24; i++) {
+            var roundConstantMsw = 0;
+            var roundConstantLsw = 0;
+
+            for (var j = 0; j < 7; j++) {
+                if (LFSR & 0x01) {
+                    var bitPosition = (1 << j) - 1;
+                    if (bitPosition < 32) {
+                        roundConstantLsw ^= 1 << bitPosition;
+                    } else /* if (bitPosition >= 32) */ {
+                        roundConstantMsw ^= 1 << (bitPosition - 32);
+                    }
+                }
+
+                // Compute next LFSR
+                if (LFSR & 0x80) {
+                    // Primitive polynomial over GF(2): x^8 + x^6 + x^5 + x^4 + 1
+                    LFSR = (LFSR << 1) ^ 0x71;
+                } else {
+                    LFSR <<= 1;
+                }
+            }
+
+            ROUND_CONSTANTS[i] = X64Word.create(roundConstantMsw, roundConstantLsw);
+        }
+    }());
+
+    // Reusable objects for temporary values
+    var T = [];
+    (function () {
+        for (var i = 0; i < 25; i++) {
+            T[i] = X64Word.create();
+        }
+    }());
+
+    /**
+     * SHA-3 hash algorithm.
+     */
+    var SHA3 = C_algo.SHA3 = Hasher.extend({
+        /**
+         * Configuration options.
+         *
+         * @property {number} outputLength
+         *   The desired number of bits in the output hash.
+         *   Only values permitted are: 224, 256, 384, 512.
+         *   Default: 512
+         */
+        cfg: Hasher.cfg.extend({
+            outputLength: 512
+        }),
+
+        _doReset: function () {
+            var state = this._state = []
+            for (var i = 0; i < 25; i++) {
+                state[i] = new X64Word.init();
+            }
+
+            this.blockSize = (1600 - 2 * this.cfg.outputLength) / 32;
+        },
+
+        _doProcessBlock: function (M, offset) {
+            // Shortcuts
+            var state = this._state;
+            var nBlockSizeLanes = this.blockSize / 2;
+
+            // Absorb
+            for (var i = 0; i < nBlockSizeLanes; i++) {
+                // Shortcuts
+                var M2i  = M[offset + 2 * i];
+                var M2i1 = M[offset + 2 * i + 1];
+
+                // Swap endian
+                M2i = (
+                    (((M2i << 8)  | (M2i >>> 24)) & 0x00ff00ff) |
+                    (((M2i << 24) | (M2i >>> 8))  & 0xff00ff00)
+                );
+                M2i1 = (
+                    (((M2i1 << 8)  | (M2i1 >>> 24)) & 0x00ff00ff) |
+                    (((M2i1 << 24) | (M2i1 >>> 8))  & 0xff00ff00)
+                );
+
+                // Absorb message into state
+                var lane = state[i];
+                lane.high ^= M2i1;
+                lane.low  ^= M2i;
+            }
+
+            // Rounds
+            for (var round = 0; round < 24; round++) {
+                // Theta
+                for (var x = 0; x < 5; x++) {
+                    // Mix column lanes
+                    var tMsw = 0, tLsw = 0;
+                    for (var y = 0; y < 5; y++) {
+                        var lane = state[x + 5 * y];
+                        tMsw ^= lane.high;
+                        tLsw ^= lane.low;
+                    }
+
+                    // Temporary values
+                    var Tx = T[x];
+                    Tx.high = tMsw;
+                    Tx.low  = tLsw;
+                }
+                for (var x = 0; x < 5; x++) {
+                    // Shortcuts
+                    var Tx4 = T[(x + 4) % 5];
+                    var Tx1 = T[(x + 1) % 5];
+                    var Tx1Msw = Tx1.high;
+                    var Tx1Lsw = Tx1.low;
+
+                    // Mix surrounding columns
+                    var tMsw = Tx4.high ^ ((Tx1Msw << 1) | (Tx1Lsw >>> 31));
+                    var tLsw = Tx4.low  ^ ((Tx1Lsw << 1) | (Tx1Msw >>> 31));
+                    for (var y = 0; y < 5; y++) {
+                        var lane = state[x + 5 * y];
+                        lane.high ^= tMsw;
+                        lane.low  ^= tLsw;
+                    }
+                }
+
+                // Rho Pi
+                for (var laneIndex = 1; laneIndex < 25; laneIndex++) {
+                    var tMsw;
+                    var tLsw;
+
+                    // Shortcuts
+                    var lane = state[laneIndex];
+                    var laneMsw = lane.high;
+                    var laneLsw = lane.low;
+                    var rhoOffset = RHO_OFFSETS[laneIndex];
+
+                    // Rotate lanes
+                    if (rhoOffset < 32) {
+                        tMsw = (laneMsw << rhoOffset) | (laneLsw >>> (32 - rhoOffset));
+                        tLsw = (laneLsw << rhoOffset) | (laneMsw >>> (32 - rhoOffset));
+                    } else /* if (rhoOffset >= 32) */ {
+                        tMsw = (laneLsw << (rhoOffset - 32)) | (laneMsw >>> (64 - rhoOffset));
+                        tLsw = (laneMsw << (rhoOffset - 32)) | (laneLsw >>> (64 - rhoOffset));
+                    }
+
+                    // Transpose lanes
+                    var TPiLane = T[PI_INDEXES[laneIndex]];
+                    TPiLane.high = tMsw;
+                    TPiLane.low  = tLsw;
+                }
+
+                // Rho pi at x = y = 0
+                var T0 = T[0];
+                var state0 = state[0];
+                T0.high = state0.high;
+                T0.low  = state0.low;
+
+                // Chi
+                for (var x = 0; x < 5; x++) {
+                    for (var y = 0; y < 5; y++) {
+                        // Shortcuts
+                        var laneIndex = x + 5 * y;
+                        var lane = state[laneIndex];
+                        var TLane = T[laneIndex];
+                        var Tx1Lane = T[((x + 1) % 5) + 5 * y];
+                        var Tx2Lane = T[((x + 2) % 5) + 5 * y];
+
+                        // Mix rows
+                        lane.high = TLane.high ^ (~Tx1Lane.high & Tx2Lane.high);
+                        lane.low  = TLane.low  ^ (~Tx1Lane.low  & Tx2Lane.low);
+                    }
+                }
+
+                // Iota
+                var lane = state[0];
+                var roundConstant = ROUND_CONSTANTS[round];
+                lane.high ^= roundConstant.high;
+                lane.low  ^= roundConstant.low;
+            }
+        },
+
+        _doFinalize: function () {
+            // Shortcuts
+            var data = this._data;
+            var dataWords = data.words;
+            var nBitsTotal = this._nDataBytes * 8;
+            var nBitsLeft = data.sigBytes * 8;
+            var blockSizeBits = this.blockSize * 32;
+
+            // Add padding
+            dataWords[nBitsLeft >>> 5] |= 0x1 << (24 - nBitsLeft % 32);
+            dataWords[((Math.ceil((nBitsLeft + 1) / blockSizeBits) * blockSizeBits) >>> 5) - 1] |= 0x80;
+            data.sigBytes = dataWords.length * 4;
+
+            // Hash final blocks
+            this._process();
+
+            // Shortcuts
+            var state = this._state;
+            var outputLengthBytes = this.cfg.outputLength / 8;
+            var outputLengthLanes = outputLengthBytes / 8;
+
+            // Squeeze
+            var hashWords = [];
+            for (var i = 0; i < outputLengthLanes; i++) {
+                // Shortcuts
+                var lane = state[i];
+                var laneMsw = lane.high;
+                var laneLsw = lane.low;
+
+                // Swap endian
+                laneMsw = (
+                    (((laneMsw << 8)  | (laneMsw >>> 24)) & 0x00ff00ff) |
+                    (((laneMsw << 24) | (laneMsw >>> 8))  & 0xff00ff00)
+                );
+                laneLsw = (
+                    (((laneLsw << 8)  | (laneLsw >>> 24)) & 0x00ff00ff) |
+                    (((laneLsw << 24) | (laneLsw >>> 8))  & 0xff00ff00)
+                );
+
+                // Squeeze state to retrieve hash
+                hashWords.push(laneLsw);
+                hashWords.push(laneMsw);
+            }
+
+            // Return final computed hash
+            return new WordArray.init(hashWords, outputLengthBytes);
+        },
+
+        clone: function () {
+            var clone = Hasher.clone.call(this);
+
+            var state = clone._state = this._state.slice(0);
+            for (var i = 0; i < 25; i++) {
+                state[i] = state[i].clone();
+            }
+
+            return clone;
+        }
+    });
+
+    /**
+     * Shortcut function to the hasher's object interface.
+     *
+     * @param {WordArray|string} message The message to hash.
+     *
+     * @return {WordArray} The hash.
+     *
+     * @static
+     *
+     * @example
+     *
+     *     var hash = CryptoJS.SHA3('message');
+     *     var hash = CryptoJS.SHA3(wordArray);
+     */
+    C.SHA3 = Hasher._createHelper(SHA3);
+
+    /**
+     * Shortcut function to the HMAC's object interface.
+     *
+     * @param {WordArray|string} message The message to hash.
+     * @param {WordArray|string} key The secret key.
+     *
+     * @return {WordArray} The HMAC.
+     *
+     * @static
+     *
+     * @example
+     *
+     *     var hmac = CryptoJS.HmacSHA3(message, key);
+     */
+    C.HmacSHA3 = Hasher._createHmacHelper(SHA3);
+}(Math));
diff --git a/src/sha384.js b/src/sha384.js
new file mode 100644
index 0000000..b15965b
--- /dev/null
+++ b/src/sha384.js
@@ -0,0 +1,63 @@
+(function () {
+    // Shortcuts
+    var C = CryptoJS;
+    var C_x64 = C.x64;
+    var X64Word = C_x64.Word;
+    var X64WordArray = C_x64.WordArray;
+    var C_algo = C.algo;
+    var SHA512 = C_algo.SHA512;
+
+    /**
+     * SHA-384 hash algorithm.
+     */
+    var SHA384 = C_algo.SHA384 = SHA512.extend({
+        _doReset: function () {
+            this._hash = new X64WordArray.init([
+                new X64Word.init(0xcbbb9d5d, 0xc1059ed8), new X64Word.init(0x629a292a, 0x367cd507),
+                new X64Word.init(0x9159015a, 0x3070dd17), new X64Word.init(0x152fecd8, 0xf70e5939),
+                new X64Word.init(0x67332667, 0xffc00b31), new X64Word.init(0x8eb44a87, 0x68581511),
+                new X64Word.init(0xdb0c2e0d, 0x64f98fa7), new X64Word.init(0x47b5481d, 0xbefa4fa4)
+            ]);
+        },
+
+        _doFinalize: function () {
+            var hash = SHA512._doFinalize.call(this);
+
+            hash.sigBytes -= 16;
+
+            return hash;
+        }
+    });
+
+    /**
+     * Shortcut function to the hasher's object interface.
+     *
+     * @param {WordArray|string} message The message to hash.
+     *
+     * @return {WordArray} The hash.
+     *
+     * @static
+     *
+     * @example
+     *
+     *     var hash = CryptoJS.SHA384('message');
+     *     var hash = CryptoJS.SHA384(wordArray);
+     */
+    C.SHA384 = SHA512._createHelper(SHA384);
+
+    /**
+     * Shortcut function to the HMAC's object interface.
+     *
+     * @param {WordArray|string} message The message to hash.
+     * @param {WordArray|string} key The secret key.
+     *
+     * @return {WordArray} The HMAC.
+     *
+     * @static
+     *
+     * @example
+     *
+     *     var hmac = CryptoJS.HmacSHA384(message, key);
+     */
+    C.HmacSHA384 = SHA512._createHmacHelper(SHA384);
+}());
diff --git a/src/sha512.js b/src/sha512.js
new file mode 100644
index 0000000..2ca9991
--- /dev/null
+++ b/src/sha512.js
@@ -0,0 +1,306 @@
+(function () {
+    // Shortcuts
+    var C = CryptoJS;
+    var C_lib = C.lib;
+    var Hasher = C_lib.Hasher;
+    var C_x64 = C.x64;
+    var X64Word = C_x64.Word;
+    var X64WordArray = C_x64.WordArray;
+    var C_algo = C.algo;
+
+    function X64Word_create() {
+        return X64Word.create.apply(X64Word, arguments);
+    }
+
+    // Constants
+    var K = [
+        X64Word_create(0x428a2f98, 0xd728ae22), X64Word_create(0x71374491, 0x23ef65cd),
+        X64Word_create(0xb5c0fbcf, 0xec4d3b2f), X64Word_create(0xe9b5dba5, 0x8189dbbc),
+        X64Word_create(0x3956c25b, 0xf348b538), X64Word_create(0x59f111f1, 0xb605d019),
+        X64Word_create(0x923f82a4, 0xaf194f9b), X64Word_create(0xab1c5ed5, 0xda6d8118),
+        X64Word_create(0xd807aa98, 0xa3030242), X64Word_create(0x12835b01, 0x45706fbe),
+        X64Word_create(0x243185be, 0x4ee4b28c), X64Word_create(0x550c7dc3, 0xd5ffb4e2),
+        X64Word_create(0x72be5d74, 0xf27b896f), X64Word_create(0x80deb1fe, 0x3b1696b1),
+        X64Word_create(0x9bdc06a7, 0x25c71235), X64Word_create(0xc19bf174, 0xcf692694),
+        X64Word_create(0xe49b69c1, 0x9ef14ad2), X64Word_create(0xefbe4786, 0x384f25e3),
+        X64Word_create(0x0fc19dc6, 0x8b8cd5b5), X64Word_create(0x240ca1cc, 0x77ac9c65),
+        X64Word_create(0x2de92c6f, 0x592b0275), X64Word_create(0x4a7484aa, 0x6ea6e483),
+        X64Word_create(0x5cb0a9dc, 0xbd41fbd4), X64Word_create(0x76f988da, 0x831153b5),
+        X64Word_create(0x983e5152, 0xee66dfab), X64Word_create(0xa831c66d, 0x2db43210),
+        X64Word_create(0xb00327c8, 0x98fb213f), X64Word_create(0xbf597fc7, 0xbeef0ee4),
+        X64Word_create(0xc6e00bf3, 0x3da88fc2), X64Word_create(0xd5a79147, 0x930aa725),
+        X64Word_create(0x06ca6351, 0xe003826f), X64Word_create(0x14292967, 0x0a0e6e70),
+        X64Word_create(0x27b70a85, 0x46d22ffc), X64Word_create(0x2e1b2138, 0x5c26c926),
+        X64Word_create(0x4d2c6dfc, 0x5ac42aed), X64Word_create(0x53380d13, 0x9d95b3df),
+        X64Word_create(0x650a7354, 0x8baf63de), X64Word_create(0x766a0abb, 0x3c77b2a8),
+        X64Word_create(0x81c2c92e, 0x47edaee6), X64Word_create(0x92722c85, 0x1482353b),
+        X64Word_create(0xa2bfe8a1, 0x4cf10364), X64Word_create(0xa81a664b, 0xbc423001),
+        X64Word_create(0xc24b8b70, 0xd0f89791), X64Word_create(0xc76c51a3, 0x0654be30),
+        X64Word_create(0xd192e819, 0xd6ef5218), X64Word_create(0xd6990624, 0x5565a910),
+        X64Word_create(0xf40e3585, 0x5771202a), X64Word_create(0x106aa070, 0x32bbd1b8),
+        X64Word_create(0x19a4c116, 0xb8d2d0c8), X64Word_create(0x1e376c08, 0x5141ab53),
+        X64Word_create(0x2748774c, 0xdf8eeb99), X64Word_create(0x34b0bcb5, 0xe19b48a8),
+        X64Word_create(0x391c0cb3, 0xc5c95a63), X64Word_create(0x4ed8aa4a, 0xe3418acb),
+        X64Word_create(0x5b9cca4f, 0x7763e373), X64Word_create(0x682e6ff3, 0xd6b2b8a3),
+        X64Word_create(0x748f82ee, 0x5defb2fc), X64Word_create(0x78a5636f, 0x43172f60),
+        X64Word_create(0x84c87814, 0xa1f0ab72), X64Word_create(0x8cc70208, 0x1a6439ec),
+        X64Word_create(0x90befffa, 0x23631e28), X64Word_create(0xa4506ceb, 0xde82bde9),
+        X64Word_create(0xbef9a3f7, 0xb2c67915), X64Word_create(0xc67178f2, 0xe372532b),
+        X64Word_create(0xca273ece, 0xea26619c), X64Word_create(0xd186b8c7, 0x21c0c207),
+        X64Word_create(0xeada7dd6, 0xcde0eb1e), X64Word_create(0xf57d4f7f, 0xee6ed178),
+        X64Word_create(0x06f067aa, 0x72176fba), X64Word_create(0x0a637dc5, 0xa2c898a6),
+        X64Word_create(0x113f9804, 0xbef90dae), X64Word_create(0x1b710b35, 0x131c471b),
+        X64Word_create(0x28db77f5, 0x23047d84), X64Word_create(0x32caab7b, 0x40c72493),
+        X64Word_create(0x3c9ebe0a, 0x15c9bebc), X64Word_create(0x431d67c4, 0x9c100d4c),
+        X64Word_create(0x4cc5d4be, 0xcb3e42b6), X64Word_create(0x597f299c, 0xfc657e2a),
+        X64Word_create(0x5fcb6fab, 0x3ad6faec), X64Word_create(0x6c44198c, 0x4a475817)
+    ];
+
+    // Reusable objects
+    var W = [];
+    (function () {
+        for (var i = 0; i < 80; i++) {
+            W[i] = X64Word_create();
+        }
+    }());
+
+    /**
+     * SHA-512 hash algorithm.
+     */
+    var SHA512 = C_algo.SHA512 = Hasher.extend({
+        _doReset: function () {
+            this._hash = new X64WordArray.init([
+                new X64Word.init(0x6a09e667, 0xf3bcc908), new X64Word.init(0xbb67ae85, 0x84caa73b),
+                new X64Word.init(0x3c6ef372, 0xfe94f82b), new X64Word.init(0xa54ff53a, 0x5f1d36f1),
+                new X64Word.init(0x510e527f, 0xade682d1), new X64Word.init(0x9b05688c, 0x2b3e6c1f),
+                new X64Word.init(0x1f83d9ab, 0xfb41bd6b), new X64Word.init(0x5be0cd19, 0x137e2179)
+            ]);
+        },
+
+        _doProcessBlock: function (M, offset) {
+            // Shortcuts
+            var H = this._hash.words;
+
+            var H0 = H[0];
+            var H1 = H[1];
+            var H2 = H[2];
+            var H3 = H[3];
+            var H4 = H[4];
+            var H5 = H[5];
+            var H6 = H[6];
+            var H7 = H[7];
+
+            var H0h = H0.high;
+            var H0l = H0.low;
+            var H1h = H1.high;
+            var H1l = H1.low;
+            var H2h = H2.high;
+            var H2l = H2.low;
+            var H3h = H3.high;
+            var H3l = H3.low;
+            var H4h = H4.high;
+            var H4l = H4.low;
+            var H5h = H5.high;
+            var H5l = H5.low;
+            var H6h = H6.high;
+            var H6l = H6.low;
+            var H7h = H7.high;
+            var H7l = H7.low;
+
+            // Working variables
+            var ah = H0h;
+            var al = H0l;
+            var bh = H1h;
+            var bl = H1l;
+            var ch = H2h;
+            var cl = H2l;
+            var dh = H3h;
+            var dl = H3l;
+            var eh = H4h;
+            var el = H4l;
+            var fh = H5h;
+            var fl = H5l;
+            var gh = H6h;
+            var gl = H6l;
+            var hh = H7h;
+            var hl = H7l;
+
+            // Rounds
+            for (var i = 0; i < 80; i++) {
+                var Wil;
+                var Wih;
+
+                // Shortcut
+                var Wi = W[i];
+
+                // Extend message
+                if (i < 16) {
+                    Wih = Wi.high = M[offset + i * 2]     | 0;
+                    Wil = Wi.low  = M[offset + i * 2 + 1] | 0;
+                } else {
+                    // Gamma0
+                    var gamma0x  = W[i - 15];
+                    var gamma0xh = gamma0x.high;
+                    var gamma0xl = gamma0x.low;
+                    var gamma0h  = ((gamma0xh >>> 1) | (gamma0xl << 31)) ^ ((gamma0xh >>> 8) | (gamma0xl << 24)) ^ (gamma0xh >>> 7);
+                    var gamma0l  = ((gamma0xl >>> 1) | (gamma0xh << 31)) ^ ((gamma0xl >>> 8) | (gamma0xh << 24)) ^ ((gamma0xl >>> 7) | (gamma0xh << 25));
+
+                    // Gamma1
+                    var gamma1x  = W[i - 2];
+                    var gamma1xh = gamma1x.high;
+                    var gamma1xl = gamma1x.low;
+                    var gamma1h  = ((gamma1xh >>> 19) | (gamma1xl << 13)) ^ ((gamma1xh << 3) | (gamma1xl >>> 29)) ^ (gamma1xh >>> 6);
+                    var gamma1l  = ((gamma1xl >>> 19) | (gamma1xh << 13)) ^ ((gamma1xl << 3) | (gamma1xh >>> 29)) ^ ((gamma1xl >>> 6) | (gamma1xh << 26));
+
+                    // W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16]
+                    var Wi7  = W[i - 7];
+                    var Wi7h = Wi7.high;
+                    var Wi7l = Wi7.low;
+
+                    var Wi16  = W[i - 16];
+                    var Wi16h = Wi16.high;
+                    var Wi16l = Wi16.low;
+
+                    Wil = gamma0l + Wi7l;
+                    Wih = gamma0h + Wi7h + ((Wil >>> 0) < (gamma0l >>> 0) ? 1 : 0);
+                    Wil = Wil + gamma1l;
+                    Wih = Wih + gamma1h + ((Wil >>> 0) < (gamma1l >>> 0) ? 1 : 0);
+                    Wil = Wil + Wi16l;
+                    Wih = Wih + Wi16h + ((Wil >>> 0) < (Wi16l >>> 0) ? 1 : 0);
+
+                    Wi.high = Wih;
+                    Wi.low  = Wil;
+                }
+
+                var chh  = (eh & fh) ^ (~eh & gh);
+                var chl  = (el & fl) ^ (~el & gl);
+                var majh = (ah & bh) ^ (ah & ch) ^ (bh & ch);
+                var majl = (al & bl) ^ (al & cl) ^ (bl & cl);
+
+                var sigma0h = ((ah >>> 28) | (al << 4))  ^ ((ah << 30)  | (al >>> 2)) ^ ((ah << 25) | (al >>> 7));
+                var sigma0l = ((al >>> 28) | (ah << 4))  ^ ((al << 30)  | (ah >>> 2)) ^ ((al << 25) | (ah >>> 7));
+                var sigma1h = ((eh >>> 14) | (el << 18)) ^ ((eh >>> 18) | (el << 14)) ^ ((eh << 23) | (el >>> 9));
+                var sigma1l = ((el >>> 14) | (eh << 18)) ^ ((el >>> 18) | (eh << 14)) ^ ((el << 23) | (eh >>> 9));
+
+                // t1 = h + sigma1 + ch + K[i] + W[i]
+                var Ki  = K[i];
+                var Kih = Ki.high;
+                var Kil = Ki.low;
+
+                var t1l = hl + sigma1l;
+                var t1h = hh + sigma1h + ((t1l >>> 0) < (hl >>> 0) ? 1 : 0);
+                var t1l = t1l + chl;
+                var t1h = t1h + chh + ((t1l >>> 0) < (chl >>> 0) ? 1 : 0);
+                var t1l = t1l + Kil;
+                var t1h = t1h + Kih + ((t1l >>> 0) < (Kil >>> 0) ? 1 : 0);
+                var t1l = t1l + Wil;
+                var t1h = t1h + Wih + ((t1l >>> 0) < (Wil >>> 0) ? 1 : 0);
+
+                // t2 = sigma0 + maj
+                var t2l = sigma0l + majl;
+                var t2h = sigma0h + majh + ((t2l >>> 0) < (sigma0l >>> 0) ? 1 : 0);
+
+                // Update working variables
+                hh = gh;
+                hl = gl;
+                gh = fh;
+                gl = fl;
+                fh = eh;
+                fl = el;
+                el = (dl + t1l) | 0;
+                eh = (dh + t1h + ((el >>> 0) < (dl >>> 0) ? 1 : 0)) | 0;
+                dh = ch;
+                dl = cl;
+                ch = bh;
+                cl = bl;
+                bh = ah;
+                bl = al;
+                al = (t1l + t2l) | 0;
+                ah = (t1h + t2h + ((al >>> 0) < (t1l >>> 0) ? 1 : 0)) | 0;
+            }
+
+            // Intermediate hash value
+            H0l = H0.low  = (H0l + al);
+            H0.high = (H0h + ah + ((H0l >>> 0) < (al >>> 0) ? 1 : 0));
+            H1l = H1.low  = (H1l + bl);
+            H1.high = (H1h + bh + ((H1l >>> 0) < (bl >>> 0) ? 1 : 0));
+            H2l = H2.low  = (H2l + cl);
+            H2.high = (H2h + ch + ((H2l >>> 0) < (cl >>> 0) ? 1 : 0));
+            H3l = H3.low  = (H3l + dl);
+            H3.high = (H3h + dh + ((H3l >>> 0) < (dl >>> 0) ? 1 : 0));
+            H4l = H4.low  = (H4l + el);
+            H4.high = (H4h + eh + ((H4l >>> 0) < (el >>> 0) ? 1 : 0));
+            H5l = H5.low  = (H5l + fl);
+            H5.high = (H5h + fh + ((H5l >>> 0) < (fl >>> 0) ? 1 : 0));
+            H6l = H6.low  = (H6l + gl);
+            H6.high = (H6h + gh + ((H6l >>> 0) < (gl >>> 0) ? 1 : 0));
+            H7l = H7.low  = (H7l + hl);
+            H7.high = (H7h + hh + ((H7l >>> 0) < (hl >>> 0) ? 1 : 0));
+        },
+
+        _doFinalize: function () {
+            // Shortcuts
+            var data = this._data;
+            var dataWords = data.words;
+
+            var nBitsTotal = this._nDataBytes * 8;
+            var nBitsLeft = data.sigBytes * 8;
+
+            // Add padding
+            dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
+            dataWords[(((nBitsLeft + 128) >>> 10) << 5) + 30] = Math.floor(nBitsTotal / 0x100000000);
+            dataWords[(((nBitsLeft + 128) >>> 10) << 5) + 31] = nBitsTotal;
+            data.sigBytes = dataWords.length * 4;
+
+            // Hash final blocks
+            this._process();
+
+            // Convert hash to 32-bit word array before returning
+            var hash = this._hash.toX32();
+
+            // Return final computed hash
+            return hash;
+        },
+
+        clone: function () {
+            var clone = Hasher.clone.call(this);
+            clone._hash = this._hash.clone();
+
+            return clone;
+        },
+
+        blockSize: 1024/32
+    });
+
+    /**
+     * Shortcut function to the hasher's object interface.
+     *
+     * @param {WordArray|string} message The message to hash.
+     *
+     * @return {WordArray} The hash.
+     *
+     * @static
+     *
+     * @example
+     *
+     *     var hash = CryptoJS.SHA512('message');
+     *     var hash = CryptoJS.SHA512(wordArray);
+     */
+    C.SHA512 = Hasher._createHelper(SHA512);
+
+    /**
+     * Shortcut function to the HMAC's object interface.
+     *
+     * @param {WordArray|string} message The message to hash.
+     * @param {WordArray|string} key The secret key.
+     *
+     * @return {WordArray} The HMAC.
+     *
+     * @static
+     *
+     * @example
+     *
+     *     var hmac = CryptoJS.HmacSHA512(message, key);
+     */
+    C.HmacSHA512 = Hasher._createHmacHelper(SHA512);
+}());
diff --git a/src/tripledes.js b/src/tripledes.js
new file mode 100644
index 0000000..0777c7c
--- /dev/null
+++ b/src/tripledes.js
@@ -0,0 +1,759 @@
+(function () {
+    // Shortcuts
+    var C = CryptoJS;
+    var C_lib = C.lib;
+    var WordArray = C_lib.WordArray;
+    var BlockCipher = C_lib.BlockCipher;
+    var C_algo = C.algo;
+
+    // Permuted Choice 1 constants
+    var PC1 = [
+        57, 49, 41, 33, 25, 17, 9,  1,
+        58, 50, 42, 34, 26, 18, 10, 2,
+        59, 51, 43, 35, 27, 19, 11, 3,
+        60, 52, 44, 36, 63, 55, 47, 39,
+        31, 23, 15, 7,  62, 54, 46, 38,
+        30, 22, 14, 6,  61, 53, 45, 37,
+        29, 21, 13, 5,  28, 20, 12, 4
+    ];
+
+    // Permuted Choice 2 constants
+    var PC2 = [
+        14, 17, 11, 24, 1,  5,
+        3,  28, 15, 6,  21, 10,
+        23, 19, 12, 4,  26, 8,
+        16, 7,  27, 20, 13, 2,
+        41, 52, 31, 37, 47, 55,
+        30, 40, 51, 45, 33, 48,
+        44, 49, 39, 56, 34, 53,
+        46, 42, 50, 36, 29, 32
+    ];
+
+    // Cumulative bit shift constants
+    var BIT_SHIFTS = [1,  2,  4,  6,  8,  10, 12, 14, 15, 17, 19, 21, 23, 25, 27, 28];
+
+    // SBOXes and round permutation constants
+    var SBOX_P = [
+        {
+            0x0: 0x808200,
+            0x10000000: 0x8000,
+            0x20000000: 0x808002,
+            0x30000000: 0x2,
+            0x40000000: 0x200,
+            0x50000000: 0x808202,
+            0x60000000: 0x800202,
+            0x70000000: 0x800000,
+            0x80000000: 0x202,
+            0x90000000: 0x800200,
+            0xa0000000: 0x8200,
+            0xb0000000: 0x808000,
+            0xc0000000: 0x8002,
+            0xd0000000: 0x800002,
+            0xe0000000: 0x0,
+            0xf0000000: 0x8202,
+            0x8000000: 0x0,
+            0x18000000: 0x808202,
+            0x28000000: 0x8202,
+            0x38000000: 0x8000,
+            0x48000000: 0x808200,
+            0x58000000: 0x200,
+            0x68000000: 0x808002,
+            0x78000000: 0x2,
+            0x88000000: 0x800200,
+            0x98000000: 0x8200,
+            0xa8000000: 0x808000,
+            0xb8000000: 0x800202,
+            0xc8000000: 0x800002,
+            0xd8000000: 0x8002,
+            0xe8000000: 0x202,
+            0xf8000000: 0x800000,
+            0x1: 0x8000,
+            0x10000001: 0x2,
+            0x20000001: 0x808200,
+            0x30000001: 0x800000,
+            0x40000001: 0x808002,
+            0x50000001: 0x8200,
+            0x60000001: 0x200,
+            0x70000001: 0x800202,
+            0x80000001: 0x808202,
+            0x90000001: 0x808000,
+            0xa0000001: 0x800002,
+            0xb0000001: 0x8202,
+            0xc0000001: 0x202,
+            0xd0000001: 0x800200,
+            0xe0000001: 0x8002,
+            0xf0000001: 0x0,
+            0x8000001: 0x808202,
+            0x18000001: 0x808000,
+            0x28000001: 0x800000,
+            0x38000001: 0x200,
+            0x48000001: 0x8000,
+            0x58000001: 0x800002,
+            0x68000001: 0x2,
+            0x78000001: 0x8202,
+            0x88000001: 0x8002,
+            0x98000001: 0x800202,
+            0xa8000001: 0x202,
+            0xb8000001: 0x808200,
+            0xc8000001: 0x800200,
+            0xd8000001: 0x0,
+            0xe8000001: 0x8200,
+            0xf8000001: 0x808002
+        },
+        {
+            0x0: 0x40084010,
+            0x1000000: 0x4000,
+            0x2000000: 0x80000,
+            0x3000000: 0x40080010,
+            0x4000000: 0x40000010,
+            0x5000000: 0x40084000,
+            0x6000000: 0x40004000,
+            0x7000000: 0x10,
+            0x8000000: 0x84000,
+            0x9000000: 0x40004010,
+            0xa000000: 0x40000000,
+            0xb000000: 0x84010,
+            0xc000000: 0x80010,
+            0xd000000: 0x0,
+            0xe000000: 0x4010,
+            0xf000000: 0x40080000,
+            0x800000: 0x40004000,
+            0x1800000: 0x84010,
+            0x2800000: 0x10,
+            0x3800000: 0x40004010,
+            0x4800000: 0x40084010,
+            0x5800000: 0x40000000,
+            0x6800000: 0x80000,
+            0x7800000: 0x40080010,
+            0x8800000: 0x80010,
+            0x9800000: 0x0,
+            0xa800000: 0x4000,
+            0xb800000: 0x40080000,
+            0xc800000: 0x40000010,
+            0xd800000: 0x84000,
+            0xe800000: 0x40084000,
+            0xf800000: 0x4010,
+            0x10000000: 0x0,
+            0x11000000: 0x40080010,
+            0x12000000: 0x40004010,
+            0x13000000: 0x40084000,
+            0x14000000: 0x40080000,
+            0x15000000: 0x10,
+            0x16000000: 0x84010,
+            0x17000000: 0x4000,
+            0x18000000: 0x4010,
+            0x19000000: 0x80000,
+            0x1a000000: 0x80010,
+            0x1b000000: 0x40000010,
+            0x1c000000: 0x84000,
+            0x1d000000: 0x40004000,
+            0x1e000000: 0x40000000,
+            0x1f000000: 0x40084010,
+            0x10800000: 0x84010,
+            0x11800000: 0x80000,
+            0x12800000: 0x40080000,
+            0x13800000: 0x4000,
+            0x14800000: 0x40004000,
+            0x15800000: 0x40084010,
+            0x16800000: 0x10,
+            0x17800000: 0x40000000,
+            0x18800000: 0x40084000,
+            0x19800000: 0x40000010,
+            0x1a800000: 0x40004010,
+            0x1b800000: 0x80010,
+            0x1c800000: 0x0,
+            0x1d800000: 0x4010,
+            0x1e800000: 0x40080010,
+            0x1f800000: 0x84000
+        },
+        {
+            0x0: 0x104,
+            0x100000: 0x0,
+            0x200000: 0x4000100,
+            0x300000: 0x10104,
+            0x400000: 0x10004,
+            0x500000: 0x4000004,
+            0x600000: 0x4010104,
+            0x700000: 0x4010000,
+            0x800000: 0x4000000,
+            0x900000: 0x4010100,
+            0xa00000: 0x10100,
+            0xb00000: 0x4010004,
+            0xc00000: 0x4000104,
+            0xd00000: 0x10000,
+            0xe00000: 0x4,
+            0xf00000: 0x100,
+            0x80000: 0x4010100,
+            0x180000: 0x4010004,
+            0x280000: 0x0,
+            0x380000: 0x4000100,
+            0x480000: 0x4000004,
+            0x580000: 0x10000,
+            0x680000: 0x10004,
+            0x780000: 0x104,
+            0x880000: 0x4,
+            0x980000: 0x100,
+            0xa80000: 0x4010000,
+            0xb80000: 0x10104,
+            0xc80000: 0x10100,
+            0xd80000: 0x4000104,
+            0xe80000: 0x4010104,
+            0xf80000: 0x4000000,
+            0x1000000: 0x4010100,
+            0x1100000: 0x10004,
+            0x1200000: 0x10000,
+            0x1300000: 0x4000100,
+            0x1400000: 0x100,
+            0x1500000: 0x4010104,
+            0x1600000: 0x4000004,
+            0x1700000: 0x0,
+            0x1800000: 0x4000104,
+            0x1900000: 0x4000000,
+            0x1a00000: 0x4,
+            0x1b00000: 0x10100,
+            0x1c00000: 0x4010000,
+            0x1d00000: 0x104,
+            0x1e00000: 0x10104,
+            0x1f00000: 0x4010004,
+            0x1080000: 0x4000000,
+            0x1180000: 0x104,
+            0x1280000: 0x4010100,
+            0x1380000: 0x0,
+            0x1480000: 0x10004,
+            0x1580000: 0x4000100,
+            0x1680000: 0x100,
+            0x1780000: 0x4010004,
+            0x1880000: 0x10000,
+            0x1980000: 0x4010104,
+            0x1a80000: 0x10104,
+            0x1b80000: 0x4000004,
+            0x1c80000: 0x4000104,
+            0x1d80000: 0x4010000,
+            0x1e80000: 0x4,
+            0x1f80000: 0x10100
+        },
+        {
+            0x0: 0x80401000,
+            0x10000: 0x80001040,
+            0x20000: 0x401040,
+            0x30000: 0x80400000,
+            0x40000: 0x0,
+            0x50000: 0x401000,
+            0x60000: 0x80000040,
+            0x70000: 0x400040,
+            0x80000: 0x80000000,
+            0x90000: 0x400000,
+            0xa0000: 0x40,
+            0xb0000: 0x80001000,
+            0xc0000: 0x80400040,
+            0xd0000: 0x1040,
+            0xe0000: 0x1000,
+            0xf0000: 0x80401040,
+            0x8000: 0x80001040,
+            0x18000: 0x40,
+            0x28000: 0x80400040,
+            0x38000: 0x80001000,
+            0x48000: 0x401000,
+            0x58000: 0x80401040,
+            0x68000: 0x0,
+            0x78000: 0x80400000,
+            0x88000: 0x1000,
+            0x98000: 0x80401000,
+            0xa8000: 0x400000,
+            0xb8000: 0x1040,
+            0xc8000: 0x80000000,
+            0xd8000: 0x400040,
+            0xe8000: 0x401040,
+            0xf8000: 0x80000040,
+            0x100000: 0x400040,
+            0x110000: 0x401000,
+            0x120000: 0x80000040,
+            0x130000: 0x0,
+            0x140000: 0x1040,
+            0x150000: 0x80400040,
+            0x160000: 0x80401000,
+            0x170000: 0x80001040,
+            0x180000: 0x80401040,
+            0x190000: 0x80000000,
+            0x1a0000: 0x80400000,
+            0x1b0000: 0x401040,
+            0x1c0000: 0x80001000,
+            0x1d0000: 0x400000,
+            0x1e0000: 0x40,
+            0x1f0000: 0x1000,
+            0x108000: 0x80400000,
+            0x118000: 0x80401040,
+            0x128000: 0x0,
+            0x138000: 0x401000,
+            0x148000: 0x400040,
+            0x158000: 0x80000000,
+            0x168000: 0x80001040,
+            0x178000: 0x40,
+            0x188000: 0x80000040,
+            0x198000: 0x1000,
+            0x1a8000: 0x80001000,
+            0x1b8000: 0x80400040,
+            0x1c8000: 0x1040,
+            0x1d8000: 0x80401000,
+            0x1e8000: 0x400000,
+            0x1f8000: 0x401040
+        },
+        {
+            0x0: 0x80,
+            0x1000: 0x1040000,
+            0x2000: 0x40000,
+            0x3000: 0x20000000,
+            0x4000: 0x20040080,
+            0x5000: 0x1000080,
+            0x6000: 0x21000080,
+            0x7000: 0x40080,
+            0x8000: 0x1000000,
+            0x9000: 0x20040000,
+            0xa000: 0x20000080,
+            0xb000: 0x21040080,
+            0xc000: 0x21040000,
+            0xd000: 0x0,
+            0xe000: 0x1040080,
+            0xf000: 0x21000000,
+            0x800: 0x1040080,
+            0x1800: 0x21000080,
+            0x2800: 0x80,
+            0x3800: 0x1040000,
+            0x4800: 0x40000,
+            0x5800: 0x20040080,
+            0x6800: 0x21040000,
+            0x7800: 0x20000000,
+            0x8800: 0x20040000,
+            0x9800: 0x0,
+            0xa800: 0x21040080,
+            0xb800: 0x1000080,
+            0xc800: 0x20000080,
+            0xd800: 0x21000000,
+            0xe800: 0x1000000,
+            0xf800: 0x40080,
+            0x10000: 0x40000,
+            0x11000: 0x80,
+            0x12000: 0x20000000,
+            0x13000: 0x21000080,
+            0x14000: 0x1000080,
+            0x15000: 0x21040000,
+            0x16000: 0x20040080,
+            0x17000: 0x1000000,
+            0x18000: 0x21040080,
+            0x19000: 0x21000000,
+            0x1a000: 0x1040000,
+            0x1b000: 0x20040000,
+            0x1c000: 0x40080,
+            0x1d000: 0x20000080,
+            0x1e000: 0x0,
+            0x1f000: 0x1040080,
+            0x10800: 0x21000080,
+            0x11800: 0x1000000,
+            0x12800: 0x1040000,
+            0x13800: 0x20040080,
+            0x14800: 0x20000000,
+            0x15800: 0x1040080,
+            0x16800: 0x80,
+            0x17800: 0x21040000,
+            0x18800: 0x40080,
+            0x19800: 0x21040080,
+            0x1a800: 0x0,
+            0x1b800: 0x21000000,
+            0x1c800: 0x1000080,
+            0x1d800: 0x40000,
+            0x1e800: 0x20040000,
+            0x1f800: 0x20000080
+        },
+        {
+            0x0: 0x10000008,
+            0x100: 0x2000,
+            0x200: 0x10200000,
+            0x300: 0x10202008,
+            0x400: 0x10002000,
+            0x500: 0x200000,
+            0x600: 0x200008,
+            0x700: 0x10000000,
+            0x800: 0x0,
+            0x900: 0x10002008,
+            0xa00: 0x202000,
+            0xb00: 0x8,
+            0xc00: 0x10200008,
+            0xd00: 0x202008,
+            0xe00: 0x2008,
+            0xf00: 0x10202000,
+            0x80: 0x10200000,
+            0x180: 0x10202008,
+            0x280: 0x8,
+            0x380: 0x200000,
+            0x480: 0x202008,
+            0x580: 0x10000008,
+            0x680: 0x10002000,
+            0x780: 0x2008,
+            0x880: 0x200008,
+            0x980: 0x2000,
+            0xa80: 0x10002008,
+            0xb80: 0x10200008,
+            0xc80: 0x0,
+            0xd80: 0x10202000,
+            0xe80: 0x202000,
+            0xf80: 0x10000000,
+            0x1000: 0x10002000,
+            0x1100: 0x10200008,
+            0x1200: 0x10202008,
+            0x1300: 0x2008,
+            0x1400: 0x200000,
+            0x1500: 0x10000000,
+            0x1600: 0x10000008,
+            0x1700: 0x202000,
+            0x1800: 0x202008,
+            0x1900: 0x0,
+            0x1a00: 0x8,
+            0x1b00: 0x10200000,
+            0x1c00: 0x2000,
+            0x1d00: 0x10002008,
+            0x1e00: 0x10202000,
+            0x1f00: 0x200008,
+            0x1080: 0x8,
+            0x1180: 0x202000,
+            0x1280: 0x200000,
+            0x1380: 0x10000008,
+            0x1480: 0x10002000,
+            0x1580: 0x2008,
+            0x1680: 0x10202008,
+            0x1780: 0x10200000,
+            0x1880: 0x10202000,
+            0x1980: 0x10200008,
+            0x1a80: 0x2000,
+            0x1b80: 0x202008,
+            0x1c80: 0x200008,
+            0x1d80: 0x0,
+            0x1e80: 0x10000000,
+            0x1f80: 0x10002008
+        },
+        {
+            0x0: 0x100000,
+            0x10: 0x2000401,
+            0x20: 0x400,
+            0x30: 0x100401,
+            0x40: 0x2100401,
+            0x50: 0x0,
+            0x60: 0x1,
+            0x70: 0x2100001,
+            0x80: 0x2000400,
+            0x90: 0x100001,
+            0xa0: 0x2000001,
+            0xb0: 0x2100400,
+            0xc0: 0x2100000,
+            0xd0: 0x401,
+            0xe0: 0x100400,
+            0xf0: 0x2000000,
+            0x8: 0x2100001,
+            0x18: 0x0,
+            0x28: 0x2000401,
+            0x38: 0x2100400,
+            0x48: 0x100000,
+            0x58: 0x2000001,
+            0x68: 0x2000000,
+            0x78: 0x401,
+            0x88: 0x100401,
+            0x98: 0x2000400,
+            0xa8: 0x2100000,
+            0xb8: 0x100001,
+            0xc8: 0x400,
+            0xd8: 0x2100401,
+            0xe8: 0x1,
+            0xf8: 0x100400,
+            0x100: 0x2000000,
+            0x110: 0x100000,
+            0x120: 0x2000401,
+            0x130: 0x2100001,
+            0x140: 0x100001,
+            0x150: 0x2000400,
+            0x160: 0x2100400,
+            0x170: 0x100401,
+            0x180: 0x401,
+            0x190: 0x2100401,
+            0x1a0: 0x100400,
+            0x1b0: 0x1,
+            0x1c0: 0x0,
+            0x1d0: 0x2100000,
+            0x1e0: 0x2000001,
+            0x1f0: 0x400,
+            0x108: 0x100400,
+            0x118: 0x2000401,
+            0x128: 0x2100001,
+            0x138: 0x1,
+            0x148: 0x2000000,
+            0x158: 0x100000,
+            0x168: 0x401,
+            0x178: 0x2100400,
+            0x188: 0x2000001,
+            0x198: 0x2100000,
+            0x1a8: 0x0,
+            0x1b8: 0x2100401,
+            0x1c8: 0x100401,
+            0x1d8: 0x400,
+            0x1e8: 0x2000400,
+            0x1f8: 0x100001
+        },
+        {
+            0x0: 0x8000820,
+            0x1: 0x20000,
+            0x2: 0x8000000,
+            0x3: 0x20,
+            0x4: 0x20020,
+            0x5: 0x8020820,
+            0x6: 0x8020800,
+            0x7: 0x800,
+            0x8: 0x8020000,
+            0x9: 0x8000800,
+            0xa: 0x20800,
+            0xb: 0x8020020,
+            0xc: 0x820,
+            0xd: 0x0,
+            0xe: 0x8000020,
+            0xf: 0x20820,
+            0x80000000: 0x800,
+            0x80000001: 0x8020820,
+            0x80000002: 0x8000820,
+            0x80000003: 0x8000000,
+            0x80000004: 0x8020000,
+            0x80000005: 0x20800,
+            0x80000006: 0x20820,
+            0x80000007: 0x20,
+            0x80000008: 0x8000020,
+            0x80000009: 0x820,
+            0x8000000a: 0x20020,
+            0x8000000b: 0x8020800,
+            0x8000000c: 0x0,
+            0x8000000d: 0x8020020,
+            0x8000000e: 0x8000800,
+            0x8000000f: 0x20000,
+            0x10: 0x20820,
+            0x11: 0x8020800,
+            0x12: 0x20,
+            0x13: 0x800,
+            0x14: 0x8000800,
+            0x15: 0x8000020,
+            0x16: 0x8020020,
+            0x17: 0x20000,
+            0x18: 0x0,
+            0x19: 0x20020,
+            0x1a: 0x8020000,
+            0x1b: 0x8000820,
+            0x1c: 0x8020820,
+            0x1d: 0x20800,
+            0x1e: 0x820,
+            0x1f: 0x8000000,
+            0x80000010: 0x20000,
+            0x80000011: 0x800,
+            0x80000012: 0x8020020,
+            0x80000013: 0x20820,
+            0x80000014: 0x20,
+            0x80000015: 0x8020000,
+            0x80000016: 0x8000000,
+            0x80000017: 0x8000820,
+            0x80000018: 0x8020820,
+            0x80000019: 0x8000020,
+            0x8000001a: 0x8000800,
+            0x8000001b: 0x0,
+            0x8000001c: 0x20800,
+            0x8000001d: 0x820,
+            0x8000001e: 0x20020,
+            0x8000001f: 0x8020800
+        }
+    ];
+
+    // Masks that select the SBOX input
+    var SBOX_MASK = [
+        0xf8000001, 0x1f800000, 0x01f80000, 0x001f8000,
+        0x0001f800, 0x00001f80, 0x000001f8, 0x8000001f
+    ];
+
+    /**
+     * DES block cipher algorithm.
+     */
+    var DES = C_algo.DES = BlockCipher.extend({
+        _doReset: function () {
+            // Shortcuts
+            var key = this._key;
+            var keyWords = key.words;
+
+            // Select 56 bits according to PC1
+            var keyBits = [];
+            for (var i = 0; i < 56; i++) {
+                var keyBitPos = PC1[i] - 1;
+                keyBits[i] = (keyWords[keyBitPos >>> 5] >>> (31 - keyBitPos % 32)) & 1;
+            }
+
+            // Assemble 16 subkeys
+            var subKeys = this._subKeys = [];
+            for (var nSubKey = 0; nSubKey < 16; nSubKey++) {
+                // Create subkey
+                var subKey = subKeys[nSubKey] = [];
+
+                // Shortcut
+                var bitShift = BIT_SHIFTS[nSubKey];
+
+                // Select 48 bits according to PC2
+                for (var i = 0; i < 24; i++) {
+                    // Select from the left 28 key bits
+                    subKey[(i / 6) | 0] |= keyBits[((PC2[i] - 1) + bitShift) % 28] << (31 - i % 6);
+
+                    // Select from the right 28 key bits
+                    subKey[4 + ((i / 6) | 0)] |= keyBits[28 + (((PC2[i + 24] - 1) + bitShift) % 28)] << (31 - i % 6);
+                }
+
+                // Since each subkey is applied to an expanded 32-bit input,
+                // the subkey can be broken into 8 values scaled to 32-bits,
+                // which allows the key to be used without expansion
+                subKey[0] = (subKey[0] << 1) | (subKey[0] >>> 31);
+                for (var i = 1; i < 7; i++) {
+                    subKey[i] = subKey[i] >>> ((i - 1) * 4 + 3);
+                }
+                subKey[7] = (subKey[7] << 5) | (subKey[7] >>> 27);
+            }
+
+            // Compute inverse subkeys
+            var invSubKeys = this._invSubKeys = [];
+            for (var i = 0; i < 16; i++) {
+                invSubKeys[i] = subKeys[15 - i];
+            }
+        },
+
+        encryptBlock: function (M, offset) {
+            this._doCryptBlock(M, offset, this._subKeys);
+        },
+
+        decryptBlock: function (M, offset) {
+            this._doCryptBlock(M, offset, this._invSubKeys);
+        },
+
+        _doCryptBlock: function (M, offset, subKeys) {
+            // Get input
+            this._lBlock = M[offset];
+            this._rBlock = M[offset + 1];
+
+            // Initial permutation
+            exchangeLR.call(this, 4,  0x0f0f0f0f);
+            exchangeLR.call(this, 16, 0x0000ffff);
+            exchangeRL.call(this, 2,  0x33333333);
+            exchangeRL.call(this, 8,  0x00ff00ff);
+            exchangeLR.call(this, 1,  0x55555555);
+
+            // Rounds
+            for (var round = 0; round < 16; round++) {
+                // Shortcuts
+                var subKey = subKeys[round];
+                var lBlock = this._lBlock;
+                var rBlock = this._rBlock;
+
+                // Feistel function
+                var f = 0;
+                for (var i = 0; i < 8; i++) {
+                    f |= SBOX_P[i][((rBlock ^ subKey[i]) & SBOX_MASK[i]) >>> 0];
+                }
+                this._lBlock = rBlock;
+                this._rBlock = lBlock ^ f;
+            }
+
+            // Undo swap from last round
+            var t = this._lBlock;
+            this._lBlock = this._rBlock;
+            this._rBlock = t;
+
+            // Final permutation
+            exchangeLR.call(this, 1,  0x55555555);
+            exchangeRL.call(this, 8,  0x00ff00ff);
+            exchangeRL.call(this, 2,  0x33333333);
+            exchangeLR.call(this, 16, 0x0000ffff);
+            exchangeLR.call(this, 4,  0x0f0f0f0f);
+
+            // Set output
+            M[offset] = this._lBlock;
+            M[offset + 1] = this._rBlock;
+        },
+
+        keySize: 64/32,
+
+        ivSize: 64/32,
+
+        blockSize: 64/32
+    });
+
+    // Swap bits across the left and right words
+    function exchangeLR(offset, mask) {
+        var t = ((this._lBlock >>> offset) ^ this._rBlock) & mask;
+        this._rBlock ^= t;
+        this._lBlock ^= t << offset;
+    }
+
+    function exchangeRL(offset, mask) {
+        var t = ((this._rBlock >>> offset) ^ this._lBlock) & mask;
+        this._lBlock ^= t;
+        this._rBlock ^= t << offset;
+    }
+
+    /**
+     * Shortcut functions to the cipher's object interface.
+     *
+     * @example
+     *
+     *     var ciphertext = CryptoJS.DES.encrypt(message, key, cfg);
+     *     var plaintext  = CryptoJS.DES.decrypt(ciphertext, key, cfg);
+     */
+    C.DES = BlockCipher._createHelper(DES);
+
+    /**
+     * Triple-DES block cipher algorithm.
+     */
+    var TripleDES = C_algo.TripleDES = BlockCipher.extend({
+        _doReset: function () {
+            // Shortcuts
+            var key = this._key;
+            var keyWords = key.words;
+            // Make sure the key length is valid (64, 128 or >= 192 bit)
+            if (keyWords.length !== 2 && keyWords.length !== 4 && keyWords.length < 6) {
+                throw new Error('Invalid key length - 3DES requires the key length to be 64, 128, 192 or >192.');
+            }
+
+            // Extend the key according to the keying options defined in 3DES standard
+            var key1 = keyWords.slice(0, 2);
+            var key2 = keyWords.length < 4 ? keyWords.slice(0, 2) : keyWords.slice(2, 4);
+            var key3 = keyWords.length < 6 ? keyWords.slice(0, 2) : keyWords.slice(4, 6);
+
+            // Create DES instances
+            this._des1 = DES.createEncryptor(WordArray.create(key1));
+            this._des2 = DES.createEncryptor(WordArray.create(key2));
+            this._des3 = DES.createEncryptor(WordArray.create(key3));
+        },
+
+        encryptBlock: function (M, offset) {
+            this._des1.encryptBlock(M, offset);
+            this._des2.decryptBlock(M, offset);
+            this._des3.encryptBlock(M, offset);
+        },
+
+        decryptBlock: function (M, offset) {
+            this._des3.decryptBlock(M, offset);
+            this._des2.encryptBlock(M, offset);
+            this._des1.decryptBlock(M, offset);
+        },
+
+        keySize: 192/32,
+
+        ivSize: 64/32,
+
+        blockSize: 64/32
+    });
+
+    /**
+     * Shortcut functions to the cipher's object interface.
+     *
+     * @example
+     *
+     *     var ciphertext = CryptoJS.TripleDES.encrypt(message, key, cfg);
+     *     var plaintext  = CryptoJS.TripleDES.decrypt(ciphertext, key, cfg);
+     */
+    C.TripleDES = BlockCipher._createHelper(TripleDES);
+}());
diff --git a/src/x64-core.js b/src/x64-core.js
new file mode 100644
index 0000000..fabcf0e
--- /dev/null
+++ b/src/x64-core.js
@@ -0,0 +1,284 @@
+(function (undefined) {
+    // Shortcuts
+    var C = CryptoJS;
+    var C_lib = C.lib;
+    var Base = C_lib.Base;
+    var X32WordArray = C_lib.WordArray;
+
+    /**
+     * x64 namespace.
+     */
+    var C_x64 = C.x64 = {};
+
+    /**
+     * A 64-bit word.
+     */
+    var X64Word = C_x64.Word = Base.extend({
+        /**
+         * Initializes a newly created 64-bit word.
+         *
+         * @param {number} high The high 32 bits.
+         * @param {number} low The low 32 bits.
+         *
+         * @example
+         *
+         *     var x64Word = CryptoJS.x64.Word.create(0x00010203, 0x04050607);
+         */
+        init: function (high, low) {
+            this.high = high;
+            this.low = low;
+        }
+
+        /**
+         * Bitwise NOTs this word.
+         *
+         * @return {X64Word} A new x64-Word object after negating.
+         *
+         * @example
+         *
+         *     var negated = x64Word.not();
+         */
+        // not: function () {
+            // var high = ~this.high;
+            // var low = ~this.low;
+
+            // return X64Word.create(high, low);
+        // },
+
+        /**
+         * Bitwise ANDs this word with the passed word.
+         *
+         * @param {X64Word} word The x64-Word to AND with this word.
+         *
+         * @return {X64Word} A new x64-Word object after ANDing.
+         *
+         * @example
+         *
+         *     var anded = x64Word.and(anotherX64Word);
+         */
+        // and: function (word) {
+            // var high = this.high & word.high;
+            // var low = this.low & word.low;
+
+            // return X64Word.create(high, low);
+        // },
+
+        /**
+         * Bitwise ORs this word with the passed word.
+         *
+         * @param {X64Word} word The x64-Word to OR with this word.
+         *
+         * @return {X64Word} A new x64-Word object after ORing.
+         *
+         * @example
+         *
+         *     var ored = x64Word.or(anotherX64Word);
+         */
+        // or: function (word) {
+            // var high = this.high | word.high;
+            // var low = this.low | word.low;
+
+            // return X64Word.create(high, low);
+        // },
+
+        /**
+         * Bitwise XORs this word with the passed word.
+         *
+         * @param {X64Word} word The x64-Word to XOR with this word.
+         *
+         * @return {X64Word} A new x64-Word object after XORing.
+         *
+         * @example
+         *
+         *     var xored = x64Word.xor(anotherX64Word);
+         */
+        // xor: function (word) {
+            // var high = this.high ^ word.high;
+            // var low = this.low ^ word.low;
+
+            // return X64Word.create(high, low);
+        // },
+
+        /**
+         * Shifts this word n bits to the left.
+         *
+         * @param {number} n The number of bits to shift.
+         *
+         * @return {X64Word} A new x64-Word object after shifting.
+         *
+         * @example
+         *
+         *     var shifted = x64Word.shiftL(25);
+         */
+        // shiftL: function (n) {
+            // if (n < 32) {
+                // var high = (this.high << n) | (this.low >>> (32 - n));
+                // var low = this.low << n;
+            // } else {
+                // var high = this.low << (n - 32);
+                // var low = 0;
+            // }
+
+            // return X64Word.create(high, low);
+        // },
+
+        /**
+         * Shifts this word n bits to the right.
+         *
+         * @param {number} n The number of bits to shift.
+         *
+         * @return {X64Word} A new x64-Word object after shifting.
+         *
+         * @example
+         *
+         *     var shifted = x64Word.shiftR(7);
+         */
+        // shiftR: function (n) {
+            // if (n < 32) {
+                // var low = (this.low >>> n) | (this.high << (32 - n));
+                // var high = this.high >>> n;
+            // } else {
+                // var low = this.high >>> (n - 32);
+                // var high = 0;
+            // }
+
+            // return X64Word.create(high, low);
+        // },
+
+        /**
+         * Rotates this word n bits to the left.
+         *
+         * @param {number} n The number of bits to rotate.
+         *
+         * @return {X64Word} A new x64-Word object after rotating.
+         *
+         * @example
+         *
+         *     var rotated = x64Word.rotL(25);
+         */
+        // rotL: function (n) {
+            // return this.shiftL(n).or(this.shiftR(64 - n));
+        // },
+
+        /**
+         * Rotates this word n bits to the right.
+         *
+         * @param {number} n The number of bits to rotate.
+         *
+         * @return {X64Word} A new x64-Word object after rotating.
+         *
+         * @example
+         *
+         *     var rotated = x64Word.rotR(7);
+         */
+        // rotR: function (n) {
+            // return this.shiftR(n).or(this.shiftL(64 - n));
+        // },
+
+        /**
+         * Adds this word with the passed word.
+         *
+         * @param {X64Word} word The x64-Word to add with this word.
+         *
+         * @return {X64Word} A new x64-Word object after adding.
+         *
+         * @example
+         *
+         *     var added = x64Word.add(anotherX64Word);
+         */
+        // add: function (word) {
+            // var low = (this.low + word.low) | 0;
+            // var carry = (low >>> 0) < (this.low >>> 0) ? 1 : 0;
+            // var high = (this.high + word.high + carry) | 0;
+
+            // return X64Word.create(high, low);
+        // }
+    });
+
+    /**
+     * An array of 64-bit words.
+     *
+     * @property {Array} words The array of CryptoJS.x64.Word objects.
+     * @property {number} sigBytes The number of significant bytes in this word array.
+     */
+    var X64WordArray = C_x64.WordArray = Base.extend({
+        /**
+         * Initializes a newly created word array.
+         *
+         * @param {Array} words (Optional) An array of CryptoJS.x64.Word objects.
+         * @param {number} sigBytes (Optional) The number of significant bytes in the words.
+         *
+         * @example
+         *
+         *     var wordArray = CryptoJS.x64.WordArray.create();
+         *
+         *     var wordArray = CryptoJS.x64.WordArray.create([
+         *         CryptoJS.x64.Word.create(0x00010203, 0x04050607),
+         *         CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f)
+         *     ]);
+         *
+         *     var wordArray = CryptoJS.x64.WordArray.create([
+         *         CryptoJS.x64.Word.create(0x00010203, 0x04050607),
+         *         CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f)
+         *     ], 10);
+         */
+        init: function (words, sigBytes) {
+            words = this.words = words || [];
+
+            if (sigBytes != undefined) {
+                this.sigBytes = sigBytes;
+            } else {
+                this.sigBytes = words.length * 8;
+            }
+        },
+
+        /**
+         * Converts this 64-bit word array to a 32-bit word array.
+         *
+         * @return {CryptoJS.lib.WordArray} This word array's data as a 32-bit word array.
+         *
+         * @example
+         *
+         *     var x32WordArray = x64WordArray.toX32();
+         */
+        toX32: function () {
+            // Shortcuts
+            var x64Words = this.words;
+            var x64WordsLength = x64Words.length;
+
+            // Convert
+            var x32Words = [];
+            for (var i = 0; i < x64WordsLength; i++) {
+                var x64Word = x64Words[i];
+                x32Words.push(x64Word.high);
+                x32Words.push(x64Word.low);
+            }
+
+            return X32WordArray.create(x32Words, this.sigBytes);
+        },
+
+        /**
+         * Creates a copy of this word array.
+         *
+         * @return {X64WordArray} The clone.
+         *
+         * @example
+         *
+         *     var clone = x64WordArray.clone();
+         */
+        clone: function () {
+            var clone = Base.clone.call(this);
+
+            // Clone "words" array
+            var words = clone.words = this.words.slice(0);
+
+            // Clone each X64Word object
+            var wordsLength = words.length;
+            for (var i = 0; i < wordsLength; i++) {
+                words[i] = words[i].clone();
+            }
+
+            return clone;
+        }
+    });
+}());
diff --git a/test/aes-profile.js b/test/aes-profile.js
new file mode 100644
index 0000000..b13d2a9
--- /dev/null
+++ b/test/aes-profile.js
@@ -0,0 +1,31 @@
+YUI.add('algo-aes-profile', function (Y) {
+    var C = CryptoJS;
+
+    Y.Profiler.add({
+        name: 'AES',
+
+        setUp: function () {
+            this.data = {
+                key: C.enc.Hex.parse('000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f'),
+                iv: C.enc.Hex.parse('000102030405060708090a0b0c0d0e0f')
+            };
+        },
+
+        profileSinglePartMessage: function () {
+            var singlePartMessage = '';
+            for (var i = 0; i < 500; i++) {
+                singlePartMessage += '12345678901234567890123456789012345678901234567890';
+            }
+
+            C.algo.AES.createEncryptor(this.data.key, { iv: this.data.iv }).finalize(singlePartMessage) + '';
+        },
+
+        profileMultiPartMessage: function () {
+            var aes = C.algo.AES.createEncryptor(this.data.key, { iv: this.data.iv });
+            for (var i = 0; i < 500; i++) {
+                aes.process('12345678901234567890123456789012345678901234567890') + '';
+            }
+            aes.finalize() + '';
+        }
+    });
+}, '$Rev$');
diff --git a/test/aes-test.js b/test/aes-test.js
new file mode 100644
index 0000000..ca589dd
--- /dev/null
+++ b/test/aes-test.js
@@ -0,0 +1,80 @@
+YUI.add('algo-aes-test', function (Y) {
+    var C = CryptoJS;
+
+    Y.Test.Runner.add(new Y.Test.Case({
+        name: 'AES',
+
+        testEncryptKeySize128: function () {
+            Y.Assert.areEqual('69c4e0d86a7b0430d8cdb78070b4c55a', C.AES.encrypt(C.enc.Hex.parse('00112233445566778899aabbccddeeff'), C.enc.Hex.parse('000102030405060708090a0b0c0d0e0f'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).ciphertext.toString());
+        },
+
+        testEncryptKeySize192: function () {
+            Y.Assert.areEqual('dda97ca4864cdfe06eaf70a0ec0d7191', C.AES.encrypt(C.enc.Hex.parse('00112233445566778899aabbccddeeff'), C.enc.Hex.parse('000102030405060708090a0b0c0d0e0f1011121314151617'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).ciphertext.toString());
+        },
+
+        testEncryptKeySize256: function () {
+            Y.Assert.areEqual('8ea2b7ca516745bfeafc49904b496089', C.AES.encrypt(C.enc.Hex.parse('00112233445566778899aabbccddeeff'), C.enc.Hex.parse('000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).ciphertext.toString());
+        },
+
+        testDecryptKeySize128: function () {
+            Y.Assert.areEqual('00112233445566778899aabbccddeeff', C.AES.decrypt(C.lib.CipherParams.create({ ciphertext: C.enc.Hex.parse('69c4e0d86a7b0430d8cdb78070b4c55a') }), C.enc.Hex.parse('000102030405060708090a0b0c0d0e0f'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString());
+        },
+
+        testDecryptKeySize192: function () {
+            Y.Assert.areEqual('00112233445566778899aabbccddeeff', C.AES.decrypt(C.lib.CipherParams.create({ ciphertext: C.enc.Hex.parse('dda97ca4864cdfe06eaf70a0ec0d7191') }), C.enc.Hex.parse('000102030405060708090a0b0c0d0e0f1011121314151617'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString());
+        },
+
+        testDecryptKeySize256: function () {
+            Y.Assert.areEqual('00112233445566778899aabbccddeeff', C.AES.decrypt(C.lib.CipherParams.create({ ciphertext: C.enc.Hex.parse('8ea2b7ca516745bfeafc49904b496089') }), C.enc.Hex.parse('000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString());
+        },
+
+        testMultiPart: function () {
+            var aes = C.algo.AES.createEncryptor(C.enc.Hex.parse('000102030405060708090a0b0c0d0e0f'), { mode: C.mode.ECB, padding: C.pad.NoPadding });
+            var ciphertext1 = aes.process(C.enc.Hex.parse('001122334455'));
+            var ciphertext2 = aes.process(C.enc.Hex.parse('66778899aa'));
+            var ciphertext3 = aes.process(C.enc.Hex.parse('bbccddeeff'));
+            var ciphertext4 = aes.finalize();
+
+            Y.Assert.areEqual('69c4e0d86a7b0430d8cdb78070b4c55a', ciphertext1.concat(ciphertext2).concat(ciphertext3).concat(ciphertext4).toString());
+        },
+
+        testInputIntegrity: function () {
+            var message = C.enc.Hex.parse('00112233445566778899aabbccddeeff');
+            var key = C.enc.Hex.parse('000102030405060708090a0b0c0d0e0f');
+            var iv = C.enc.Hex.parse('101112131415161718191a1b1c1d1e1f');
+
+            var expectedMessage = message.toString();
+            var expectedKey = key.toString();
+            var expectedIv = iv.toString();
+
+            C.AES.encrypt(message, key, { iv: iv });
+
+            Y.Assert.areEqual(expectedMessage, message.toString());
+            Y.Assert.areEqual(expectedKey, key.toString());
+            Y.Assert.areEqual(expectedIv, iv.toString());
+        },
+
+        testHelper: function () {
+            // Save original random method
+            var random = C.lib.WordArray.random;
+
+            // Replace random method with one that returns a predictable value
+            C.lib.WordArray.random = function (nBytes) {
+                var words = [];
+                for (var i = 0; i < nBytes; i += 4) {
+                    words.push([0x11223344]);
+                }
+
+                return C.lib.WordArray.create(words, nBytes);
+            };
+
+            // Test
+            Y.Assert.areEqual(C.algo.AES.createEncryptor(C.SHA256('Jefe'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).finalize('Hi There').toString(), C.AES.encrypt('Hi There', C.SHA256('Jefe'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).ciphertext.toString());
+            Y.Assert.areEqual(C.lib.SerializableCipher.encrypt(C.algo.AES, 'Hi There', C.SHA256('Jefe'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString(), C.AES.encrypt('Hi There', C.SHA256('Jefe'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString());
+            Y.Assert.areEqual(C.lib.PasswordBasedCipher.encrypt(C.algo.AES, 'Hi There', 'Jefe', { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString(), C.AES.encrypt('Hi There', 'Jefe', { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString());
+
+            // Restore random method
+            C.lib.WordArray.random = random;
+        }
+    }));
+}, '$Rev$');
diff --git a/test/blowfish-test.js b/test/blowfish-test.js
new file mode 100644
index 0000000..607354a
--- /dev/null
+++ b/test/blowfish-test.js
@@ -0,0 +1,33 @@
+YUI.add('algo-aes-test', function (Y) {
+    var C = CryptoJS;
+
+    Y.Test.Runner.add(new Y.Test.Case({
+        name: 'Blowfish',
+
+        setUp: function () {
+            this.data = {
+                saltA: CryptoJS.enc.Hex.parse('AA00000000000000')
+            };
+        },
+
+        testEncrypt: function () {
+            let encryptedA = C.Blowfish.encrypt('Test',
+            'pass',
+            {
+                salt: this.data.saltA,
+                hasher: CryptoJS.algo.SHA256
+            }).toString();
+            Y.Assert.areEqual('U2FsdGVkX1+qAAAAAAAAAKTIU8MPrBdH', encryptedA);
+        },
+
+        testDecrypt: function () {
+            let encryptedA = C.Blowfish.encrypt('Test',
+            'pass',
+            {
+                salt: this.data.saltA,
+                hasher: CryptoJS.algo.SHA256
+            }).toString();
+            Y.Assert.areEqual('Test', C.Blowfish.decrypt(encryptedA, 'pass', {hasher: CryptoJS.algo.SHA256}).toString(C.enc.Utf8));
+        }
+    }));
+}, '$Rev$');
diff --git a/test/cipher-test.js b/test/cipher-test.js
new file mode 100644
index 0000000..2529eff
--- /dev/null
+++ b/test/cipher-test.js
@@ -0,0 +1,522 @@
+function extendWithCMAC(C) {
+    function createExt(C) {
+        /*
+         * The MIT License (MIT)
+         *
+         * Copyright (c) 2015 artjomb
+         */
+        // put on ext property in CryptoJS
+        var ext;
+        if (!C.hasOwnProperty("ext")) {
+            ext = C.ext = {};
+        } else {
+            ext = C.ext;
+        }
+
+        // Shortcuts
+        var Base = C.lib.Base;
+        var WordArray = C.lib.WordArray;
+
+        // Constants
+        ext.const_Zero = new WordArray.init([0x00000000, 0x00000000, 0x00000000, 0x00000000]);
+        ext.const_One = new WordArray.init([0x00000000, 0x00000000, 0x00000000, 0x00000001]);
+        ext.const_Rb = new WordArray.init([0x00000000, 0x00000000, 0x00000000, 0x00000087]); // 00..0010000111
+        ext.const_Rb_Shifted = new WordArray.init([0x80000000, 0x00000000, 0x00000000, 0x00000043]); // 100..001000011
+        ext.const_nonMSB = new WordArray.init([0xFFFFFFFF, 0xFFFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF]); // 1^64 || 0^1 || 1^31 || 0^1 || 1^31
+
+        /**
+         * Looks into the object to see if it is a WordArray.
+         *
+         * @param obj Some object
+         *
+         * @returns {boolean}
+         */
+        ext.isWordArray = function(obj) {
+            return obj && typeof obj.clamp === "function" && typeof obj.concat === "function" && typeof obj.words === "array";
+        }
+
+        /**
+         * This padding is a 1 bit followed by as many 0 bits as needed to fill
+         * up the block. This implementation doesn't work on bits directly,
+         * but on bytes. Therefore the granularity is much bigger.
+         */
+        C.pad.OneZeroPadding = {
+            pad: function (data, blocksize) {
+                // Shortcut
+                var blockSizeBytes = blocksize * 4;
+
+                // Count padding bytes
+                var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes;
+
+                // Create padding
+                var paddingWords = [];
+                for (var i = 0; i < nPaddingBytes; i += 4) {
+                    var paddingWord = 0x00000000;
+                    if (i === 0) {
+                        paddingWord = 0x80000000;
+                    }
+                    paddingWords.push(paddingWord);
+                }
+                var padding = new WordArray.init(paddingWords, nPaddingBytes);
+
+                // Add padding
+                data.concat(padding);
+            },
+            unpad: function () {
+                // TODO: implement
+            }
+        };
+
+        /**
+         * No padding is applied. This is necessary for streaming cipher modes
+         * like CTR.
+         */
+        C.pad.NoPadding = {
+            pad: function () {},
+            unpad: function () {}
+        };
+
+        /**
+         * Returns the n leftmost bytes of the WordArray.
+         *
+         * @param {WordArray} wordArray WordArray to work on
+         * @param {int} n Bytes to retrieve
+         *
+         * @returns new WordArray
+         */
+        ext.leftmostBytes = function(wordArray, n){
+            var lmArray = wordArray.clone();
+            lmArray.sigBytes = n;
+            lmArray.clamp();
+            return lmArray;
+        };
+
+        /**
+         * Returns the n rightmost bytes of the WordArray.
+         *
+         * @param {WordArray} wordArray WordArray to work on
+         * @param {int} n Bytes to retrieve (must be positive)
+         *
+         * @returns new WordArray
+         */
+        ext.rightmostBytes = function(wordArray, n){
+            wordArray.clamp();
+            var wordSize = 32;
+            var rmArray = wordArray.clone();
+            var bitsToShift = (rmArray.sigBytes - n) * 8;
+            if (bitsToShift >= wordSize) {
+                var popCount = Math.floor(bitsToShift/wordSize);
+                bitsToShift -= popCount * wordSize;
+                rmArray.words.splice(0, popCount);
+                rmArray.sigBytes -= popCount * wordSize / 8;
+            }
+            if (bitsToShift > 0) {
+                ext.bitshift(rmArray, bitsToShift);
+                rmArray.sigBytes -= bitsToShift / 8;
+            }
+            return rmArray;
+        };
+
+        /**
+         * Returns the n rightmost words of the WordArray. It assumes
+         * that the current WordArray has at least n words.
+         *
+         * @param {WordArray} wordArray WordArray to work on
+         * @param {int} n Words to retrieve (must be positive)
+         *
+         * @returns popped words as new WordArray
+         */
+        ext.popWords = function(wordArray, n){
+            var left = wordArray.words.splice(0, n);
+            wordArray.sigBytes -= n * 4;
+            return new WordArray.init(left);
+        };
+
+        /**
+         * Shifts the array to the left and returns the shifted dropped elements
+         * as WordArray. The initial WordArray must contain at least n bytes and
+         * they have to be significant.
+         *
+         * @param {WordArray} wordArray WordArray to work on (is modified)
+         * @param {int} n Bytes to shift (must be positive, default 16)
+         *
+         * @returns new WordArray
+         */
+        ext.shiftBytes = function(wordArray, n){
+            n = n || 16;
+            var r = n % 4;
+            n -= r;
+
+            var shiftedArray = new WordArray.init();
+            for(var i = 0; i < n; i += 4) {
+                shiftedArray.words.push(wordArray.words.shift());
+                wordArray.sigBytes -= 4;
+                shiftedArray.sigBytes += 4;
+            }
+            if (r > 0) {
+                shiftedArray.words.push(wordArray.words[0]);
+                shiftedArray.sigBytes += r;
+
+                ext.bitshift(wordArray, r * 8);
+                wordArray.sigBytes -= r;
+            }
+            return shiftedArray;
+        };
+
+        /**
+         * XORs arr2 to the end of arr1 array. This doesn't modify the current
+         * array aside from clamping.
+         *
+         * @param {WordArray} arr1 Bigger array
+         * @param {WordArray} arr2 Smaller array to be XORed to the end
+         *
+         * @returns new WordArray
+         */
+        ext.xorendBytes = function(arr1, arr2){
+            // TODO: more efficient
+            return ext.leftmostBytes(arr1, arr1.sigBytes-arr2.sigBytes)
+                    .concat(ext.xor(ext.rightmostBytes(arr1, arr2.sigBytes), arr2));
+        };
+
+        /**
+         * Doubling operation on a 128-bit value. This operation modifies the
+         * passed array.
+         *
+         * @param {WordArray} wordArray WordArray to work on
+         *
+         * @returns passed WordArray
+         */
+        ext.dbl = function(wordArray){
+            var carry = ext.msb(wordArray);
+            ext.bitshift(wordArray, 1);
+            ext.xor(wordArray, carry === 1 ? ext.const_Rb : ext.const_Zero);
+            return wordArray;
+        };
+
+        /**
+         * Inverse operation on a 128-bit value. This operation modifies the
+         * passed array.
+         *
+         * @param {WordArray} wordArray WordArray to work on
+         *
+         * @returns passed WordArray
+         */
+        ext.inv = function(wordArray){
+            var carry = wordArray.words[4] & 1;
+            ext.bitshift(wordArray, -1);
+            ext.xor(wordArray, carry === 1 ? ext.const_Rb_Shifted : ext.const_Zero);
+            return wordArray;
+        };
+
+        /**
+         * Check whether the word arrays are equal.
+         *
+         * @param {WordArray} arr1 Array 1
+         * @param {WordArray} arr2 Array 2
+         *
+         * @returns boolean
+         */
+        ext.equals = function(arr1, arr2){
+            if (!arr2 || !arr2.words || arr1.sigBytes !== arr2.sigBytes) {
+                return false;
+            }
+            arr1.clamp();
+            arr2.clamp();
+            var equal = 0;
+            for(var i = 0; i < arr1.words.length; i++) {
+                equal |= arr1.words[i] ^ arr2.words[i];
+            }
+            return equal === 0;
+        };
+
+        /**
+         * Retrieves the most significant bit of the WordArray as an Integer.
+         *
+         * @param {WordArray} arr
+         *
+         * @returns Integer
+         */
+        ext.msb = function(arr) {
+            return arr.words[0] >>> 31;
+        }
+    }
+
+    function createExtBit(C) {
+        /*
+         * The MIT License (MIT)
+         *
+         * Copyright (c) 2015 artjomb
+         */
+        // put on ext property in CryptoJS
+        var ext;
+        if (!C.hasOwnProperty("ext")) {
+            ext = C.ext = {};
+        } else {
+            ext = C.ext;
+        }
+
+        /**
+         * Shifts the array by n bits to the left. Zero bits are added as the
+         * least significant bits. This operation modifies the current array.
+         *
+         * @param {WordArray} wordArray WordArray to work on
+         * @param {int} n Bits to shift by
+         *
+         * @returns the WordArray that was passed in
+         */
+        ext.bitshift = function(wordArray, n){
+            var carry = 0,
+                words = wordArray.words,
+                wres,
+                skipped = 0,
+                carryMask;
+            if (n > 0) {
+                while(n > 31) {
+                    // delete first element:
+                    words.splice(0, 1);
+
+                    // add `0` word to the back
+                    words.push(0);
+
+                    n -= 32;
+                    skipped++;
+                }
+                if (n == 0) {
+                    // 1. nothing to shift if the shift amount is on a word boundary
+                    // 2. This has to be done, because the following algorithm computes
+                    // wrong values only for n==0
+                    return carry;
+                }
+                for(var i = words.length - skipped - 1; i >= 0; i--) {
+                    wres = words[i];
+                    words[i] <<= n;
+                    words[i] |= carry;
+                    carry = wres >>> (32 - n);
+                }
+            } else if (n < 0) {
+                while(n < -31) {
+                    // insert `0` word to the front:
+                    words.splice(0, 0, 0);
+
+                    // remove last element:
+                    words.length--;
+
+                    n += 32;
+                    skipped++;
+                }
+                if (n == 0) {
+                    // nothing to shift if the shift amount is on a word boundary
+                    return carry;
+                }
+                n = -n;
+                carryMask = (1 << n) - 1;
+                for(var i = skipped; i < words.length; i++) {
+                    wres = words[i] & carryMask;
+                    words[i] >>>= n;
+                    words[i] |= carry;
+                    carry = wres << (32 - n);
+                }
+            }
+            return carry;
+        };
+
+        /**
+         * Negates all bits in the WordArray. This manipulates the given array.
+         *
+         * @param {WordArray} wordArray WordArray to work on
+         *
+         * @returns the WordArray that was passed in
+         */
+        ext.neg = function(wordArray){
+            var words = wordArray.words;
+            for(var i = 0; i < words.length; i++) {
+                words[i] = ~words[i];
+            }
+            return wordArray;
+        };
+
+        /**
+         * Applies XOR on both given word arrays and returns a third resulting
+         * WordArray. The initial word arrays must have the same length
+         * (significant bytes).
+         *
+         * @param {WordArray} wordArray1 WordArray
+         * @param {WordArray} wordArray2 WordArray
+         *
+         * @returns first passed WordArray (modified)
+         */
+        ext.xor = function(wordArray1, wordArray2){
+            for(var i = 0; i < wordArray1.words.length; i++) {
+                wordArray1.words[i] ^= wordArray2.words[i];
+            }
+            return wordArray1;
+        };
+
+        /**
+         * Logical AND between the two passed arrays. Both arrays must have the
+         * same length.
+         *
+         * @param {WordArray} arr1 Array 1
+         * @param {WordArray} arr2 Array 2
+         *
+         * @returns new WordArray
+         */
+        ext.bitand = function(arr1, arr2){
+            var newArr = arr1.clone(),
+                tw = newArr.words,
+                ow = arr2.words;
+            for(var i = 0; i < tw.length; i++) {
+                tw[i] &= ow[i];
+            }
+            return newArr;
+        };
+    }
+
+    function createCMAC(C) {
+        /*
+         * The MIT License (MIT)
+         *
+         * Copyright (c) 2015 artjomb
+         */
+        // Shortcuts
+        var Base = C.lib.Base;
+        var WordArray = C.lib.WordArray;
+        var AES = C.algo.AES;
+        var ext = C.ext;
+        var OneZeroPadding = C.pad.OneZeroPadding;
+
+        var CMAC = C.algo.CMAC = Base.extend({
+            /**
+             * Initializes a newly created CMAC
+             *
+             * @param {WordArray} key The secret key
+             *
+             * @example
+             *
+             *     var cmacer = CryptoJS.algo.CMAC.create(key);
+             */
+            init: function(key){
+                // generate sub keys...
+                this._aes = AES.createEncryptor(key, { iv: new WordArray.init(), padding: C.pad.NoPadding });
+
+                // Step 1
+                var L = this._aes.finalize(ext.const_Zero);
+
+                // Step 2
+                var K1 = L.clone();
+                ext.dbl(K1);
+
+                // Step 3
+                if (!this._isTwo) {
+                    var K2 = K1.clone();
+                    ext.dbl(K2);
+                } else {
+                    var K2 = L.clone();
+                    ext.inv(K2);
+                }
+
+                this._K1 = K1;
+                this._K2 = K2;
+
+                this._const_Bsize = 16;
+
+                this.reset();
+            },
+
+            reset: function () {
+                this._x = ext.const_Zero.clone();
+                this._counter = 0;
+                this._buffer = new WordArray.init();
+            },
+
+            update: function (messageUpdate) {
+                if (!messageUpdate) {
+                    return this;
+                }
+
+                // Shortcuts
+                var buffer = this._buffer;
+                var bsize = this._const_Bsize;
+
+                if (typeof messageUpdate === "string") {
+                    messageUpdate = C.enc.Utf8.parse(messageUpdate);
+                }
+
+                buffer.concat(messageUpdate);
+
+                while(buffer.sigBytes > bsize){
+                    var M_i = ext.shiftBytes(buffer, bsize);
+                    ext.xor(this._x, M_i);
+                    this._x.clamp();
+                    this._aes.reset();
+                    this._x = this._aes.finalize(this._x);
+                    this._counter++;
+                }
+
+                // Chainable
+                return this;
+            },
+
+            finalize: function (messageUpdate) {
+                this.update(messageUpdate);
+
+                // Shortcuts
+                var buffer = this._buffer;
+                var bsize = this._const_Bsize;
+
+                var M_last = buffer.clone();
+                if (buffer.sigBytes === bsize) {
+                    ext.xor(M_last, this._K1);
+                } else {
+                    OneZeroPadding.pad(M_last, bsize/4);
+                    ext.xor(M_last, this._K2);
+                }
+
+                ext.xor(M_last, this._x);
+
+                this.reset(); // Can be used immediately afterwards
+
+                this._aes.reset();
+                return this._aes.finalize(M_last);
+            },
+
+            _isTwo: false
+        });
+
+        /**
+         * Directly invokes the CMAC and returns the calculated MAC.
+         *
+         * @param {WordArray} key The key to be used for CMAC
+         * @param {WordArray|string} message The data to be MAC'ed (either WordArray or UTF-8 encoded string)
+         *
+         * @returns {WordArray} MAC
+         */
+        C.CMAC = function(key, message){
+            return CMAC.create(key).finalize(message);
+        };
+
+        C.algo.OMAC1 = CMAC;
+        C.algo.OMAC2 = CMAC.extend({
+            _isTwo: true
+        });
+    }
+
+    createExt(C);
+    createExtBit(C);
+    createCMAC(C);
+}
+
+YUI.add('cipher-core-test', function (Y) {
+    var C = CryptoJS;
+
+    // Extend with CMAC to test `cipher-core.js` L:457-462
+    extendWithCMAC(C);
+
+    Y.Test.Runner.add(new Y.Test.Case({
+        name: 'Cipher',
+
+        testCMAC: function () {
+            Y.Assert.areEqual('35e1872b95ce5d99bb5dbbbbd79b9b9b', C.CMAC('69c4e0d86a7b0430d8cdb78070b4c55a', 'Test message').toString());
+        }
+    }));
+}, '$Rev$');
diff --git a/test/config-test.js b/test/config-test.js
new file mode 100644
index 0000000..c09e425
--- /dev/null
+++ b/test/config-test.js
@@ -0,0 +1,51 @@
+YUI.add('config-test', function (Y) {
+    var C = CryptoJS;
+
+    Y.Test.Runner.add(new Y.Test.Case({
+        name: 'Config',
+
+        setUp: function () {
+            this.data = {
+                saltA: CryptoJS.enc.Hex.parse('AA00000000000000'),
+                saltB: CryptoJS.enc.Hex.parse('BB00000000000000')
+            };
+        },
+
+        testEncrypt: function () {
+            Y.Assert.areEqual(C.AES.encrypt('Test', 'Pass', { salt: this.data.saltA }).toString(), C.AES.encrypt('Test', 'Pass', { salt: this.data.saltA }).toString());
+            Y.Assert.areNotEqual(C.AES.encrypt('Test', 'Pass', { salt: this.data.saltA }).toString(), C.AES.encrypt('Test', 'Pass', { salt: this.data.saltB }).toString());
+        },
+
+        testDecrypt: function () {
+            var encryptedA = C.AES.encrypt('Test', 'Pass', { salt: this.data.saltA });
+            var encryptedB = C.AES.encrypt('Test', 'Pass', { salt: this.data.saltB });
+            Y.Assert.areEqual('Test', C.AES.decrypt(encryptedA, 'Pass').toString(C.enc.Utf8));
+            Y.Assert.areEqual('Test', C.AES.decrypt(encryptedB, 'Pass').toString(C.enc.Utf8));
+        },
+
+        testCustomKDFHasher: function () {
+            //SHA1
+            let encryptedSHA1 = C.AES.encrypt('Test', 'Pass', { salt: this.data.saltA, hasher: C.algo.SHA1}).toString();
+            Y.Assert.areEqual('Test', C.AES.decrypt(encryptedSHA1, 'Pass', { hasher: C.algo.SHA1}).toString(C.enc.Utf8));
+
+            //SHA256
+            let encryptedSHA256 = C.AES.encrypt('Test', 'Pass', { salt: this.data.saltA, hasher: C.algo.SHA256}).toString();
+            Y.Assert.areEqual('Test', C.AES.decrypt(encryptedSHA256, 'Pass', { hasher: C.algo.SHA256}).toString(C.enc.Utf8));
+
+            //SHA512
+            let encryptedSHA512 = C.AES.encrypt('Test', 'Pass', { salt: this.data.saltA, hasher: C.algo.SHA512}).toString();
+            Y.Assert.areEqual('Test', C.AES.decrypt(encryptedSHA512, 'Pass', { hasher: C.algo.SHA512}).toString(C.enc.Utf8));
+
+            //Default: MD5
+            let encryptedDefault = C.AES.encrypt('Test', 'Pass', { salt: this.data.saltA }).toString();
+            let encryptedMD5 = C.AES.encrypt('Test', 'Pass', { salt: this.data.saltA, hasher: C.algo.MD5}).toString();
+            Y.Assert.areEqual('Test', C.AES.decrypt(encryptedMD5, 'Pass', { hasher: C.algo.MD5}).toString(C.enc.Utf8));
+            Y.Assert.areEqual(encryptedDefault, encryptedMD5);
+
+            //Different KDFHasher
+            Y.Assert.areNotEqual(encryptedDefault, encryptedSHA1);
+            Y.Assert.areNotEqual(encryptedDefault, encryptedSHA256);
+            Y.Assert.areNotEqual(encryptedDefault, encryptedSHA512);
+        }
+    }));
+}, '$Rev$');
\ No newline at end of file
diff --git a/test/des-profile.js b/test/des-profile.js
new file mode 100644
index 0000000..37a27e8
--- /dev/null
+++ b/test/des-profile.js
@@ -0,0 +1,31 @@
+YUI.add('algo-des-profile', function (Y) {
+    var C = CryptoJS;
+
+    Y.Profiler.add({
+        name: 'DES',
+
+        setUp: function () {
+            this.data = {
+                key: C.enc.Hex.parse('0001020304050607'),
+                iv: C.enc.Hex.parse('08090a0b0c0d0e0f')
+            };
+        },
+
+        profileSinglePartMessage: function () {
+            var singlePartMessage = '';
+            for (var i = 0; i < 100; i++) {
+                singlePartMessage += '12345678901234567890123456789012345678901234567890';
+            }
+
+            C.algo.DES.createEncryptor(this.data.key, { iv: this.data.iv }).finalize(singlePartMessage) + '';
+        },
+
+        profileMultiPartMessage: function () {
+            var des = C.algo.DES.createEncryptor(this.data.key, { iv: this.data.iv });
+            for (var i = 0; i < 100; i++) {
+                des.process('12345678901234567890123456789012345678901234567890') + '';
+            }
+            des.finalize() + '';
+        }
+    });
+}, '$Rev$');
diff --git a/test/des-test.js b/test/des-test.js
new file mode 100644
index 0000000..6580a3e
--- /dev/null
+++ b/test/des-test.js
@@ -0,0 +1,104 @@
+YUI.add('algo-des-test', function (Y) {
+    var C = CryptoJS;
+
+    Y.Test.Runner.add(new Y.Test.Case({
+        name: 'DES',
+
+        testEncrypt1: function () {
+            Y.Assert.areEqual('95a8d72813daa94d', C.DES.encrypt(C.enc.Hex.parse('0000000000000000'), C.enc.Hex.parse('8000000000000000'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).ciphertext.toString());
+        },
+
+        testEncrypt2: function () {
+            Y.Assert.areEqual('1de5279dae3bed6f', C.DES.encrypt(C.enc.Hex.parse('0000000000000000'), C.enc.Hex.parse('0000000000002000'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).ciphertext.toString());
+        },
+
+        testEncrypt3: function () {
+            Y.Assert.areEqual('1d1ca853ae7c0c5f', C.DES.encrypt(C.enc.Hex.parse('0000000000002000'), C.enc.Hex.parse('0000000000000000'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).ciphertext.toString());
+        },
+
+        testEncrypt4: function () {
+            Y.Assert.areEqual('ac978c247863388f', C.DES.encrypt(C.enc.Hex.parse('3232323232323232'), C.enc.Hex.parse('3232323232323232'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).ciphertext.toString());
+        },
+
+        testEncrypt5: function () {
+            Y.Assert.areEqual('3af1703d76442789', C.DES.encrypt(C.enc.Hex.parse('6464646464646464'), C.enc.Hex.parse('6464646464646464'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).ciphertext.toString());
+        },
+
+        testEncrypt6: function () {
+            Y.Assert.areEqual('a020003c5554f34c', C.DES.encrypt(C.enc.Hex.parse('9696969696969696'), C.enc.Hex.parse('9696969696969696'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).ciphertext.toString());
+        },
+
+        testDecrypt1: function () {
+            Y.Assert.areEqual('0000000000000000', C.DES.decrypt(C.lib.CipherParams.create({ ciphertext: C.enc.Hex.parse('95a8d72813daa94d') }), C.enc.Hex.parse('8000000000000000'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString());
+        },
+
+        testDecrypt2: function () {
+            Y.Assert.areEqual('0000000000000000', C.DES.decrypt(C.lib.CipherParams.create({ ciphertext: C.enc.Hex.parse('1de5279dae3bed6f') }), C.enc.Hex.parse('0000000000002000'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString());
+        },
+
+        testDecrypt3: function () {
+            Y.Assert.areEqual('0000000000002000', C.DES.decrypt(C.lib.CipherParams.create({ ciphertext: C.enc.Hex.parse('1d1ca853ae7c0c5f') }), C.enc.Hex.parse('0000000000000000'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString());
+        },
+
+        testDecrypt4: function () {
+            Y.Assert.areEqual('3232323232323232', C.DES.decrypt(C.lib.CipherParams.create({ ciphertext: C.enc.Hex.parse('ac978c247863388f') }), C.enc.Hex.parse('3232323232323232'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString());
+        },
+
+        testDecrypt5: function () {
+            Y.Assert.areEqual('6464646464646464', C.DES.decrypt(C.lib.CipherParams.create({ ciphertext: C.enc.Hex.parse('3af1703d76442789') }), C.enc.Hex.parse('6464646464646464'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString());
+        },
+
+        testDecrypt6: function () {
+            Y.Assert.areEqual('9696969696969696', C.DES.decrypt(C.lib.CipherParams.create({ ciphertext: C.enc.Hex.parse('a020003c5554f34c') }), C.enc.Hex.parse('9696969696969696'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString());
+        },
+
+        testMultiPart: function () {
+            var des = C.algo.DES.createEncryptor(C.enc.Hex.parse('0123456789abcdef'), { mode: C.mode.ECB, padding: C.pad.NoPadding });
+            var ciphertext1 = des.process(C.enc.Hex.parse('001122334455'));
+            var ciphertext2 = des.process(C.enc.Hex.parse('66778899aa'));
+            var ciphertext3 = des.process(C.enc.Hex.parse('bbccddeeff'));
+            var ciphertext4 = des.finalize();
+
+            Y.Assert.areEqual(C.DES.encrypt(C.enc.Hex.parse('00112233445566778899aabbccddeeff'), C.enc.Hex.parse('0123456789abcdef'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).ciphertext.toString(), ciphertext1.concat(ciphertext2).concat(ciphertext3).concat(ciphertext4).toString());
+        },
+
+        testInputIntegrity: function () {
+            var message = C.enc.Hex.parse('00112233445566778899aabbccddeeff');
+            var key = C.enc.Hex.parse('0001020304050607');
+            var iv = C.enc.Hex.parse('08090a0b0c0d0e0f');
+
+            var expectedMessage = message.toString();
+            var expectedKey = key.toString();
+            var expectedIv = iv.toString();
+
+            C.DES.encrypt(message, key, { iv: iv });
+
+            Y.Assert.areEqual(expectedMessage, message.toString());
+            Y.Assert.areEqual(expectedKey, key.toString());
+            Y.Assert.areEqual(expectedIv, iv.toString());
+        },
+
+        testHelper: function () {
+            // Save original random method
+            var random = C.lib.WordArray.random;
+
+            // Replace random method with one that returns a predictable value
+            C.lib.WordArray.random = function (nBytes) {
+                var words = [];
+                for (var i = 0; i < nBytes; i += 4) {
+                    words.push([0x11223344]);
+                }
+
+                return C.lib.WordArray.create(words, nBytes);
+            };
+
+            // Test
+            Y.Assert.areEqual(C.algo.DES.createEncryptor(C.SHA256('Jefe'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).finalize('Hi There').toString(), C.DES.encrypt('Hi There', C.SHA256('Jefe'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).ciphertext.toString());
+            Y.Assert.areEqual(C.lib.SerializableCipher.encrypt(C.algo.DES, 'Hi There', C.SHA256('Jefe'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString(), C.DES.encrypt('Hi There', C.SHA256('Jefe'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString());
+            Y.Assert.areEqual(C.lib.PasswordBasedCipher.encrypt(C.algo.DES, 'Hi There', 'Jefe', { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString(), C.DES.encrypt('Hi There', 'Jefe', { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString());
+
+            // Restore random method
+            C.lib.WordArray.random = random;
+        }
+    }));
+}, '$Rev$');
diff --git a/test/enc-base64-test.js b/test/enc-base64-test.js
new file mode 100644
index 0000000..a40da35
--- /dev/null
+++ b/test/enc-base64-test.js
@@ -0,0 +1,71 @@
+YUI.add('enc-base64-test', function (Y) {
+    var C = CryptoJS;
+
+    Y.Test.Runner.add(new Y.Test.Case({
+        name: 'Base64',
+
+        testStringify0: function () {
+            Y.Assert.areEqual('', C.enc.Base64.stringify(C.lib.WordArray.create([0x666f6f62, 0x61720000], 0)));
+        },
+
+        testStringify1: function () {
+            Y.Assert.areEqual('Zg==', C.enc.Base64.stringify(C.lib.WordArray.create([0x666f6f62, 0x61720000], 1)));
+        },
+
+        testStringify2: function () {
+            Y.Assert.areEqual('Zm8=', C.enc.Base64.stringify(C.lib.WordArray.create([0x666f6f62, 0x61720000], 2)));
+        },
+
+        testStringify3: function () {
+            Y.Assert.areEqual('Zm9v', C.enc.Base64.stringify(C.lib.WordArray.create([0x666f6f62, 0x61720000], 3)));
+        },
+
+        testStringify4: function () {
+            Y.Assert.areEqual('Zm9vYg==', C.enc.Base64.stringify(C.lib.WordArray.create([0x666f6f62, 0x61720000], 4)));
+        },
+
+        testStringify5: function () {
+            Y.Assert.areEqual('Zm9vYmE=', C.enc.Base64.stringify(C.lib.WordArray.create([0x666f6f62, 0x61720000], 5)));
+        },
+
+        testStringify6: function () {
+            Y.Assert.areEqual('Zm9vYmFy', C.enc.Base64.stringify(C.lib.WordArray.create([0x666f6f62, 0x61720000], 6)));
+        },
+
+        testStringify15: function () {
+            Y.Assert.areEqual('Pj4+Pz8/Pj4+Pz8/PS8r', C.enc.Base64.stringify(C.lib.WordArray.create([0x3e3e3e3f, 0x3f3f3e3e, 0x3e3f3f3f, 0x3d2f2b00], 15)));
+        },
+
+        testParse0: function () {
+            Y.Assert.areEqual(C.lib.WordArray.create([0x666f6f62, 0x61720000], 0).toString(), C.enc.Base64.parse('').toString());
+        },
+
+        testParse1: function () {
+            Y.Assert.areEqual(C.lib.WordArray.create([0x666f6f62, 0x61720000], 1).toString(), C.enc.Base64.parse('Zg==').toString());
+        },
+
+        testParse2: function () {
+            Y.Assert.areEqual(C.lib.WordArray.create([0x666f6f62, 0x61720000], 2).toString(), C.enc.Base64.parse('Zm8=').toString());
+        },
+
+        testParse3: function () {
+            Y.Assert.areEqual(C.lib.WordArray.create([0x666f6f62, 0x61720000], 3).toString(), C.enc.Base64.parse('Zm9v').toString());
+        },
+
+        testParse4: function () {
+            Y.Assert.areEqual(C.lib.WordArray.create([0x666f6f62, 0x61720000], 4).toString(), C.enc.Base64.parse('Zm9vYg==').toString());
+        },
+
+        testParse5: function () {
+            Y.Assert.areEqual(C.lib.WordArray.create([0x666f6f62, 0x61720000], 5).toString(), C.enc.Base64.parse('Zm9vYmE=').toString());
+        },
+
+        testParse6: function () {
+            Y.Assert.areEqual(C.lib.WordArray.create([0x666f6f62, 0x61720000], 6).toString(), C.enc.Base64.parse('Zm9vYmFy').toString());
+        },
+
+        testParse15: function () {
+            Y.Assert.areEqual(C.lib.WordArray.create([0x3e3e3e3f, 0x3f3f3e3e, 0x3e3f3f3f, 0x3d2f2b00], 15).toString(), C.enc.Base64.parse('Pj4+Pz8/Pj4+Pz8/PS8r').toString());
+        }
+    }));
+}, '$Rev$');
diff --git a/test/enc-hex-test.js b/test/enc-hex-test.js
new file mode 100644
index 0000000..8ef9167
--- /dev/null
+++ b/test/enc-hex-test.js
@@ -0,0 +1,15 @@
+YUI.add('enc-hex-test', function (Y) {
+    var C = CryptoJS;
+
+    Y.Test.Runner.add(new Y.Test.Case({
+        name: 'Hex',
+
+        testStringify: function () {
+            Y.Assert.areEqual('12345678', C.enc.Hex.stringify(C.lib.WordArray.create([0x12345678])));
+        },
+
+        testParse: function () {
+            Y.Assert.areEqual(C.lib.WordArray.create([0x12345678]).toString(), C.enc.Hex.parse('12345678').toString());
+        }
+    }));
+}, '$Rev$');
diff --git a/test/enc-latin1-test.js b/test/enc-latin1-test.js
new file mode 100644
index 0000000..fc2c274
--- /dev/null
+++ b/test/enc-latin1-test.js
@@ -0,0 +1,15 @@
+YUI.add('enc-latin1-test', function (Y) {
+    var C = CryptoJS;
+
+    Y.Test.Runner.add(new Y.Test.Case({
+        name: 'Latin1',
+
+        testStringify: function () {
+            Y.Assert.areEqual('\x12\x34\x56\x78', C.enc.Latin1.stringify(C.lib.WordArray.create([0x12345678])));
+        },
+
+        testParse: function () {
+            Y.Assert.areEqual(C.lib.WordArray.create([0x12345678]).toString(), C.enc.Latin1.parse('\x12\x34\x56\x78').toString());
+        }
+    }));
+}, '$Rev$');
diff --git a/test/enc-utf16-test.js b/test/enc-utf16-test.js
new file mode 100644
index 0000000..073763a
--- /dev/null
+++ b/test/enc-utf16-test.js
@@ -0,0 +1,55 @@
+YUI.add('enc-utf16-test', function (Y) {
+    var C = CryptoJS;
+
+    Y.Test.Runner.add(new Y.Test.Case({
+        name: 'Utf16',
+
+        testStringify1: function () {
+            Y.Assert.areEqual('z', C.enc.Utf16.stringify(C.lib.WordArray.create([0x007a0000], 2)));
+        },
+
+        testStringify2: function () {
+            Y.Assert.areEqual('水', C.enc.Utf16.stringify(C.lib.WordArray.create([0x6c340000], 2)));
+        },
+
+        testStringify3: function () {
+            Y.Assert.areEqual('𐀀', C.enc.Utf16.stringify(C.lib.WordArray.create([0xd800dc00], 4)));
+        },
+
+        testStringify4: function () {
+            Y.Assert.areEqual('𝄞', C.enc.Utf16.stringify(C.lib.WordArray.create([0xd834dd1e], 4)));
+        },
+
+        testStringify5: function () {
+            Y.Assert.areEqual('􏿽', C.enc.Utf16.stringify(C.lib.WordArray.create([0xdbffdffd], 4)));
+        },
+
+        testStringifyLE: function () {
+            Y.Assert.areEqual('􏿽', C.enc.Utf16LE.stringify(C.lib.WordArray.create([0xffdbfddf], 4)));
+        },
+
+        testParse1: function () {
+            Y.Assert.areEqual(C.lib.WordArray.create([0x007a0000], 2).toString(), C.enc.Utf16.parse('z').toString());
+        },
+
+        testParse2: function () {
+            Y.Assert.areEqual(C.lib.WordArray.create([0x6c340000], 2).toString(), C.enc.Utf16.parse('水').toString());
+        },
+
+        testParse3: function () {
+            Y.Assert.areEqual(C.lib.WordArray.create([0xd800dc00], 4).toString(), C.enc.Utf16.parse('𐀀').toString());
+        },
+
+        testParse4: function () {
+            Y.Assert.areEqual(C.lib.WordArray.create([0xd834dd1e], 4).toString(), C.enc.Utf16.parse('𝄞').toString());
+        },
+
+        testParse5: function () {
+            Y.Assert.areEqual(C.lib.WordArray.create([0xdbffdffd], 4).toString(), C.enc.Utf16.parse('􏿽').toString());
+        },
+
+        testParseLE: function () {
+            Y.Assert.areEqual(C.lib.WordArray.create([0xffdbfddf], 4).toString(), C.enc.Utf16LE.parse('􏿽').toString());
+        }
+    }));
+}, '$Rev$');
diff --git a/test/enc-utf8-test.js b/test/enc-utf8-test.js
new file mode 100644
index 0000000..7786c96
--- /dev/null
+++ b/test/enc-utf8-test.js
@@ -0,0 +1,39 @@
+YUI.add('enc-utf8-test', function (Y) {
+    var C = CryptoJS;
+
+    Y.Test.Runner.add(new Y.Test.Case({
+        name: 'Utf8',
+
+        testStringify1: function () {
+            Y.Assert.areEqual('$', C.enc.Utf8.stringify(C.lib.WordArray.create([0x24000000], 1)));
+        },
+
+        testStringify2: function () {
+            Y.Assert.areEqual('¢', C.enc.Utf8.stringify(C.lib.WordArray.create([0xc2a20000], 2)));
+        },
+
+        testStringify3: function () {
+            Y.Assert.areEqual('€', C.enc.Utf8.stringify(C.lib.WordArray.create([0xe282ac00], 3)));
+        },
+
+        testStringify4: function () {
+            Y.Assert.areEqual('𤭢', C.enc.Utf8.stringify(C.lib.WordArray.create([0xf0a4ada2], 4)));
+        },
+
+        testParse1: function () {
+            Y.Assert.areEqual(C.lib.WordArray.create([0x24000000], 1).toString(), C.enc.Utf8.parse('$').toString());
+        },
+
+        testParse2: function () {
+            Y.Assert.areEqual(C.lib.WordArray.create([0xc2a20000], 2).toString(), C.enc.Utf8.parse('¢').toString());
+        },
+
+        testParse3: function () {
+            Y.Assert.areEqual(C.lib.WordArray.create([0xe282ac00], 3).toString(), C.enc.Utf8.parse('€').toString());
+        },
+
+        testParse4: function () {
+            Y.Assert.areEqual(C.lib.WordArray.create([0xf0a4ada2], 4).toString(), C.enc.Utf8.parse('𤭢').toString());
+        }
+    }));
+}, '$Rev$');
diff --git a/test/evpkdf-profile.js b/test/evpkdf-profile.js
new file mode 100644
index 0000000..68a709b
--- /dev/null
+++ b/test/evpkdf-profile.js
@@ -0,0 +1,11 @@
+YUI.add('algo-evpkdf-profile', function (Y) {
+    var C = CryptoJS;
+
+    Y.Profiler.add({
+        name: 'EvpKDF',
+
+        profileKeySize256Iterations20: function () {
+            C.algo.EvpKDF.create({ keySize: 256/32, iterations: 20 }).compute('password', 'ATHENA.MIT.EDUraeburn');
+        }
+    });
+}, '$Rev$');
diff --git a/test/evpkdf-test.js b/test/evpkdf-test.js
new file mode 100644
index 0000000..492551a
--- /dev/null
+++ b/test/evpkdf-test.js
@@ -0,0 +1,32 @@
+YUI.add('algo-evpkdf-test', function (Y) {
+    var C = CryptoJS;
+
+    Y.Test.Runner.add(new Y.Test.Case({
+        name: 'EvpKDF',
+
+        testVector: function () {
+            Y.Assert.areEqual('fdbdf3419fff98bdb0241390f62a9db35f4aba29d77566377997314ebfc709f20b5ca7b1081f94b1ac12e3c8ba87d05a', C.EvpKDF('password', 'saltsalt', { keySize: (256+128)/32 }).toString());
+        },
+
+        // There are no official test vectors that I could find, and the EVP implementation is short on comments.
+        // Need to use the C code to generate more test vectors.
+        // The iteration count in particular needs to be tested.
+
+        testInputIntegrity: function () {
+            var password = C.lib.WordArray.create([0x12345678]);
+            var salt = C.lib.WordArray.create([0x12345678]);
+
+            var expectedPassword = password.toString();
+            var expectedSalt = salt.toString();
+
+            C.EvpKDF(password, salt);
+
+            Y.Assert.areEqual(expectedPassword, password.toString());
+            Y.Assert.areEqual(expectedSalt, salt.toString());
+        },
+
+        testHelper: function () {
+            Y.Assert.areEqual(C.algo.EvpKDF.create({ keySize: (256+128)/32 }).compute('password', 'saltsalt').toString(), C.EvpKDF('password', 'saltsalt', { keySize: (256+128)/32 }).toString());
+        }
+    }));
+}, '$Rev$');
diff --git a/test/format-openssl-test.js b/test/format-openssl-test.js
new file mode 100644
index 0000000..b6a6153
--- /dev/null
+++ b/test/format-openssl-test.js
@@ -0,0 +1,37 @@
+YUI.add('format-openssl-test', function (Y) {
+    var C = CryptoJS;
+
+    Y.Test.Runner.add(new Y.Test.Case({
+        name: 'OpenSSLFormatter',
+
+        setUp: function () {
+            this.data = {};
+
+            this.data.ciphertext = C.lib.WordArray.create([0x00010203, 0x04050607, 0x08090a0b, 0x0c0d0e0f]);
+            this.data.salt = C.lib.WordArray.create([0x01234567, 0x89abcdef]);
+        },
+
+        testSaltedToString: function () {
+            Y.Assert.areEqual(C.enc.Latin1.parse('Salted__').concat(this.data.salt).concat(this.data.ciphertext).toString(C.enc.Base64), C.format.OpenSSL.stringify(C.lib.CipherParams.create({ ciphertext: this.data.ciphertext, salt: this.data.salt })));
+        },
+
+        testUnsaltedToString: function () {
+            Y.Assert.areEqual(this.data.ciphertext.toString(C.enc.Base64), C.format.OpenSSL.stringify(C.lib.CipherParams.create({ ciphertext: this.data.ciphertext })));
+        },
+
+        testSaltedFromString: function () {
+            var openSSLStr = C.format.OpenSSL.stringify(C.lib.CipherParams.create({ ciphertext: this.data.ciphertext, salt: this.data.salt }));
+            var cipherParams = C.format.OpenSSL.parse(openSSLStr);
+
+            Y.Assert.areEqual(this.data.ciphertext.toString(), cipherParams.ciphertext.toString());
+            Y.Assert.areEqual(this.data.salt.toString(), cipherParams.salt.toString());
+        },
+
+        testUnsaltedFromString: function () {
+            var openSSLStr = C.format.OpenSSL.stringify(C.lib.CipherParams.create({ ciphertext: this.data.ciphertext }));
+            var cipherParams = C.format.OpenSSL.parse(openSSLStr);
+
+            Y.Assert.areEqual(this.data.ciphertext.toString(), cipherParams.ciphertext.toString());
+        }
+    }));
+}, '$Rev$');
diff --git a/test/hmac-md5-profile.js b/test/hmac-md5-profile.js
new file mode 100644
index 0000000..b628240
--- /dev/null
+++ b/test/hmac-md5-profile.js
@@ -0,0 +1,30 @@
+YUI.add('algo-hmac-md5-profile', function (Y) {
+    var C = CryptoJS;
+
+    Y.Profiler.add({
+        name: 'HMAC MD5',
+
+        setUp: function () {
+            this.data = {
+                key: C.lib.WordArray.random(128/8)
+            };
+        },
+
+        profileSinglePartMessage: function () {
+            var singlePartMessage = '';
+            for (var i = 0; i < 500; i++) {
+                singlePartMessage += '12345678901234567890123456789012345678901234567890';
+            }
+
+            C.algo.HMAC.create(C.algo.MD5, this.data.key).finalize(singlePartMessage) + '';
+        },
+
+        profileMultiPartMessage: function () {
+            var hmac = C.algo.HMAC.create(C.algo.MD5, this.data.key);
+            for (var i = 0; i < 500; i++) {
+                hmac.update('12345678901234567890123456789012345678901234567890');
+            }
+            hmac.finalize() + '';
+        }
+    });
+}, '$Rev$');
diff --git a/test/hmac-md5-test.js b/test/hmac-md5-test.js
new file mode 100644
index 0000000..b87aaf9
--- /dev/null
+++ b/test/hmac-md5-test.js
@@ -0,0 +1,59 @@
+YUI.add('algo-hmac-md5-test', function (Y) {
+    var C = CryptoJS;
+
+    Y.Test.Runner.add(new Y.Test.Case({
+        name: 'HMAC MD5',
+
+        testVector1: function () {
+            Y.Assert.areEqual('9294727a3638bb1c13f48ef8158bfc9d', C.HmacMD5('Hi There', C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).toString());
+        },
+
+        testVector2: function () {
+            Y.Assert.areEqual('750c783e6ab0b503eaa86e310a5db738', C.HmacMD5('what do ya want for nothing?', 'Jefe').toString());
+        },
+
+        testVector3: function () {
+            Y.Assert.areEqual('56be34521d144c88dbb8c733f0e8b3f6', C.HmacMD5(C.enc.Hex.parse('dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd'), C.enc.Hex.parse('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')).toString());
+        },
+
+        testVector4: function () {
+            Y.Assert.areEqual('7ee2a3cc979ab19865704644ce13355c', C.HmacMD5('ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'A').toString());
+        },
+
+        testVector5: function () {
+            Y.Assert.areEqual('0e1bd89c43e3e6e3b3f8cf1d5ba4f77a', C.HmacMD5('abcdefghijklmnopqrstuvwxyz', 'A').toString());
+        },
+
+        testUpdate: function () {
+            var hmac = C.algo.HMAC.create(C.algo.MD5, C.enc.Hex.parse('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'));
+            hmac.update(C.enc.Hex.parse('dddddddddddddddddddddddddddddddddddd'));
+            hmac.update(C.enc.Hex.parse('dddddddddddddddddddddddddddddddd'));
+            hmac.update(C.enc.Hex.parse('dddddddddddddddddddddddddddddddd'));
+
+            Y.Assert.areEqual(C.HmacMD5(C.enc.Hex.parse('dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd'), C.enc.Hex.parse('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')).toString(), hmac.finalize().toString());
+        },
+
+        testInputIntegrity: function () {
+            var message = C.lib.WordArray.create([0x12345678]);
+            var key = C.lib.WordArray.create([0x12345678]);
+
+            var expectedMessage = message.toString();
+            var expectedKey = key.toString();
+
+            C.HmacMD5(message, key);
+
+            Y.Assert.areEqual(expectedMessage, message.toString());
+            Y.Assert.areEqual(expectedKey, key.toString());
+        },
+
+        testRespectKeySigBytes: function () {
+            var key = C.lib.WordArray.random(8);
+            key.sigBytes = 4;
+
+            var keyClamped = key.clone();
+            keyClamped.clamp();
+
+            Y.Assert.areEqual(CryptoJS.HmacSHA256("Message", keyClamped).toString(), CryptoJS.HmacSHA256("Message", key).toString());
+        }
+    }));
+}, '$Rev$');
diff --git a/test/hmac-sha224-test.js b/test/hmac-sha224-test.js
new file mode 100644
index 0000000..4895137
--- /dev/null
+++ b/test/hmac-sha224-test.js
@@ -0,0 +1,59 @@
+YUI.add('algo-hmac-sha224-test', function (Y) {
+    var C = CryptoJS;
+
+    Y.Test.Runner.add(new Y.Test.Case({
+        name: 'HMAC SHA224',
+
+        testVector1: function () {
+            Y.Assert.areEqual('4e841ce7a4ae83fbcf71e3cd64bfbf277f73a14680aae8c518ac7861', C.HmacSHA224('Hi There', C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).toString());
+        },
+
+        testVector2: function () {
+            Y.Assert.areEqual('a30e01098bc6dbbf45690f3a7e9e6d0f8bbea2a39e6148008fd05e44', C.HmacSHA224('what do ya want for nothing?', 'Jefe').toString());
+        },
+
+        testVector3: function () {
+            Y.Assert.areEqual('cbff7c2716bbaa7c77bed4f491d3e8456cb6c574e92f672b291acf5b', C.HmacSHA224(C.enc.Hex.parse('dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd'), C.enc.Hex.parse('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')).toString());
+        },
+
+        testVector4: function () {
+            Y.Assert.areEqual('61bf669da4fdcd8e5c3bd09ebbb4a986d3d1b298d3ca05c511f7aeff', C.HmacSHA224('ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'A').toString());
+        },
+
+        testVector5: function () {
+            Y.Assert.areEqual('16fc69ada3c3edc1fe9144d6b98d93393833ae442bedf681110a1176', C.HmacSHA224('abcdefghijklmnopqrstuvwxyz', 'A').toString());
+        },
+
+        testUpdate: function () {
+            var hmac = C.algo.HMAC.create(C.algo.SHA224, C.enc.Hex.parse('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'));
+            hmac.update(C.enc.Hex.parse('dddddddddddddddddddddddddddddddddddd'));
+            hmac.update(C.enc.Hex.parse('dddddddddddddddddddddddddddddddd'));
+            hmac.update(C.enc.Hex.parse('dddddddddddddddddddddddddddddddd'));
+
+            Y.Assert.areEqual(C.HmacSHA224(C.enc.Hex.parse('dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd'), C.enc.Hex.parse('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')).toString(), hmac.finalize().toString());
+        },
+
+        testInputIntegrity: function () {
+            var message = C.lib.WordArray.create([0x12345678]);
+            var key = C.lib.WordArray.create([0x12345678]);
+
+            var expectedMessage = message.toString();
+            var expectedKey = key.toString();
+
+            C.HmacSHA224(message, key);
+
+            Y.Assert.areEqual(expectedMessage, message.toString());
+            Y.Assert.areEqual(expectedKey, key.toString());
+        },
+
+        testRespectKeySigBytes: function () {
+            var key = C.lib.WordArray.random(8);
+            key.sigBytes = 4;
+
+            var keyClamped = key.clone();
+            keyClamped.clamp();
+
+            Y.Assert.areEqual(CryptoJS.HmacSHA224("Message", keyClamped).toString(), CryptoJS.HmacSHA224("Message", key).toString());
+        }
+    }));
+}, '$Rev$');
diff --git a/test/hmac-sha256-test.js b/test/hmac-sha256-test.js
new file mode 100644
index 0000000..f10d89e
--- /dev/null
+++ b/test/hmac-sha256-test.js
@@ -0,0 +1,59 @@
+YUI.add('algo-hmac-sha256-test', function (Y) {
+    var C = CryptoJS;
+
+    Y.Test.Runner.add(new Y.Test.Case({
+        name: 'HMAC SHA256',
+
+        testVector1: function () {
+            Y.Assert.areEqual('492ce020fe2534a5789dc3848806c78f4f6711397f08e7e7a12ca5a4483c8aa6', C.HmacSHA256('Hi There', C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).toString());
+        },
+
+        testVector2: function () {
+            Y.Assert.areEqual('5bdcc146bf60754e6a042426089575c75a003f089d2739839dec58b964ec3843', C.HmacSHA256('what do ya want for nothing?', 'Jefe').toString());
+        },
+
+        testVector3: function () {
+            Y.Assert.areEqual('7dda3cc169743a6484649f94f0eda0f9f2ff496a9733fb796ed5adb40a44c3c1', C.HmacSHA256(C.enc.Hex.parse('dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd'), C.enc.Hex.parse('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')).toString());
+        },
+
+        testVector4: function () {
+            Y.Assert.areEqual('a89dc8178c1184a62df87adaa77bf86e93064863d93c5131140b0ae98b866687', C.HmacSHA256('ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'A').toString());
+        },
+
+        testVector5: function () {
+            Y.Assert.areEqual('d8cb78419c02fe20b90f8b77427dd9f81817a751d74c2e484e0ac5fc4e6ca986', C.HmacSHA256('abcdefghijklmnopqrstuvwxyz', 'A').toString());
+        },
+
+        testUpdate: function () {
+            var hmac = C.algo.HMAC.create(C.algo.SHA256, C.enc.Hex.parse('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'));
+            hmac.update(C.enc.Hex.parse('dddddddddddddddddddddddddddddddddddd'));
+            hmac.update(C.enc.Hex.parse('dddddddddddddddddddddddddddddddd'));
+            hmac.update(C.enc.Hex.parse('dddddddddddddddddddddddddddddddd'));
+
+            Y.Assert.areEqual(C.HmacSHA256(C.enc.Hex.parse('dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd'), C.enc.Hex.parse('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')).toString(), hmac.finalize().toString());
+        },
+
+        testInputIntegrity: function () {
+            var message = C.lib.WordArray.create([0x12345678]);
+            var key = C.lib.WordArray.create([0x12345678]);
+
+            var expectedMessage = message.toString();
+            var expectedKey = key.toString();
+
+            C.HmacSHA256(message, key);
+
+            Y.Assert.areEqual(expectedMessage, message.toString());
+            Y.Assert.areEqual(expectedKey, key.toString());
+        },
+
+        testRespectKeySigBytes: function () {
+            var key = C.lib.WordArray.random(8);
+            key.sigBytes = 4;
+
+            var keyClamped = key.clone();
+            keyClamped.clamp();
+
+            Y.Assert.areEqual(CryptoJS.HmacSHA256("Message", keyClamped).toString(), CryptoJS.HmacSHA256("Message", key).toString());
+        }
+    }));
+}, '$Rev$');
diff --git a/test/hmac-sha384-test.js b/test/hmac-sha384-test.js
new file mode 100644
index 0000000..ebea5e1
--- /dev/null
+++ b/test/hmac-sha384-test.js
@@ -0,0 +1,59 @@
+YUI.add('algo-hmac-sha384-test', function (Y) {
+    var C = CryptoJS;
+
+    Y.Test.Runner.add(new Y.Test.Case({
+        name: 'HMAC SHA384',
+
+        testVector1: function () {
+            Y.Assert.areEqual('7afaa633e20d379b02395915fbc385ff8dc27dcd3885e1068ab942eeab52ec1f20ad382a92370d8b2e0ac8b83c4d53bf', C.HmacSHA384('Hi There', C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).toString());
+        },
+
+        testVector2: function () {
+            Y.Assert.areEqual('af45d2e376484031617f78d2b58a6b1b9c7ef464f5a01b47e42ec3736322445e8e2240ca5e69e2c78b3239ecfab21649', C.HmacSHA384('what do ya want for nothing?', 'Jefe').toString());
+        },
+
+        testVector3: function () {
+            Y.Assert.areEqual('1383e82e28286b91f4cc7afbd13d5b5c6f887c05e7c4542484043a37a5fe45802a9470fb663bd7b6570fe2f503fc92f5', C.HmacSHA384(C.enc.Hex.parse('dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd'), C.enc.Hex.parse('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')).toString());
+        },
+
+        testVector4: function () {
+            Y.Assert.areEqual('365dfb271adb8e30fe6c74220b75df1b38c2d19b9d37f2e5a0ec2f3f22bd0406bf5b786e98d81b82c36d3d8a1be6cd07', C.HmacSHA384('ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'A').toString());
+        },
+
+        testVector5: function () {
+            Y.Assert.areEqual('a8357d5e84da64140e41545562ae0782e2a58e39c6cd98939fad8d9080e774c84b7eaca4ba07f6dbf0f12eab912c5285', C.HmacSHA384('abcdefghijklmnopqrstuvwxyz', 'A').toString());
+        },
+
+        testUpdate: function () {
+            var hmac = C.algo.HMAC.create(C.algo.SHA384, C.enc.Hex.parse('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'));
+            hmac.update(C.enc.Hex.parse('dddddddddddddddddddddddddddddddddddd'));
+            hmac.update(C.enc.Hex.parse('dddddddddddddddddddddddddddddddd'));
+            hmac.update(C.enc.Hex.parse('dddddddddddddddddddddddddddddddd'));
+
+            Y.Assert.areEqual(C.HmacSHA384(C.enc.Hex.parse('dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd'), C.enc.Hex.parse('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')).toString(), hmac.finalize().toString());
+        },
+
+        testInputIntegrity: function () {
+            var message = C.lib.WordArray.create([0x12345678]);
+            var key = C.lib.WordArray.create([0x12345678]);
+
+            var expectedMessage = message.toString();
+            var expectedKey = key.toString();
+
+            C.HmacSHA384(message, key);
+
+            Y.Assert.areEqual(expectedMessage, message.toString());
+            Y.Assert.areEqual(expectedKey, key.toString());
+        },
+
+        testRespectKeySigBytes: function () {
+            var key = C.lib.WordArray.random(8);
+            key.sigBytes = 4;
+
+            var keyClamped = key.clone();
+            keyClamped.clamp();
+
+            Y.Assert.areEqual(CryptoJS.HmacSHA384("Message", keyClamped).toString(), CryptoJS.HmacSHA384("Message", key).toString());
+        }
+    }));
+}, '$Rev$');
diff --git a/test/hmac-sha512-test.js b/test/hmac-sha512-test.js
new file mode 100644
index 0000000..1e5d820
--- /dev/null
+++ b/test/hmac-sha512-test.js
@@ -0,0 +1,59 @@
+YUI.add('algo-hmac-sha512-test', function (Y) {
+    var C = CryptoJS;
+
+    Y.Test.Runner.add(new Y.Test.Case({
+        name: 'HMAC SHA512',
+
+        testVector1: function () {
+            Y.Assert.areEqual('7641c48a3b4aa8f887c07b3e83f96affb89c978fed8c96fcbbf4ad596eebfe496f9f16da6cd080ba393c6f365ad72b50d15c71bfb1d6b81f66a911786c6ce932', C.HmacSHA512('Hi There', C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).toString());
+        },
+
+        testVector2: function () {
+            Y.Assert.areEqual('164b7a7bfcf819e2e395fbe73b56e0a387bd64222e831fd610270cd7ea2505549758bf75c05a994a6d034f65f8f0e6fdcaeab1a34d4a6b4b636e070a38bce737', C.HmacSHA512('what do ya want for nothing?', 'Jefe').toString());
+        },
+
+        testVector3: function () {
+            Y.Assert.areEqual('ad9b5c7de72693737cd5e9d9f41170d18841fec1201c1c1b02e05cae116718009f771cad9946ddbf7e3cde3e818d9ae85d91b2badae94172d096a44a79c91e86', C.HmacSHA512(C.enc.Hex.parse('dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd'), C.enc.Hex.parse('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')).toString());
+        },
+
+        testVector4: function () {
+            Y.Assert.areEqual('a303979f7c94bb39a8ab6ce05cdbe28f0255da8bb305263e3478ef7e855f0242729bf1d2be55398f14da8e63f0302465a8a3f76c297bd584ad028d18ed7f0195', C.HmacSHA512('ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'A').toString());
+        },
+
+        testVector5: function () {
+            Y.Assert.areEqual('8c2d56f7628325e62124c0a870ad98d101327fc42696899a06ce0d7121454022fae597e42c25ac3a4c380fd514f553702a5b0afaa9b5a22050902f024368e9d9', C.HmacSHA512('abcdefghijklmnopqrstuvwxyz', 'A').toString());
+        },
+
+        testUpdate: function () {
+            var hmac = C.algo.HMAC.create(C.algo.SHA512, C.enc.Hex.parse('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'));
+            hmac.update(C.enc.Hex.parse('dddddddddddddddddddddddddddddddddddd'));
+            hmac.update(C.enc.Hex.parse('dddddddddddddddddddddddddddddddd'));
+            hmac.update(C.enc.Hex.parse('dddddddddddddddddddddddddddddddd'));
+
+            Y.Assert.areEqual(C.HmacSHA512(C.enc.Hex.parse('dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd'), C.enc.Hex.parse('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')).toString(), hmac.finalize().toString());
+        },
+
+        testInputIntegrity: function () {
+            var message = C.lib.WordArray.create([0x12345678]);
+            var key = C.lib.WordArray.create([0x12345678]);
+
+            var expectedMessage = message.toString();
+            var expectedKey = key.toString();
+
+            C.HmacSHA512(message, key);
+
+            Y.Assert.areEqual(expectedMessage, message.toString());
+            Y.Assert.areEqual(expectedKey, key.toString());
+        },
+
+        testRespectKeySigBytes: function () {
+            var key = C.lib.WordArray.random(8);
+            key.sigBytes = 4;
+
+            var keyClamped = key.clone();
+            keyClamped.clamp();
+
+            Y.Assert.areEqual(CryptoJS.HmacSHA512("Message", keyClamped).toString(), CryptoJS.HmacSHA512("Message", key).toString());
+        }
+    }));
+}, '$Rev$');
diff --git a/test/kdf-openssl-test.js b/test/kdf-openssl-test.js
new file mode 100644
index 0000000..92a8d9e
--- /dev/null
+++ b/test/kdf-openssl-test.js
@@ -0,0 +1,15 @@
+YUI.add('kdf-openssl-test', function (Y) {
+    var C = CryptoJS;
+
+    Y.Test.Runner.add(new Y.Test.Case({
+        name: 'OpenSSLKdf',
+
+        testVector: function () {
+            var derivedParams = C.kdf.OpenSSL.execute('password', 256/32, 128/32, C.enc.Hex.parse('0a9d8620cf7219f1'));
+
+            Y.Assert.areEqual('50f32e0ec9408e02ff42364a52aac95c3694fc027256c6f488bf84b8e60effcd', derivedParams.key.toString());
+            Y.Assert.areEqual('81381e39b94fd692dff7e2239a298cb6', derivedParams.iv.toString());
+            Y.Assert.areEqual('0a9d8620cf7219f1', derivedParams.salt.toString());
+        }
+    }));
+}, '$Rev$');
diff --git a/test/lib-base-test.js b/test/lib-base-test.js
new file mode 100644
index 0000000..ed8e642
--- /dev/null
+++ b/test/lib-base-test.js
@@ -0,0 +1,92 @@
+YUI.add('lib-base-test', function (Y) {
+    var C = CryptoJS;
+
+    Y.Test.Runner.add(new Y.Test.Case({
+        name: 'Base',
+
+        setUp: function () {
+            this.data = {};
+
+            this.data.overrides = {
+                init: function (arg) {
+                    this.initFired = true;
+                    this.initArg = arg;
+                },
+
+                toString: function () {
+                }
+            };
+
+            this.data.mixins = {
+                mixinMethod: function () {
+                }
+            };
+
+            this.data.Obj = C.lib.Base.extend(this.data.overrides);
+
+            this.data.Obj.mixIn(this.data.mixins);
+
+            this.data.obj = this.data.Obj.create('argValue');
+
+            this.data.objClone = this.data.obj.clone();
+        },
+
+        testExtendInheritance: function () {
+            Y.Assert.areEqual(C.lib.Base.extend, this.data.Obj.extend);
+            Y.Assert.isFalse(this.data.Obj.hasOwnProperty('extend'));
+        },
+
+        testExtendSuper: function () {
+            Y.Assert.areEqual(C.lib.Base, this.data.Obj.$super);
+        },
+
+        testExtendOverrideInit: function () {
+            Y.Assert.areEqual(this.data.overrides.init, this.data.Obj.init);
+            Y.Assert.isTrue(this.data.Obj.hasOwnProperty('init'));
+        },
+
+        testExtendOverrideToString: function () {
+            Y.Assert.areEqual(this.data.overrides.toString, this.data.Obj.toString);
+            Y.Assert.isTrue(this.data.Obj.hasOwnProperty('toString'));
+        },
+
+        testCreateInheritanceFromBase: function () {
+            Y.Assert.areEqual(C.lib.Base.extend, this.data.obj.extend);
+            Y.Assert.isFalse(this.data.obj.hasOwnProperty('extend'));
+        },
+
+        testCreateSuper: function () {
+            Y.Assert.areEqual(this.data.Obj, this.data.obj.$super);
+        },
+
+        testCreateInit: function () {
+            Y.Assert.isTrue(this.data.obj.initFired);
+            Y.Assert.areEqual('argValue', this.data.obj.initArg);
+        },
+
+        testMixIn: function () {
+            Y.Assert.areEqual(this.data.mixins.mixinMethod, this.data.Obj.mixinMethod);
+            Y.Assert.isTrue(this.data.Obj.hasOwnProperty('mixinMethod'));
+        },
+
+        testCloneDistinct: function () {
+            Y.Assert.areNotEqual(this.data.obj, this.data.objClone);
+        },
+
+        testCloneCopy: function () {
+            Y.Assert.areEqual(this.data.obj.initArg, this.data.objClone.initArg);
+        },
+
+        testCloneIndependent: function () {
+            this.data.obj.initArg = 'newValue';
+
+            Y.Assert.areNotEqual(this.data.obj.initArg, this.data.objClone.initArg);
+        },
+
+        testCloneLeavesOriginalInitPrototypeUnchanged: function() {
+            Y.Assert.areEqual(this.data.obj, this.data.obj.init.prototype);
+            Y.Assert.areEqual(this.data.objClone, this.data.objClone.init.prototype);
+            Y.Assert.areNotEqual(this.data.obj.init.prototype, this.data.objClone.init.prototype);
+        }
+    }));
+}, '$Rev$');
diff --git a/test/lib-cipherparams-test.js b/test/lib-cipherparams-test.js
new file mode 100644
index 0000000..a99d25d
--- /dev/null
+++ b/test/lib-cipherparams-test.js
@@ -0,0 +1,59 @@
+YUI.add('lib-cipherparams-test', function (Y) {
+    var C = CryptoJS;
+
+    Y.Test.Runner.add(new Y.Test.Case({
+        name: 'CipherParams',
+
+        setUp: function () {
+            this.data = {};
+
+            this.data.ciphertext = C.enc.Hex.parse('000102030405060708090a0b0c0d0e0f');
+            this.data.key = C.enc.Hex.parse('101112131415161718191a1b1c1d1e1f');
+            this.data.iv = C.enc.Hex.parse('202122232425262728292a2b2c2d2e2f');
+            this.data.salt = C.enc.Hex.parse('0123456789abcdef');
+            this.data.algorithm = C.algo.AES;
+            this.data.mode = C.mode.CBC;
+            this.data.padding = C.pad.PKCS7;
+            this.data.blockSize = this.data.algorithm.blockSize;
+            this.data.formatter = C.format.OpenSSL;
+
+            this.data.cipherParams = C.lib.CipherParams.create({
+                ciphertext: this.data.ciphertext,
+                key: this.data.key,
+                iv: this.data.iv,
+                salt: this.data.salt,
+                algorithm: this.data.algorithm,
+                mode: this.data.mode,
+                padding: this.data.padding,
+                blockSize: this.data.blockSize,
+                formatter: this.data.formatter
+            });
+        },
+
+        testInit: function () {
+            Y.Assert.areEqual(this.data.ciphertext, this.data.cipherParams.ciphertext);
+            Y.Assert.areEqual(this.data.key, this.data.cipherParams.key);
+            Y.Assert.areEqual(this.data.iv, this.data.cipherParams.iv);
+            Y.Assert.areEqual(this.data.salt, this.data.cipherParams.salt);
+            Y.Assert.areEqual(this.data.algorithm, this.data.cipherParams.algorithm);
+            Y.Assert.areEqual(this.data.mode, this.data.cipherParams.mode);
+            Y.Assert.areEqual(this.data.padding, this.data.cipherParams.padding);
+            Y.Assert.areEqual(this.data.blockSize, this.data.cipherParams.blockSize);
+            Y.Assert.areEqual(this.data.formatter, this.data.cipherParams.formatter);
+        },
+
+        testToString0: function () {
+            Y.Assert.areEqual(C.format.OpenSSL.stringify(this.data.cipherParams), this.data.cipherParams.toString());
+        },
+
+        testToString1: function () {
+            var JsonFormatter = {
+                stringify: function (cipherParams) {
+                    return '{ ct: ' + cipherParams.ciphertext + ', iv: ' + cipherParams.iv + ' }';
+                }
+            };
+
+            Y.Assert.areEqual(JsonFormatter.stringify(this.data.cipherParams), this.data.cipherParams.toString(JsonFormatter));
+        }
+    }));
+}, '$Rev$');
diff --git a/test/lib-passwordbasedcipher-test.js b/test/lib-passwordbasedcipher-test.js
new file mode 100644
index 0000000..04f63a1
--- /dev/null
+++ b/test/lib-passwordbasedcipher-test.js
@@ -0,0 +1,25 @@
+YUI.add('lib-passwordbasedcipher-test', function (Y) {
+    var C = CryptoJS;
+
+    Y.Test.Runner.add(new Y.Test.Case({
+        name: 'PasswordBasedCipher',
+
+        testEncrypt: function () {
+            // Compute actual
+            var actual = C.lib.PasswordBasedCipher.encrypt(C.algo.AES, 'Hello, World!', 'password');
+
+            // Compute expected
+            var aes = C.algo.AES.createEncryptor(actual.key, { iv: actual.iv });
+            var expected = aes.finalize('Hello, World!');
+
+            Y.Assert.areEqual(expected.toString(), actual.ciphertext.toString());
+        },
+
+        testDecrypt: function () {
+            var ciphertext = C.lib.PasswordBasedCipher.encrypt(C.algo.AES, 'Hello, World!', 'password');
+            var plaintext = C.lib.PasswordBasedCipher.decrypt(C.algo.AES, ciphertext, 'password');
+
+            Y.Assert.areEqual('Hello, World!', plaintext.toString(C.enc.Utf8));
+        }
+    }));
+}, '$Rev$');
diff --git a/test/lib-serializablecipher-test.js b/test/lib-serializablecipher-test.js
new file mode 100644
index 0000000..60a13da
--- /dev/null
+++ b/test/lib-serializablecipher-test.js
@@ -0,0 +1,51 @@
+YUI.add('lib-serializablecipher-test', function (Y) {
+    var C = CryptoJS;
+
+    Y.Test.Runner.add(new Y.Test.Case({
+        name: 'SerializableCipher',
+
+        setUp: function () {
+            this.data = {};
+
+            this.data.message = C.lib.WordArray.create([0x00010203, 0x04050607, 0x08090a0b, 0x0c0d0e0f]);
+            this.data.key = C.lib.WordArray.create([0x10111213, 0x14151617, 0x18191a1b, 0x1c1d1e1f]);
+            this.data.iv = C.lib.WordArray.create([0x20212223, 0x24252627, 0x28292a2b, 0x2c2d2e2f]);
+        },
+
+        testEncrypt: function () {
+            // Compute expected
+            var aes = C.algo.AES.createEncryptor(this.data.key, { iv: this.data.iv });
+            var ciphertext = aes.finalize(this.data.message);
+            var expected = C.lib.CipherParams.create({
+                ciphertext: ciphertext,
+                key: this.data.key,
+                iv: this.data.iv,
+                algorithm: C.algo.AES,
+                mode: aes.cfg.mode,
+                padding: aes.cfg.padding,
+                blockSize: aes.blockSize,
+                formatter: C.format.OpenSSL
+            });
+
+            // Compute actual
+            var actual = C.lib.SerializableCipher.encrypt(C.algo.AES, this.data.message, this.data.key, { iv: this.data.iv });
+
+            // Test
+            Y.Assert.areEqual(expected.toString(), actual.toString());
+            Y.Assert.areEqual(expected.ciphertext.toString(), actual.ciphertext.toString());
+            Y.Assert.areEqual(expected.key.toString(), actual.key.toString());
+            Y.Assert.areEqual(expected.iv.toString(), actual.iv.toString());
+            Y.Assert.areEqual(expected.algorithm, actual.algorithm);
+            Y.Assert.areEqual(expected.mode, actual.mode);
+            Y.Assert.areEqual(expected.padding, actual.padding);
+            Y.Assert.areEqual(expected.blockSize, actual.blockSize);
+        },
+
+        testDecrypt: function () {
+            var encrypted = C.lib.SerializableCipher.encrypt(C.algo.AES, this.data.message, this.data.key, { iv: this.data.iv }) + '';
+            var decrypted = C.lib.SerializableCipher.decrypt(C.algo.AES, encrypted, this.data.key, { iv: this.data.iv });
+
+            Y.Assert.areEqual(this.data.message.toString(), decrypted.toString());
+        }
+    }));
+}, '$Rev$');
diff --git a/test/lib-typedarrays-test.js b/test/lib-typedarrays-test.js
new file mode 100644
index 0000000..4763a56
--- /dev/null
+++ b/test/lib-typedarrays-test.js
@@ -0,0 +1,57 @@
+YUI.add('lib-wordarray-test', function (Y) {
+    var C = CryptoJS;
+
+    if (typeof ArrayBuffer != 'undefined') {
+        Y.Test.Runner.add(new Y.Test.Case({
+            name: 'TypedArrays',
+
+            setUp: function () {
+                this.data = {};
+
+                this.data.buffer = new ArrayBuffer(8);
+
+                var uint8View = new Uint8Array(this.data.buffer);
+                uint8View[0] = 0x01;
+                uint8View[1] = 0x23;
+                uint8View[2] = 0x45;
+                uint8View[3] = 0x67;
+                uint8View[4] = 0x89;
+                uint8View[5] = 0xab;
+                uint8View[6] = 0xcd;
+                uint8View[7] = 0xef;
+            },
+
+            testInt8Array: function () {
+                Y.Assert.areEqual('0123456789abcdef', C.lib.WordArray.create(new Int8Array(this.data.buffer)).toString());
+            },
+
+            testUint8Array: function () {
+                Y.Assert.areEqual('0123456789abcdef', C.lib.WordArray.create(new Uint8Array(this.data.buffer)).toString());
+            },
+
+            testUint8ClampedArray: function () {
+                Y.Assert.areEqual('0123456789abcdef', C.lib.WordArray.create(new Uint8ClampedArray(this.data.buffer)).toString());
+            },
+
+            testInt16Array: function () {
+                Y.Assert.areEqual('0123456789abcdef', C.lib.WordArray.create(new Int16Array(this.data.buffer)).toString());
+            },
+
+            testUint16Array: function () {
+                Y.Assert.areEqual('0123456789abcdef', C.lib.WordArray.create(new Uint16Array(this.data.buffer)).toString());
+            },
+
+            testInt32Array: function () {
+                Y.Assert.areEqual('0123456789abcdef', C.lib.WordArray.create(new Int32Array(this.data.buffer)).toString());
+            },
+
+            testUint32Array: function () {
+                Y.Assert.areEqual('0123456789abcdef', C.lib.WordArray.create(new Uint32Array(this.data.buffer)).toString());
+            },
+
+            testPartialView: function () {
+                Y.Assert.areEqual('456789ab', C.lib.WordArray.create(new Int16Array(this.data.buffer, 2, 2)).toString());
+            }
+        }));
+    }
+}, '$Rev$');
diff --git a/test/lib-wordarray-test.js b/test/lib-wordarray-test.js
new file mode 100644
index 0000000..ab2aead
--- /dev/null
+++ b/test/lib-wordarray-test.js
@@ -0,0 +1,85 @@
+YUI.add('lib-wordarray-test', function (Y) {
+    var C = CryptoJS;
+
+    Y.Test.Runner.add(new Y.Test.Case({
+        name: 'WordArray',
+
+        testInit0: function () {
+            Y.Assert.areEqual('', C.lib.WordArray.create().toString());
+        },
+
+        testInit1: function () {
+            Y.Assert.areEqual('12345678', C.lib.WordArray.create([0x12345678]).toString());
+        },
+
+        testInit2: function () {
+            Y.Assert.areEqual('1234', C.lib.WordArray.create([0x12345678], 2).toString());
+        },
+
+        testToStringPassedEncoder: function () {
+            Y.Assert.areEqual('\x12\x34\x56\x78', C.lib.WordArray.create([0x12345678]).toString(C.enc.Latin1));
+        },
+
+        testToStringDefaultEncoder: function () {
+            Y.Assert.areEqual('12345678', C.lib.WordArray.create([0x12345678]).toString());
+        },
+
+        testConcat3: function () {
+            var wordArray1 = C.lib.WordArray.create([0x12345678], 3);
+            var wordArray2 = C.lib.WordArray.create([0x12345678], 3);
+
+            Y.Assert.areEqual('123456123456', wordArray1.concat(wordArray2).toString());
+            Y.Assert.areEqual('123456123456', wordArray1.toString());
+        },
+
+        testConcat4: function () {
+            var wordArray1 = C.lib.WordArray.create([0x12345678], 4);
+            var wordArray2 = C.lib.WordArray.create([0x12345678], 3);
+
+            Y.Assert.areEqual('12345678123456', wordArray1.concat(wordArray2).toString());
+            Y.Assert.areEqual('12345678123456', wordArray1.toString());
+        },
+
+        testConcat5: function () {
+            var wordArray1 = C.lib.WordArray.create([0x12345678], 5);
+            var wordArray2 = C.lib.WordArray.create([0x12345678], 3);
+
+            Y.Assert.areEqual('1234567800123456', wordArray1.concat(wordArray2).toString());
+            Y.Assert.areEqual('1234567800123456', wordArray1.toString());
+        },
+
+        testConcatLong: function () {
+            var wordArray1 = C.lib.WordArray.create();
+
+            var wordArray2 = C.lib.WordArray.create();
+            var wordArray3 = C.lib.WordArray.create();
+            for (var i = 0; i < 500000; i++) {
+                wordArray2.words[i] = i;
+                wordArray3.words[i] = i;
+            }
+            wordArray2.sigBytes = wordArray3.sigBytes = 500000;
+
+            Y.Assert.areEqual(wordArray2.toString() + wordArray3.toString(), wordArray1.concat(wordArray2.concat(wordArray3)).toString());
+        },
+
+        testClamp: function () {
+            var wordArray = C.lib.WordArray.create([0x12345678, 0x12345678], 3);
+            wordArray.clamp();
+
+            Y.Assert.areEqual([0x12345600].toString(), wordArray.words.toString());
+        },
+
+        testClone: function () {
+            var wordArray = C.lib.WordArray.create([0x12345678]);
+            var clone = wordArray.clone();
+            clone.words[0] = 0;
+
+            Y.Assert.areNotEqual(wordArray.toString(), clone.toString());
+        },
+
+        testRandom: function () {
+            Y.Assert.areNotEqual(C.lib.WordArray.random(8).toString(), C.lib.WordArray.random(8).toString());
+            Y.Assert.areEqual(8, C.lib.WordArray.random(8).sigBytes);
+        }
+    }));
+}, '$Rev$');
diff --git a/test/md5-profile.js b/test/md5-profile.js
new file mode 100644
index 0000000..2747b26
--- /dev/null
+++ b/test/md5-profile.js
@@ -0,0 +1,24 @@
+YUI.add('algo-md5-profile', function (Y) {
+    var C = CryptoJS;
+
+    Y.Profiler.add({
+        name: 'MD5',
+
+        profileSinglePartMessage: function () {
+            var singlePartMessage = '';
+            for (var i = 0; i < 500; i++) {
+                singlePartMessage += '12345678901234567890123456789012345678901234567890';
+            }
+
+            C.algo.MD5.create().finalize(singlePartMessage) + '';
+        },
+
+        profileMultiPartMessage: function () {
+            var md5 = C.algo.MD5.create();
+            for (var i = 0; i < 500; i++) {
+                md5.update('12345678901234567890123456789012345678901234567890');
+            }
+            md5.finalize() + '';
+        }
+    });
+}, '$Rev$');
diff --git a/test/md5-test.js b/test/md5-test.js
new file mode 100644
index 0000000..e27674f
--- /dev/null
+++ b/test/md5-test.js
@@ -0,0 +1,70 @@
+YUI.add('algo-md5-test', function (Y) {
+    var C = CryptoJS;
+
+    Y.Test.Runner.add(new Y.Test.Case({
+        name: 'MD5',
+
+        testVector1: function () {
+            Y.Assert.areEqual('d41d8cd98f00b204e9800998ecf8427e', C.MD5('').toString());
+        },
+
+        testVector2: function () {
+            Y.Assert.areEqual('0cc175b9c0f1b6a831c399e269772661', C.MD5('a').toString());
+        },
+
+        testVector3: function () {
+            Y.Assert.areEqual('900150983cd24fb0d6963f7d28e17f72', C.MD5('abc').toString());
+        },
+
+        testVector4: function () {
+            Y.Assert.areEqual('f96b697d7cb7938d525a2f31aaf161d0', C.MD5('message digest').toString());
+        },
+
+        testVector5: function () {
+            Y.Assert.areEqual('c3fcd3d76192e4007dfb496cca67e13b', C.MD5('abcdefghijklmnopqrstuvwxyz').toString());
+        },
+
+        testVector6: function () {
+            Y.Assert.areEqual('d174ab98d277d9f5a5611c2c9f419d9f', C.MD5('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789').toString());
+        },
+
+        testVector7: function () {
+            Y.Assert.areEqual('57edf4a22be3c955ac49da2e2107b67a', C.MD5('12345678901234567890123456789012345678901234567890123456789012345678901234567890').toString());
+        },
+
+        testUpdateAndLongMessage: function () {
+            var md5 = C.algo.MD5.create();
+            for (var i = 0; i < 100; i++) {
+                md5.update('12345678901234567890123456789012345678901234567890');
+            }
+
+            Y.Assert.areEqual('7d017545e0268a6a12f2b507871d0429', md5.finalize().toString());
+        },
+
+        testClone: function () {
+            var md5 = C.algo.MD5.create();
+
+            Y.Assert.areEqual(C.MD5('a').toString(), md5.update('a').clone().finalize().toString());
+            Y.Assert.areEqual(C.MD5('ab').toString(), md5.update('b').clone().finalize().toString());
+            Y.Assert.areEqual(C.MD5('abc').toString(), md5.update('c').clone().finalize().toString());
+        },
+
+        testInputIntegrity: function () {
+            var message = C.lib.WordArray.create([0x12345678]);
+
+            var expected = message.toString();
+
+            C.MD5(message);
+
+            Y.Assert.areEqual(expected, message.toString());
+        },
+
+        testHelper: function () {
+            Y.Assert.areEqual(C.algo.MD5.create().finalize('').toString(), C.MD5('').toString());
+        },
+
+        testHmacHelper: function () {
+            Y.Assert.areEqual(C.algo.HMAC.create(C.algo.MD5, C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).finalize('Hi There').toString(), C.HmacMD5('Hi There', C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).toString());
+        }
+    }));
+}, '$Rev$');
diff --git a/test/mode-cbc-test.js b/test/mode-cbc-test.js
new file mode 100644
index 0000000..a3e7101
--- /dev/null
+++ b/test/mode-cbc-test.js
@@ -0,0 +1,49 @@
+YUI.add('mode-cbc-test', function (Y) {
+    var C = CryptoJS;
+
+    Y.Test.Runner.add(new Y.Test.Case({
+        name: 'CBC',
+
+        setUp: function () {
+            this.data = {};
+
+            this.data.message = C.lib.WordArray.create([
+                0x00010203, 0x04050607, 0x08090a0b, 0x0c0d0e0f,
+                0x10111213, 0x14151617, 0x18191a1b, 0x1c1d1e1f
+            ]);
+            this.data.key = C.lib.WordArray.create([0x20212223, 0x24252627, 0x28292a2b, 0x2c2d2e2f]);
+            this.data.iv = C.lib.WordArray.create([0x30313233, 0x34353637, 0x38393a3b, 0x3c3d3e3f]);
+        },
+
+        testEncryptor: function () {
+            // Compute expected
+            var expected = this.data.message.clone();
+            var aes = C.algo.AES.createEncryptor(this.data.key);
+
+            // First block XORed with IV, then encrypted
+            for (var i = 0; i < 4; i++) {
+                expected.words[i] ^= this.data.iv.words[i];
+            }
+            aes.encryptBlock(expected.words, 0);
+
+            // Subsequent blocks XORed with previous crypted block, then encrypted
+            for (var i = 4; i < 8; i++) {
+                expected.words[i] ^= expected.words[i - 4];
+            }
+            aes.encryptBlock(expected.words, 4);
+
+            // Compute actual
+            var actual = C.AES.encrypt(this.data.message, this.data.key, { iv: this.data.iv, mode: C.mode.CBC, padding: C.pad.NoPadding }).ciphertext;
+
+            // Test
+            Y.Assert.areEqual(expected.toString(), actual.toString());
+        },
+
+        testDecryptor: function () {
+            var encrypted = C.AES.encrypt(this.data.message, this.data.key, { iv: this.data.iv, mode: C.mode.CBC, padding: C.pad.NoPadding });
+            var decrypted = C.AES.decrypt(encrypted, this.data.key, { iv: this.data.iv, mode: C.mode.CBC, padding: C.pad.NoPadding });
+
+            Y.Assert.areEqual(this.data.message.toString(), decrypted.toString());
+        }
+    }));
+}, '$Rev$');
diff --git a/test/mode-cfb-test.js b/test/mode-cfb-test.js
new file mode 100644
index 0000000..68a7205
--- /dev/null
+++ b/test/mode-cfb-test.js
@@ -0,0 +1,51 @@
+YUI.add('mode-cfb-test', function (Y) {
+    var C = CryptoJS;
+
+    Y.Test.Runner.add(new Y.Test.Case({
+        name: 'CFB',
+
+        setUp: function () {
+            this.data = {};
+
+            this.data.message = C.lib.WordArray.create([
+                0x00010203, 0x04050607, 0x08090a0b, 0x0c0d0e0f,
+                0x10111213, 0x14151617, 0x18191a1b, 0x1c1d1e1f
+            ]);
+            this.data.key = C.lib.WordArray.create([0x20212223, 0x24252627, 0x28292a2b, 0x2c2d2e2f]);
+            this.data.iv = C.lib.WordArray.create([0x30313233, 0x34353637, 0x38393a3b, 0x3c3d3e3f]);
+        },
+
+        testEncryptor: function () {
+            // Compute expected
+            var expected = this.data.message.clone();
+            var aes = C.algo.AES.createEncryptor(this.data.key);
+
+            // First block XORed with encrypted IV
+            var keystream = this.data.iv.words.slice(0);
+            aes.encryptBlock(keystream, 0);
+            for (var i = 0; i < 4; i++) {
+                expected.words[i] ^= keystream[i];
+            }
+
+            // Subsequent blocks XORed with encrypted previous crypted block
+            var keystream = expected.words.slice(0, 4);
+            aes.encryptBlock(keystream, 0);
+            for (var i = 4; i < 8; i++) {
+                expected.words[i] ^= keystream[i % 4];
+            }
+
+            // Compute actual
+            var actual = C.AES.encrypt(this.data.message, this.data.key, { iv: this.data.iv, mode: C.mode.CFB, padding: C.pad.NoPadding }).ciphertext;
+
+            // Test
+            Y.Assert.areEqual(expected.toString(), actual.toString());
+        },
+
+        testDecryptor: function () {
+            var encrypted = C.AES.encrypt(this.data.message, this.data.key, { iv: this.data.iv, mode: C.mode.CFB, padding: C.pad.NoPadding });
+            var decrypted = C.AES.decrypt(encrypted, this.data.key, { iv: this.data.iv, mode: C.mode.CFB, padding: C.pad.NoPadding });
+
+            Y.Assert.areEqual(this.data.message.toString(), decrypted.toString());
+        }
+    }));
+}, '$Rev$');
diff --git a/test/mode-ctr-test.js b/test/mode-ctr-test.js
new file mode 100644
index 0000000..4d78385
--- /dev/null
+++ b/test/mode-ctr-test.js
@@ -0,0 +1,55 @@
+YUI.add('mode-ctr-test', function (Y) {
+    var C = CryptoJS;
+
+    Y.Test.Runner.add(new Y.Test.Case({
+        name: 'CTR',
+
+        setUp: function () {
+            this.data = {};
+
+            this.data.message = C.lib.WordArray.create([
+                0x00010203, 0x04050607, 0x08090a0b, 0x0c0d0e0f,
+                0x10111213, 0x14151617, 0x18191a1b, 0x1c1d1e1f
+            ]);
+            this.data.key = C.lib.WordArray.create([0x20212223, 0x24252627, 0x28292a2b, 0x2c2d2e2f]);
+            this.data.iv = C.lib.WordArray.create([0x30313233, 0x34353637, 0x38393a3b, 0x3c3d3e3f]);
+        },
+
+        testEncryptor: function () {
+            // Compute expected
+            var expected = this.data.message.clone();
+            var aes = C.algo.AES.createEncryptor(this.data.key);
+
+            // Counter initialized with IV
+            var counter = this.data.iv.words.slice(0);
+
+            // First block XORed with encrypted counter
+            var keystream = counter.slice(0);
+            aes.encryptBlock(keystream, 0);
+            for (var i = 0; i < 4; i++) {
+                expected.words[i] ^= keystream[i];
+            }
+
+            // Subsequent blocks XORed with encrypted incremented counter
+            counter[3]++;
+            var keystream = counter.slice(0);
+            aes.encryptBlock(keystream, 0);
+            for (var i = 4; i < 8; i++) {
+                expected.words[i] ^= keystream[i % 4];
+            }
+
+            // Compute actual
+            var actual = C.AES.encrypt(this.data.message, this.data.key, { iv: this.data.iv, mode: C.mode.CTR, padding: C.pad.NoPadding }).ciphertext;
+
+            // Test
+            Y.Assert.areEqual(expected.toString(), actual.toString());
+        },
+
+        testDecryptor: function () {
+            var encrypted = C.AES.encrypt(this.data.message, this.data.key, { iv: this.data.iv, mode: C.mode.CTR, padding: C.pad.NoPadding });
+            var decrypted = C.AES.decrypt(encrypted, this.data.key, { iv: this.data.iv, mode: C.mode.CTR, padding: C.pad.NoPadding });
+
+            Y.Assert.areEqual(this.data.message.toString(), decrypted.toString());
+        }
+    }));
+}, '$Rev$');
diff --git a/test/mode-ecb-test.js b/test/mode-ecb-test.js
new file mode 100644
index 0000000..26156a3
--- /dev/null
+++ b/test/mode-ecb-test.js
@@ -0,0 +1,38 @@
+YUI.add('mode-ecb-test', function (Y) {
+    var C = CryptoJS;
+
+    Y.Test.Runner.add(new Y.Test.Case({
+        name: 'ECB',
+
+        setUp: function () {
+            this.data = {};
+
+            this.data.message = C.lib.WordArray.create([
+                0x00010203, 0x04050607, 0x08090a0b, 0x0c0d0e0f,
+                0x10111213, 0x14151617, 0x18191a1b, 0x1c1d1e1f
+            ]);
+            this.data.key = C.lib.WordArray.create([0x20212223, 0x24252627, 0x28292a2b, 0x2c2d2e2f]);
+        },
+
+        testEncryptor: function () {
+            // Compute expected
+            var expected = this.data.message.clone();
+            var aes = C.algo.AES.createEncryptor(this.data.key);
+            aes.encryptBlock(expected.words, 0);
+            aes.encryptBlock(expected.words, 4);
+
+            // Compute actual
+            var actual = C.AES.encrypt(this.data.message, this.data.key, { mode: C.mode.ECB, padding: C.pad.NoPadding }).ciphertext;
+
+            // Test
+            Y.Assert.areEqual(expected.toString(), actual.toString());
+        },
+
+        testDecryptor: function () {
+            var encrypted = C.AES.encrypt(this.data.message, this.data.key, { mode: C.mode.ECB, padding: C.pad.NoPadding });
+            var decrypted = C.AES.decrypt(encrypted, this.data.key, { mode: C.mode.ECB, padding: C.pad.NoPadding });
+
+            Y.Assert.areEqual(this.data.message.toString(), decrypted.toString());
+        }
+    }));
+}, '$Rev$');
diff --git a/test/mode-ofb-test.js b/test/mode-ofb-test.js
new file mode 100644
index 0000000..f3ad22b
--- /dev/null
+++ b/test/mode-ofb-test.js
@@ -0,0 +1,50 @@
+YUI.add('mode-ofb-test', function (Y) {
+    var C = CryptoJS;
+
+    Y.Test.Runner.add(new Y.Test.Case({
+        name: 'OFB',
+
+        setUp: function () {
+            this.data = {};
+
+            this.data.message = C.lib.WordArray.create([
+                0x00010203, 0x04050607, 0x08090a0b, 0x0c0d0e0f,
+                0x10111213, 0x14151617, 0x18191a1b, 0x1c1d1e1f
+            ]);
+            this.data.key = C.lib.WordArray.create([0x20212223, 0x24252627, 0x28292a2b, 0x2c2d2e2f]);
+            this.data.iv = C.lib.WordArray.create([0x30313233, 0x34353637, 0x38393a3b, 0x3c3d3e3f]);
+        },
+
+        testEncryptor: function () {
+            // Compute expected
+            var expected = this.data.message.clone();
+            var aes = C.algo.AES.createEncryptor(this.data.key);
+
+            // First block XORed with encrypted IV
+            var keystream = this.data.iv.words.slice(0);
+            aes.encryptBlock(keystream, 0);
+            for (var i = 0; i < 4; i++) {
+                expected.words[i] ^= keystream[i];
+            }
+
+            // Subsequent blocks XORed with encrypted previous keystream
+            aes.encryptBlock(keystream, 0);
+            for (var i = 4; i < 8; i++) {
+                expected.words[i] ^= keystream[i % 4];
+            }
+
+            // Compute actual
+            var actual = C.AES.encrypt(this.data.message, this.data.key, { iv: this.data.iv, mode: C.mode.OFB, padding: C.pad.NoPadding }).ciphertext;
+
+            // Test
+            Y.Assert.areEqual(expected.toString(), actual.toString());
+        },
+
+        testDecryptor: function () {
+            var encrypted = C.AES.encrypt(this.data.message, this.data.key, { iv: this.data.iv, mode: C.mode.OFB, padding: C.pad.NoPadding });
+            var decrypted = C.AES.decrypt(encrypted, this.data.key, { iv: this.data.iv, mode: C.mode.OFB, padding: C.pad.NoPadding });
+
+            Y.Assert.areEqual(this.data.message.toString(), decrypted.toString());
+        }
+    }));
+}, '$Rev$');
diff --git a/test/pad-ansix923-test.js b/test/pad-ansix923-test.js
new file mode 100644
index 0000000..158fa3c
--- /dev/null
+++ b/test/pad-ansix923-test.js
@@ -0,0 +1,28 @@
+YUI.add('pad-ansix923-test', function (Y) {
+    var C = CryptoJS;
+
+    Y.Test.Runner.add(new Y.Test.Case({
+        name: 'AnsiX923',
+
+        testPad: function () {
+            var data = C.lib.WordArray.create([0xdddddd00], 3);
+            C.pad.AnsiX923.pad(data, 2);
+
+            Y.Assert.areEqual(C.lib.WordArray.create([0xdddddd00, 0x00000005]).toString(), data.toString());
+        },
+
+        testPadClamp: function () {
+            var data = C.lib.WordArray.create([0xdddddddd, 0xdddddddd], 3);
+            C.pad.AnsiX923.pad(data, 2);
+
+            Y.Assert.areEqual(C.lib.WordArray.create([0xdddddd00, 0x00000005]).toString(), data.toString());
+        },
+
+        testUnpad: function () {
+            var data = C.lib.WordArray.create([0xdddddd00, 0x00000005]);
+            C.pad.AnsiX923.unpad(data);
+
+            Y.Assert.areEqual(C.lib.WordArray.create([0xdddddd00], 3).toString(), data.toString());
+        }
+    }));
+}, '$Rev$');
diff --git a/test/pad-iso10126-test.js b/test/pad-iso10126-test.js
new file mode 100644
index 0000000..d51211e
--- /dev/null
+++ b/test/pad-iso10126-test.js
@@ -0,0 +1,50 @@
+YUI.add('pad-iso10126-test', function (Y) {
+    var C = CryptoJS;
+
+    Y.Test.Runner.add(new Y.Test.Case({
+        name: 'Iso10126',
+
+        setUp: function () {
+            this.data = {};
+
+            // Save original random method
+            this.data.random = C.lib.WordArray.random;
+
+            // Replace random method with one that returns a predictable value
+            C.lib.WordArray.random = function (nBytes) {
+                var words = [];
+                for (var i = 0; i < nBytes; i += 4) {
+                    words.push([0x11223344]);
+                }
+
+                return C.lib.WordArray.create(words, nBytes);
+            };
+        },
+
+        tearDown: function () {
+            // Restore random method
+            C.lib.WordArray.random = this.data.random;
+        },
+
+        testPad: function () {
+            var data = C.lib.WordArray.create([0xdddddd00], 3);
+            C.pad.Iso10126.pad(data, 2);
+
+            Y.Assert.areEqual(C.lib.WordArray.create([0xdddddd11, 0x22334405]).toString(), data.toString());
+        },
+
+        testPadClamp: function () {
+            var data = C.lib.WordArray.create([0xdddddddd, 0xdddddddd], 3);
+            C.pad.Iso10126.pad(data, 2);
+
+            Y.Assert.areEqual(C.lib.WordArray.create([0xdddddd11, 0x22334405]).toString(), data.toString());
+        },
+
+        testUnpad: function () {
+            var data = C.lib.WordArray.create([0xdddddd11, 0x22334405]);
+            C.pad.Iso10126.unpad(data);
+
+            Y.Assert.areEqual(C.lib.WordArray.create([0xdddddd00], 3).toString(), data.toString());
+        }
+    }));
+}, '$Rev$');
diff --git a/test/pad-iso97971-test.js b/test/pad-iso97971-test.js
new file mode 100644
index 0000000..1541eac
--- /dev/null
+++ b/test/pad-iso97971-test.js
@@ -0,0 +1,35 @@
+YUI.add('pad-iso97971-test', function (Y) {
+    var C = CryptoJS;
+
+    Y.Test.Runner.add(new Y.Test.Case({
+        name: 'Iso97971',
+
+        testPad1: function () {
+            var data = C.lib.WordArray.create([0xdddddd00], 3);
+            C.pad.Iso97971.pad(data, 1);
+
+            Y.Assert.areEqual(C.lib.WordArray.create([0xdddddd80]).toString(), data.toString());
+        },
+
+        testPad2: function () {
+            var data = C.lib.WordArray.create([0xdddddd00], 3);
+            C.pad.Iso97971.pad(data, 2);
+
+            Y.Assert.areEqual(C.lib.WordArray.create([0xdddddd80, 0x00000000]).toString(), data.toString());
+        },
+
+        testPadClamp: function () {
+            var data = C.lib.WordArray.create([0xdddddddd, 0xdddddddd], 3);
+            C.pad.Iso97971.pad(data, 2);
+
+            Y.Assert.areEqual(C.lib.WordArray.create([0xdddddd80, 0x00000000]).toString(), data.toString());
+        },
+
+        testUnpad: function () {
+            var data = C.lib.WordArray.create([0xdddddd80, 0x00000000]);
+            C.pad.Iso97971.unpad(data);
+
+            Y.Assert.areEqual(C.lib.WordArray.create([0xdddddd00], 3).toString(), data.toString());
+        }
+    }));
+}, '$Rev$');
diff --git a/test/pad-pkcs7-test.js b/test/pad-pkcs7-test.js
new file mode 100644
index 0000000..6d59947
--- /dev/null
+++ b/test/pad-pkcs7-test.js
@@ -0,0 +1,28 @@
+YUI.add('pad-pkcs7-test', function (Y) {
+    var C = CryptoJS;
+
+    Y.Test.Runner.add(new Y.Test.Case({
+        name: 'Pkcs7',
+
+        testPad: function () {
+            var data = C.lib.WordArray.create([0xdddddd00], 3);
+            C.pad.Pkcs7.pad(data, 2);
+
+            Y.Assert.areEqual(C.lib.WordArray.create([0xdddddd05, 0x05050505]).toString(), data.toString());
+        },
+
+        testPadClamp: function () {
+            var data = C.lib.WordArray.create([0xdddddddd, 0xdddddddd], 3);
+            C.pad.Pkcs7.pad(data, 2);
+
+            Y.Assert.areEqual(C.lib.WordArray.create([0xdddddd05, 0x05050505]).toString(), data.toString());
+        },
+
+        testUnpad: function () {
+            var data = C.lib.WordArray.create([0xdddddd05, 0x05050505]);
+            C.pad.Pkcs7.unpad(data);
+
+            Y.Assert.areEqual(C.lib.WordArray.create([0xdddddd00], 3).toString(), data.toString());
+        }
+    }));
+}, '$Rev$');
diff --git a/test/pad-zeropadding-test.js b/test/pad-zeropadding-test.js
new file mode 100644
index 0000000..6432185
--- /dev/null
+++ b/test/pad-zeropadding-test.js
@@ -0,0 +1,28 @@
+YUI.add('pad-zeropadding-test', function (Y) {
+    var C = CryptoJS;
+
+    Y.Test.Runner.add(new Y.Test.Case({
+        name: 'ZeroPadding',
+
+        testPad: function () {
+            var data = C.lib.WordArray.create([0xdddddd00], 3);
+            C.pad.ZeroPadding.pad(data, 2);
+
+            Y.Assert.areEqual(C.lib.WordArray.create([0xdddddd00, 0x00000000]).toString(), data.toString());
+        },
+
+        testPadClamp: function () {
+            var data = C.lib.WordArray.create([0xdddddddd, 0xdddddddd], 3);
+            C.pad.ZeroPadding.pad(data, 2);
+
+            Y.Assert.areEqual(C.lib.WordArray.create([0xdddddd00, 0x00000000]).toString(), data.toString());
+        },
+
+        testUnpad: function () {
+            var data = C.lib.WordArray.create([0xdddddd00, 0x00000000]);
+            C.pad.ZeroPadding.unpad(data);
+
+            Y.Assert.areEqual(C.lib.WordArray.create([0xdddddd00], 3).toString(), data.toString());
+        }
+    }));
+}, '$Rev$');
diff --git a/test/pbkdf2-profile.js b/test/pbkdf2-profile.js
new file mode 100644
index 0000000..d69e2f1
--- /dev/null
+++ b/test/pbkdf2-profile.js
@@ -0,0 +1,11 @@
+YUI.add('algo-pbkdf2-profile', function (Y) {
+    var C = CryptoJS;
+
+    Y.Profiler.add({
+        name: 'PBKDF2',
+
+        profileKeySize256Iterations20: function () {
+            C.algo.PBKDF2.create({ keySize: 256/32, iterations: 20 }).compute('password', 'ATHENA.MIT.EDUraeburn');
+        }
+    });
+}, '$Rev$');
diff --git a/test/pbkdf2-test.js b/test/pbkdf2-test.js
new file mode 100644
index 0000000..c15f569
--- /dev/null
+++ b/test/pbkdf2-test.js
@@ -0,0 +1,80 @@
+YUI.add('algo-pbkdf2-test', function (Y) {
+    var C = CryptoJS;
+
+    Y.Test.Runner.add(new Y.Test.Case({
+        name: 'PBKDF2',
+
+        testKeySize128: function () {
+            Y.Assert.areEqual('62929ab995a1111c75c37bc562261ea3', C.PBKDF2('password', 'ATHENA.MIT.EDUraeburn', { keySize: 128/32 }).toString());
+        },
+
+        testKeySize256: function () {
+            Y.Assert.areEqual('62929ab995a1111c75c37bc562261ea3fb3cdc7e725c4ca87c03cec5bb7663e1', C.PBKDF2('password', 'ATHENA.MIT.EDUraeburn', { keySize: 256/32 }).toString());
+        },
+
+        testKeySize128Iterations2: function () {
+            Y.Assert.areEqual('262fb72ea65b44ab5ceba7f8c8bfa781', C.PBKDF2('password', 'ATHENA.MIT.EDUraeburn', { keySize: 128/32, iterations: 2 }).toString());
+        },
+
+        testKeySize256Iterations2: function () {
+            Y.Assert.areEqual('262fb72ea65b44ab5ceba7f8c8bfa7815ff9939204eb7357a59a75877d745777', C.PBKDF2('password', 'ATHENA.MIT.EDUraeburn', { keySize: 256/32, iterations: 2 }).toString());
+        },
+
+        testKeySize128Iterations1200: function () {
+            Y.Assert.areEqual('c76a982415f1acc71dc197273c5b6ada', C.PBKDF2('password', 'ATHENA.MIT.EDUraeburn', { keySize: 128/32, iterations: 1200 }).toString());
+        },
+
+        testKeySize256Iterations1200: function () {
+            Y.Assert.areEqual('c76a982415f1acc71dc197273c5b6ada32f62915ed461718aad32843762433fa', C.PBKDF2('password', 'ATHENA.MIT.EDUraeburn', { keySize: 256/32, iterations: 1200 }).toString());
+        },
+
+        testKeySize128Iterations5: function () {
+            Y.Assert.areEqual('74e98b2e9eeddaab3113c1efc6d82b07', C.PBKDF2('password', C.enc.Hex.parse('1234567878563412'), { keySize: 128/32, iterations: 5 }).toString());
+        },
+
+        testKeySize256Iterations5: function () {
+            Y.Assert.areEqual('74e98b2e9eeddaab3113c1efc6d82b073c4860195b3e0737fa21a4778f376321', C.PBKDF2('password', C.enc.Hex.parse('1234567878563412'), { keySize: 256/32, iterations: 5 }).toString());
+        },
+
+        testKeySize128Iterations1200PassPhraseEqualsBlockSize: function () {
+            Y.Assert.areEqual('c1dfb29a4d2f2fb67c6f78d074d66367', C.PBKDF2('XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', 'pass phrase equals block size', { keySize: 128/32, iterations: 1200 }).toString());
+        },
+
+        testKeySize256Iterations1200PassPhraseEqualsBlockSize: function () {
+            Y.Assert.areEqual('c1dfb29a4d2f2fb67c6f78d074d663671e6fd4da1e598572b1fecf256cb7cf61', C.PBKDF2('XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', 'pass phrase equals block size', { keySize: 256/32, iterations: 1200 }).toString());
+        },
+
+        testKeySize128Iterations1200PassPhraseExceedsBlockSize: function () {
+            Y.Assert.areEqual('22344bc4b6e32675a8090f3ea80be01d', C.PBKDF2('XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', 'pass phrase exceeds block size', { keySize: 128/32, iterations: 1200 }).toString());
+        },
+
+        testKeySize256Iterations1200PassPhraseExceedsBlockSize: function () {
+            Y.Assert.areEqual('22344bc4b6e32675a8090f3ea80be01d5f95126a2cddc3facc4a5e6dca04ec58', C.PBKDF2('XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', 'pass phrase exceeds block size', { keySize: 256/32, iterations: 1200 }).toString());
+        },
+
+        testKeySize128Iterations50: function () {
+            Y.Assert.areEqual('44b0781253db3141ac4174af29325818', C.PBKDF2(C.enc.Hex.parse('f09d849e'), 'EXAMPLE.COMpianist', { keySize: 128/32, iterations: 50 }).toString());
+        },
+
+        testKeySize256Iterations50: function () {
+            Y.Assert.areEqual('44b0781253db3141ac4174af29325818584698d507a79f9879033dec308a2b77', C.PBKDF2(C.enc.Hex.parse('f09d849e'), 'EXAMPLE.COMpianist', { keySize: 256/32, iterations: 50 }).toString());
+        },
+
+        testInputIntegrity: function () {
+            var password = C.lib.WordArray.create([0x12345678]);
+            var salt = C.lib.WordArray.create([0x12345678]);
+
+            var expectedPassword = password.toString();
+            var expectedSalt = salt.toString();
+
+            C.PBKDF2(password, salt);
+
+            Y.Assert.areEqual(expectedPassword, password.toString());
+            Y.Assert.areEqual(expectedSalt, salt.toString());
+        },
+
+        testHelper: function () {
+            Y.Assert.areEqual(C.algo.PBKDF2.create({ keySize: 128/32 }).compute('password', 'ATHENA.MIT.EDUraeburn').toString(), C.PBKDF2('password', 'ATHENA.MIT.EDUraeburn', { keySize: 128/32 }).toString());
+        }
+    }));
+}, '$Rev$');
diff --git a/test/profile.html b/test/profile.html
new file mode 100644
index 0000000..65d9fb5
--- /dev/null
+++ b/test/profile.html
@@ -0,0 +1,281 @@
+<!doctype html>
+<html>
+    <head>
+        <meta charset="utf-8">
+        <title>CryptoJS Profile</title>
+
+        <!-- CryptoJS -->
+        <script src="../src/core.js"></script>
+        <script src="../src/x64-core.js"></script>
+        <script src="../src/enc-utf16.js"></script>
+        <script src="../src/enc-base64.js"></script>
+        <script src="../src/md5.js"></script>
+        <script src="../src/sha1.js"></script>
+        <script src="../src/sha256.js"></script>
+        <script src="../src/sha512.js"></script>
+        <script src="../src/sha3.js"></script>
+        <script src="../src/hmac.js"></script>
+        <script src="../src/pbkdf2.js"></script>
+        <script src="../src/evpkdf.js"></script>
+        <script src="../src/cipher-core.js"></script>
+        <script src="../src/mode-cfb.js"></script>
+        <script src="../src/mode-ctr.js"></script>
+        <script src="../src/mode-ofb.js"></script>
+        <script src="../src/mode-ecb.js"></script>
+        <script src="../src/pad-ansix923.js"></script>
+        <script src="../src/pad-iso10126.js"></script>
+        <script src="../src/pad-zeropadding.js"></script>
+        <script src="../src/pad-iso97971.js"></script>
+        <script src="../src/pad-nopadding.js"></script>
+        <script src="../src/rc4.js"></script>
+        <script src="../src/rabbit.js"></script>
+        <script src="../src/aes.js"></script>
+        <script src="../src/tripledes.js"></script>
+
+        <!-- YUI -->
+        <script src="http://yui.yahooapis.com/3.4.1/build/yui/yui-min.js"></script>
+
+        <!-- Profile subjects -->
+        <script src="md5-profile.js"></script>
+        <script src="sha1-profile.js"></script>
+        <script src="sha256-profile.js"></script>
+        <script src="sha512-profile.js"></script>
+        <script src="sha3-profile.js"></script>
+        <script src="hmac-profile.js"></script>
+        <script src="pbkdf2-profile.js"></script>
+        <script src="evpkdf-profile.js"></script>
+        <script src="rc4-profile.js"></script>
+        <script src="rabbit-profile.js"></script>
+        <script src="aes-profile.js"></script>
+        <script src="des-profile.js"></script>
+        <script src="tripledes-profile.js"></script>
+
+        <!-- Profile reports -->
+        <script>
+            YUI().use('profiler', 'console', 'substitute', function (Y) {
+                // Implement Profiler.add
+                Y.Profiler._subjects = [];
+                Y.Profiler.add = function (subject) {
+                    Y.Profiler._subjects.push(subject);
+                };
+                Y.Profiler.getSubjects = function () {
+                    return Y.Profiler._subjects;
+                };
+
+                // Objects to profile
+                var objects = [
+                    'CryptoJS.lib.Base',
+                    'CryptoJS.lib.WordArray',
+
+                    'CryptoJS.x64.Word',
+                    'CryptoJS.x64.WordArray',
+
+                    'CryptoJS.enc.Hex',
+                    'CryptoJS.enc.Latin1',
+                    'CryptoJS.enc.Utf8',
+                    'CryptoJS.enc.Utf16',
+                    'CryptoJS.enc.Base64',
+
+                    'CryptoJS.lib.BufferedBlockAlgorithm',
+                    'CryptoJS.lib.Hasher',
+
+                    'CryptoJS.algo.MD5',
+                    'CryptoJS.algo.SHA1',
+                    'CryptoJS.algo.SHA256',
+                    'CryptoJS.algo.SHA512',
+                    'CryptoJS.algo.SHA3',
+
+                    'CryptoJS.algo.HMAC',
+
+                    'CryptoJS.algo.PBKDF2',
+                    'CryptoJS.algo.EvpKDF',
+
+                    'CryptoJS.lib.Cipher',
+                    'CryptoJS.lib.StreamCipher',
+                    'CryptoJS.lib.BlockCipher',
+                    'CryptoJS.lib.BlockCipherMode',
+                    'CryptoJS.lib.CipherParams',
+                    'CryptoJS.lib.SerializableCipher',
+                    'CryptoJS.lib.PasswordBasedCipher',
+
+                    'CryptoJS.mode.CBC', 'CryptoJS.mode.CBC.Encryptor', 'CryptoJS.mode.CBC.Decryptor',
+                    'CryptoJS.mode.CFB', 'CryptoJS.mode.CFB.Encryptor', 'CryptoJS.mode.CFB.Decryptor',
+                    'CryptoJS.mode.CTR', 'CryptoJS.mode.CTR.Encryptor', 'CryptoJS.mode.CTR.Decryptor',
+                    'CryptoJS.mode.OFB', 'CryptoJS.mode.OFB.Encryptor', 'CryptoJS.mode.OFB.Decryptor',
+                    'CryptoJS.mode.ECB', 'CryptoJS.mode.ECB.Encryptor', 'CryptoJS.mode.ECB.Decryptor',
+
+                    'CryptoJS.pad.Pkcs7',
+                    'CryptoJS.pad.AnsiX923',
+                    'CryptoJS.pad.Iso10126',
+                    'CryptoJS.pad.Iso97971',
+                    'CryptoJS.pad.ZeroPadding',
+                    'CryptoJS.pad.NoPadding',
+
+                    'CryptoJS.format.OpenSSL',
+
+                    'CryptoJS.kdf.OpenSSL',
+
+                    'CryptoJS.algo.RC4',
+                    'CryptoJS.algo.RC4Drop',
+                    'CryptoJS.algo.Rabbit',
+                    'CryptoJS.algo.AES',
+                    'CryptoJS.algo.DES',
+                    'CryptoJS.algo.TripleDES'
+                ];
+
+                function registerObjects() {
+                    for (var i = 0; i < objects.length; i++) {
+                        Y.Profiler.registerObject(objects[i]);
+                    }
+                }
+
+                function unregisterObjects() {
+                    for (var i = 0; i < objects.length; i++) {
+                        Y.Profiler.unregisterObject(objects[i]);
+                    }
+                }
+
+                // Load profile subjects
+                Y.use('*', function (Y) {
+                    // Iterate over profile subjects
+                    var subjects = Y.Profiler.getSubjects();
+                    for (var nSubject = 0; nSubject < subjects.length; nSubject++) {
+                        // Shortcut
+                        var subject = subjects[nSubject];
+
+                        // Iterate over profile subject methods
+                        for (var methodName in subject) {
+                            if (typeof subject[methodName] == 'function' && methodName.indexOf('profile') == 0) {
+                                // Set up
+                                if (subject['setUp']) {
+                                    subject['setUp']();
+                                }
+
+                                // Run
+                                registerObjects();
+                                subject[methodName]();
+                                unregisterObjects();
+
+                                // Tear down
+                                if (subject['tearDown']) {
+                                    subject['tearDown']();
+                                }
+
+                                // Get reports
+                                var reports = Y.Profiler.getFullReport(function (report) {
+                                    // Skip reports with 0 calls
+                                    if ( ! report.calls) {
+                                        return false;
+                                    }
+
+                                    // Create "total" entry
+                                    report.total = 0;
+                                    for (var i = 0; i < report.points.length; i++) {
+                                        report.total += report.points[i];
+                                    }
+
+                                    // Round "avg" entry
+                                    report.avg = Number(report.avg.toFixed(4));
+
+                                    return true;
+                                });
+
+                                // Add name to reports
+                                for (var name in reports) {
+                                    reports[name].name = name;
+                                }
+
+                                // Sort reports by total time
+                                var orderedReports = [];
+                                for (var name in reports) {
+                                    orderedReports.push(reports[name]);
+                                }
+                                orderedReports.sort(function (a, b) {
+                                    return ((b.total - a.total) || (b.calls - a.calls));
+                                });
+
+                                // Create profile source
+                                var source = subject.name + '_' + methodName;
+
+                                // Create console
+                                var yconsole = new Y.Console({
+                                    style: 'block',
+                                    width: '100%',
+                                    height: '600px',
+                                    entryTemplate:
+                                        '<div class="{entry_class} {cat_class} {src_class}">' +
+                                        '    <pre class="{entry_content_class}">{message}</pre>' +
+                                        '</div>',
+                                    strings: {
+                                        title: source,
+                                        pause: 'Pause',
+                                        clear: 'Clear',
+                                        collapse: 'Collapse',
+                                        expand: 'Expand'
+                                    },
+                                    newestOnTop: false,
+                                    render: true
+                                });
+
+                                // Restrict profile sources
+                                (function (yconsole, source) {
+                                    yconsole.on('entry', function (e) {
+                                        if (e.message.source != source) {
+                                            e.preventDefault();
+                                        }
+                                    });
+                                }(yconsole, source));
+
+                                // Collapse doesn't seem to work reliably unless we do it after DOM ready
+                                (function (yconsole) {
+                                    Y.on('domready', function () {
+                                        yconsole.collapse();
+                                    });
+                                }(yconsole));
+
+                                // Log reports
+                                for (var i = 0; i < orderedReports.length; i++) {
+                                    var template =
+                                        '[{total}ms] {name}(): Called {calls} times. ' +
+                                        'Avg: {avg}ms, Min: {min}ms, Max: {max}ms';
+                                    var message = Y.substitute(template, orderedReports[i]);
+
+                                    Y.log(message, 'time', source);
+                                }
+
+                                // Clean slate for next profile subject
+                                Y.Profiler.clear();
+                            }
+                        }
+                    }
+                });
+            });
+        </script>
+
+        <!-- Console -->
+        <style type="text/css">
+            body.yui3-skin-sam .yui3-console {
+                margin: 1em 0;
+            }
+            body.yui3-skin-sam .yui3-console-entry-meta,
+            body.yui3-skin-sam .yui3-console-entry-content {
+                display: inline-block;
+                vertical-align: top;
+            }
+            body.yui3-skin-sam .yui3-console-entry-cat {
+                display: inline-block;
+                width: 35px;
+                text-align: center;
+            }
+            body.yui3-skin-sam .yui3-console-entry {
+                min-height: 0;
+            }
+            body.yui3-skin-sam .yui3-console-ft .yui3-console-filters-categories,
+            body.yui3-skin-sam .yui3-console-ft .yui3-console-filters-sources {
+                display: none;
+            }
+        </style>
+    </head>
+    <body class="yui3-skin-sam">
+    </body>
+</html>
diff --git a/test/rabbit-legacy-test.js b/test/rabbit-legacy-test.js
new file mode 100644
index 0000000..c0f349a
--- /dev/null
+++ b/test/rabbit-legacy-test.js
@@ -0,0 +1,80 @@
+YUI.add('algo-rabbit-legacy-test', function (Y) {
+    var C = CryptoJS;
+
+    Y.Test.Runner.add(new Y.Test.Case({
+        name: 'RabbitLegacy',
+
+        testVector1: function () {
+            Y.Assert.areEqual('02f74a1c26456bf5ecd6a536f05457b1', C.RabbitLegacy.encrypt(C.enc.Hex.parse('00000000000000000000000000000000'), C.enc.Hex.parse('00000000000000000000000000000000')).ciphertext.toString());
+        },
+
+        testVector2: function () {
+            Y.Assert.areEqual('9c51e28784c37fe9a127f63ec8f32d3d', C.RabbitLegacy.encrypt(C.enc.Hex.parse('00000000000000000000000000000000'), C.enc.Hex.parse('dc51c3ac3bfc62f12e3d36fe91281329')).ciphertext.toString());
+        },
+
+        testVector3: function () {
+            Y.Assert.areEqual('9b60d002fd5ceb32accd41a0cd0db10c', C.RabbitLegacy.encrypt(C.enc.Hex.parse('00000000000000000000000000000000'), C.enc.Hex.parse('c09b0043e9e9ab0187e0c73383957415')).ciphertext.toString());
+        },
+
+        testVector4: function () {
+            Y.Assert.areEqual('edb70567375dcd7cd89554f85e27a7c6', C.RabbitLegacy.encrypt(C.enc.Hex.parse('00000000000000000000000000000000'), C.enc.Hex.parse('00000000000000000000000000000000'), { iv: C.enc.Hex.parse('0000000000000000') }).ciphertext.toString());
+        },
+
+        testVector5: function () {
+            Y.Assert.areEqual('6d7d012292ccdce0e2120058b94ecd1f', C.RabbitLegacy.encrypt(C.enc.Hex.parse('00000000000000000000000000000000'), C.enc.Hex.parse('00000000000000000000000000000000'), { iv: C.enc.Hex.parse('597e26c175f573c3') }).ciphertext.toString());
+        },
+
+        testVector6: function () {
+            Y.Assert.areEqual('4d1051a123afb670bf8d8505c8d85a44', C.RabbitLegacy.encrypt(C.enc.Hex.parse('00000000000000000000000000000000'), C.enc.Hex.parse('00000000000000000000000000000000'), { iv: C.enc.Hex.parse('2717f4d21a56eba6') }).ciphertext.toString());
+        },
+
+        testMultiPart: function () {
+            var rabbit = C.algo.RabbitLegacy.createEncryptor(C.enc.Hex.parse('00000000000000000000000000000000'));
+            var ciphertext1 = rabbit.process(C.enc.Hex.parse('000000000000'));
+            var ciphertext2 = rabbit.process(C.enc.Hex.parse('0000000000'));
+            var ciphertext3 = rabbit.process(C.enc.Hex.parse('0000000000'));
+            var ciphertext4 = rabbit.finalize();
+
+            Y.Assert.areEqual('02f74a1c26456bf5ecd6a536f05457b1', ciphertext1.concat(ciphertext2).concat(ciphertext3).concat(ciphertext4).toString());
+        },
+
+        testInputIntegrity: function () {
+            var message = C.enc.Hex.parse('00000000000000000000000000000000');
+            var key = C.enc.Hex.parse('00000000000000000000000000000000');
+            var iv = C.enc.Hex.parse('0000000000000000');
+
+            var expectedMessage = message.toString();
+            var expectedKey = key.toString();
+            var expectedIv = iv.toString();
+
+            C.RabbitLegacy.encrypt(message, key, { iv: iv });
+
+            Y.Assert.areEqual(expectedMessage, message.toString());
+            Y.Assert.areEqual(expectedKey, key.toString());
+            Y.Assert.areEqual(expectedIv, iv.toString());
+        },
+
+        testHelper: function () {
+            // Save original random method
+            var random = C.lib.WordArray.random;
+
+            // Replace random method with one that returns a predictable value
+            C.lib.WordArray.random = function (nBytes) {
+                var words = [];
+                for (var i = 0; i < nBytes; i += 4) {
+                    words.push([0x11223344]);
+                }
+
+                return C.lib.WordArray.create(words, nBytes);
+            };
+
+            // Test
+            Y.Assert.areEqual(C.algo.RabbitLegacy.createEncryptor(C.MD5('Jefe')).finalize('Hi There').toString(), C.RabbitLegacy.encrypt('Hi There', C.MD5('Jefe')).ciphertext.toString());
+            Y.Assert.areEqual(C.lib.SerializableCipher.encrypt(C.algo.RabbitLegacy, 'Hi There', C.MD5('Jefe')).toString(), C.RabbitLegacy.encrypt('Hi There', C.MD5('Jefe')).toString());
+            Y.Assert.areEqual(C.lib.PasswordBasedCipher.encrypt(C.algo.RabbitLegacy, 'Hi There', 'Jefe').toString(), C.RabbitLegacy.encrypt('Hi There', 'Jefe').toString());
+
+            // Restore random method
+            C.lib.WordArray.random = random;
+        }
+    }));
+}, '$Rev$');
diff --git a/test/rabbit-profile.js b/test/rabbit-profile.js
new file mode 100644
index 0000000..2b2dfe2
--- /dev/null
+++ b/test/rabbit-profile.js
@@ -0,0 +1,30 @@
+YUI.add('algo-rabbit-profile', function (Y) {
+    var C = CryptoJS;
+
+    Y.Profiler.add({
+        name: 'Rabbit',
+
+        setUp: function () {
+            this.data = {
+                key: C.enc.Hex.parse('000102030405060708090a0b0c0d0e0f')
+            };
+        },
+
+        profileSinglePartMessage: function () {
+            var singlePartMessage = '';
+            for (var i = 0; i < 500; i++) {
+                singlePartMessage += '12345678901234567890123456789012345678901234567890';
+            }
+
+            C.algo.Rabbit.createEncryptor(this.data.key).finalize(singlePartMessage) + '';
+        },
+
+        profileMultiPartMessage: function () {
+            var rabbit = C.algo.Rabbit.createEncryptor(this.data.key);
+            for (var i = 0; i < 500; i++) {
+                rabbit.process('12345678901234567890123456789012345678901234567890') + '';
+            }
+            rabbit.finalize() + '';
+        }
+    });
+}, '$Rev$');
diff --git a/test/rabbit-test.js b/test/rabbit-test.js
new file mode 100644
index 0000000..2fea36e
--- /dev/null
+++ b/test/rabbit-test.js
@@ -0,0 +1,84 @@
+YUI.add('algo-rabbit-test', function (Y) {
+    var C = CryptoJS;
+
+    Y.Test.Runner.add(new Y.Test.Case({
+        name: 'Rabbit',
+
+        testVector1: function () {
+            Y.Assert.areEqual('02f74a1c26456bf5ecd6a536f05457b1', C.Rabbit.encrypt(C.enc.Hex.parse('00000000000000000000000000000000'), C.enc.Hex.parse('00000000000000000000000000000000')).ciphertext.toString());
+        },
+
+        testVector2: function () {
+            Y.Assert.areEqual('3d02e0c730559112b473b790dee018df', C.Rabbit.encrypt(C.enc.Hex.parse('00000000000000000000000000000000'), C.enc.Hex.parse('c21fcf3881cd5ee8628accb0a9890df8')).ciphertext.toString());
+        },
+
+        testVector3: function () {
+            Y.Assert.areEqual('a3a97abb80393820b7e50c4abb53823d', C.Rabbit.encrypt(C.enc.Hex.parse('00000000000000000000000000000000'), C.enc.Hex.parse('1d272c6a2d8e3dfcac14056b78d633a0')).ciphertext.toString());
+        },
+
+        testVector4: function () {
+            Y.Assert.areEqual('75d186d6bc6905c64f1b2dfdd51f7bfc', C.Rabbit.encrypt(C.enc.Hex.parse('00000000000000000000000000000000'), C.enc.Hex.parse('0053a6f94c9ff24598eb3e91e4378add'), { iv: C.enc.Hex.parse('0d74db42a91077de') }).ciphertext.toString());
+        },
+
+        testVector5: function () {
+            Y.Assert.areEqual('476e2750c73856c93563b5f546f56a6a', C.Rabbit.encrypt(C.enc.Hex.parse('00000000000000000000000000000000'), C.enc.Hex.parse('0558abfe51a4f74a9df04396e93c8fe2'), { iv: C.enc.Hex.parse('167de44bb21980e7') }).ciphertext.toString());
+        },
+
+        testVector6: function () {
+            Y.Assert.areEqual('921fcf4983891365a7dc901924b5e24b', C.Rabbit.encrypt(C.enc.Hex.parse('00000000000000000000000000000000'), C.enc.Hex.parse('0a5db00356a9fc4fa2f5489bee4194e7'), { iv: C.enc.Hex.parse('1f86ed54bb2289f0') }).ciphertext.toString());
+        },
+
+        testVector7: function () {
+            Y.Assert.areEqual('613cb0ba96aff6cacf2a459a102a7f78', C.Rabbit.encrypt(C.enc.Hex.parse('00000000000000000000000000000000'), C.enc.Hex.parse('0f62b5085bae0154a7fa4da0f34699ec'), { iv: C.enc.Hex.parse('288ff65dc42b92f9') }).ciphertext.toString());
+        },
+
+        testMultiPart: function () {
+            var rabbit = C.algo.Rabbit.createEncryptor(C.enc.Hex.parse('00000000000000000000000000000000'));
+            var ciphertext1 = rabbit.process(C.enc.Hex.parse('000000000000'));
+            var ciphertext2 = rabbit.process(C.enc.Hex.parse('0000000000'));
+            var ciphertext3 = rabbit.process(C.enc.Hex.parse('0000000000'));
+            var ciphertext4 = rabbit.finalize();
+
+            Y.Assert.areEqual('02f74a1c26456bf5ecd6a536f05457b1', ciphertext1.concat(ciphertext2).concat(ciphertext3).concat(ciphertext4).toString());
+        },
+
+        testInputIntegrity: function () {
+            var message = C.enc.Hex.parse('00000000000000000000000000000000');
+            var key = C.enc.Hex.parse('00000000000000000000000000000000');
+            var iv = C.enc.Hex.parse('0000000000000000');
+
+            var expectedMessage = message.toString();
+            var expectedKey = key.toString();
+            var expectedIv = iv.toString();
+
+            C.Rabbit.encrypt(message, key, { iv: iv });
+
+            Y.Assert.areEqual(expectedMessage, message.toString());
+            Y.Assert.areEqual(expectedKey, key.toString());
+            Y.Assert.areEqual(expectedIv, iv.toString());
+        },
+
+        testHelper: function () {
+            // Save original random method
+            var random = C.lib.WordArray.random;
+
+            // Replace random method with one that returns a predictable value
+            C.lib.WordArray.random = function (nBytes) {
+                var words = [];
+                for (var i = 0; i < nBytes; i += 4) {
+                    words.push([0x11223344]);
+                }
+
+                return C.lib.WordArray.create(words, nBytes);
+            };
+
+            // Test
+            Y.Assert.areEqual(C.algo.Rabbit.createEncryptor(C.MD5('Jefe')).finalize('Hi There').toString(), C.Rabbit.encrypt('Hi There', C.MD5('Jefe')).ciphertext.toString());
+            Y.Assert.areEqual(C.lib.SerializableCipher.encrypt(C.algo.Rabbit, 'Hi There', C.MD5('Jefe')).toString(), C.Rabbit.encrypt('Hi There', C.MD5('Jefe')).toString());
+            Y.Assert.areEqual(C.lib.PasswordBasedCipher.encrypt(C.algo.Rabbit, 'Hi There', 'Jefe').toString(), C.Rabbit.encrypt('Hi There', 'Jefe').toString());
+
+            // Restore random method
+            C.lib.WordArray.random = random;
+        }
+    }));
+}, '$Rev$');
diff --git a/test/rc4-profile.js b/test/rc4-profile.js
new file mode 100644
index 0000000..8590d1a
--- /dev/null
+++ b/test/rc4-profile.js
@@ -0,0 +1,30 @@
+YUI.add('algo-rc4-profile', function (Y) {
+    var C = CryptoJS;
+
+    Y.Profiler.add({
+        name: 'RC4',
+
+        setUp: function () {
+            this.data = {
+                key: C.enc.Hex.parse('000102030405060708090a0b0c0d0e0f')
+            };
+        },
+
+        profileSinglePartMessage: function () {
+            var singlePartMessage = '';
+            for (var i = 0; i < 500; i++) {
+                singlePartMessage += '12345678901234567890123456789012345678901234567890';
+            }
+
+            C.algo.RC4.createEncryptor(this.data.key).finalize(singlePartMessage) + '';
+        },
+
+        profileMultiPartMessage: function () {
+            var rc4 = C.algo.RC4.createEncryptor(this.data.key);
+            for (var i = 0; i < 500; i++) {
+                rc4.process('12345678901234567890123456789012345678901234567890') + '';
+            }
+            rc4.finalize() + '';
+        }
+    });
+}, '$Rev$');
diff --git a/test/rc4-test.js b/test/rc4-test.js
new file mode 100644
index 0000000..721b676
--- /dev/null
+++ b/test/rc4-test.js
@@ -0,0 +1,68 @@
+YUI.add('algo-rc4-test', function (Y) {
+    var C = CryptoJS;
+
+    Y.Test.Runner.add(new Y.Test.Case({
+        name: 'RC4',
+
+        testVector1: function () {
+            Y.Assert.areEqual('7494c2e7104b0879', C.RC4.encrypt(C.enc.Hex.parse('0000000000000000'), C.enc.Hex.parse('0123456789abcdef')).ciphertext.toString());
+        },
+
+        testVector2: function () {
+            Y.Assert.areEqual('f13829c9de', C.RC4.encrypt(C.enc.Hex.parse('dcee4cf92c'), C.enc.Hex.parse('618a63d2fb')).ciphertext.toString());
+        },
+
+        testDrop: function () {
+            Y.Assert.areEqual(
+                C.RC4.encrypt(C.enc.Hex.parse('00000000000000000000000000000000'), C.enc.Hex.parse('0123456789abcdef')).ciphertext.toString().substr(16),
+                C.RC4Drop.encrypt(C.enc.Hex.parse('0000000000000000'), C.enc.Hex.parse('0123456789abcdef'), { drop: 2 }).ciphertext.toString()
+            );
+        },
+
+        testMultiPart: function () {
+            var rc4 = C.algo.RC4.createEncryptor(C.enc.Hex.parse('0123456789abcdef'));
+            var ciphertext1 = rc4.process(C.enc.Hex.parse('00000000'));
+            var ciphertext2 = rc4.process(C.enc.Hex.parse('0000'));
+            var ciphertext3 = rc4.process(C.enc.Hex.parse('0000'));
+            var ciphertext4 = rc4.finalize();
+
+            Y.Assert.areEqual('7494c2e7104b0879', ciphertext1.concat(ciphertext2).concat(ciphertext3).concat(ciphertext4).toString());
+        },
+
+        testInputIntegrity: function () {
+            var message = C.enc.Hex.parse('0000000000000000');
+            var key = C.enc.Hex.parse('0123456789abcdef');
+
+            var expectedMessage = message.toString();
+            var expectedKey = key.toString();
+
+            C.RC4.encrypt(message, key);
+
+            Y.Assert.areEqual(expectedMessage, message.toString());
+            Y.Assert.areEqual(expectedKey, key.toString());
+        },
+
+        testHelper: function () {
+            // Save original random method
+            var random = C.lib.WordArray.random;
+
+            // Replace random method with one that returns a predictable value
+            C.lib.WordArray.random = function (nBytes) {
+                var words = [];
+                for (var i = 0; i < nBytes; i += 4) {
+                    words.push([0x11223344]);
+                }
+
+                return C.lib.WordArray.create(words, nBytes);
+            };
+
+            // Test
+            Y.Assert.areEqual(C.algo.RC4.createEncryptor(C.SHA256('Jefe')).finalize('Hi There').toString(), C.RC4.encrypt('Hi There', C.SHA256('Jefe')).ciphertext.toString());
+            Y.Assert.areEqual(C.lib.SerializableCipher.encrypt(C.algo.RC4, 'Hi There', C.SHA256('Jefe')).toString(), C.RC4.encrypt('Hi There', C.SHA256('Jefe')).toString());
+            Y.Assert.areEqual(C.lib.PasswordBasedCipher.encrypt(C.algo.RC4, 'Hi There', 'Jefe').toString(), C.RC4.encrypt('Hi There', 'Jefe').toString());
+
+            // Restore random method
+            C.lib.WordArray.random = random;
+        }
+    }));
+}, '$Rev$');
diff --git a/test/ripemd160-test.js b/test/ripemd160-test.js
new file mode 100644
index 0000000..0b4e1f4
--- /dev/null
+++ b/test/ripemd160-test.js
@@ -0,0 +1,19 @@
+YUI.add('algo-ripemd160-test', function (Y) {
+    var C = CryptoJS;
+
+    Y.Test.Runner.add(new Y.Test.Case({
+        name: 'RIPEMD160',
+
+        testVector1: function () {
+            Y.Assert.areEqual('37f332f68db77bd9d7edd4969571ad671cf9dd3b', C.RIPEMD160('The quick brown fox jumps over the lazy dog').toString());
+        },
+
+        testVector2: function () {
+            Y.Assert.areEqual('132072df690933835eb8b6ad0b77e7b6f14acad7', C.RIPEMD160('The quick brown fox jumps over the lazy cog').toString());
+        },
+
+        testVector3: function () {
+            Y.Assert.areEqual('9c1185a5c5e9fc54612808977ee8f548b2258d31', C.RIPEMD160('').toString());
+        }
+    }));
+}, '$Rev$');
diff --git a/test/sha1-profile.js b/test/sha1-profile.js
new file mode 100644
index 0000000..55ce702
--- /dev/null
+++ b/test/sha1-profile.js
@@ -0,0 +1,24 @@
+YUI.add('algo-sha1-profile', function (Y) {
+    var C = CryptoJS;
+
+    Y.Profiler.add({
+        name: 'SHA1',
+
+        profileSinglePartMessage: function () {
+            var singlePartMessage = '';
+            for (var i = 0; i < 500; i++) {
+                singlePartMessage += '12345678901234567890123456789012345678901234567890';
+            }
+
+            C.algo.SHA1.create().finalize(singlePartMessage) + '';
+        },
+
+        profileMultiPartMessage: function () {
+            var sha1 = C.algo.SHA1.create();
+            for (var i = 0; i < 500; i++) {
+                sha1.update('12345678901234567890123456789012345678901234567890');
+            }
+            sha1.finalize() + '';
+        }
+    });
+}, '$Rev$');
diff --git a/test/sha1-test.js b/test/sha1-test.js
new file mode 100644
index 0000000..c1dd472
--- /dev/null
+++ b/test/sha1-test.js
@@ -0,0 +1,70 @@
+YUI.add('algo-sha1-test', function (Y) {
+    var C = CryptoJS;
+
+    Y.Test.Runner.add(new Y.Test.Case({
+        name: 'SHA1',
+
+        testVector1: function () {
+            Y.Assert.areEqual('da39a3ee5e6b4b0d3255bfef95601890afd80709', C.SHA1('').toString());
+        },
+
+        testVector2: function () {
+            Y.Assert.areEqual('86f7e437faa5a7fce15d1ddcb9eaeaea377667b8', C.SHA1('a').toString());
+        },
+
+        testVector3: function () {
+            Y.Assert.areEqual('a9993e364706816aba3e25717850c26c9cd0d89d', C.SHA1('abc').toString());
+        },
+
+        testVector4: function () {
+            Y.Assert.areEqual('c12252ceda8be8994d5fa0290a47231c1d16aae3', C.SHA1('message digest').toString());
+        },
+
+        testVector5: function () {
+            Y.Assert.areEqual('32d10c7b8cf96570ca04ce37f2a19d84240d3a89', C.SHA1('abcdefghijklmnopqrstuvwxyz').toString());
+        },
+
+        testVector6: function () {
+            Y.Assert.areEqual('761c457bf73b14d27e9e9265c46f4b4dda11f940', C.SHA1('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789').toString());
+        },
+
+        testVector7: function () {
+            Y.Assert.areEqual('50abf5706a150990a08b2c5ea40fa0e585554732', C.SHA1('12345678901234567890123456789012345678901234567890123456789012345678901234567890').toString());
+        },
+
+        testUpdateAndLongMessage: function () {
+            var sha1 = C.algo.SHA1.create();
+            for (var i = 0; i < 100; i++) {
+                sha1.update('12345678901234567890123456789012345678901234567890');
+            }
+
+            Y.Assert.areEqual('85e4c4b3933d5553ebf82090409a9d90226d845c', sha1.finalize().toString());
+        },
+
+        testClone: function () {
+            var sha1 = C.algo.SHA1.create();
+
+            Y.Assert.areEqual(C.SHA1('a').toString(), sha1.update('a').clone().finalize().toString());
+            Y.Assert.areEqual(C.SHA1('ab').toString(), sha1.update('b').clone().finalize().toString());
+            Y.Assert.areEqual(C.SHA1('abc').toString(), sha1.update('c').clone().finalize().toString());
+        },
+
+        testInputIntegrity: function () {
+            var message = C.lib.WordArray.create([0x12345678]);
+
+            var expected = message.toString();
+
+            C.SHA1(message);
+
+            Y.Assert.areEqual(expected, message.toString());
+        },
+
+        testHelper: function () {
+            Y.Assert.areEqual(C.algo.SHA1.create().finalize('').toString(), C.SHA1('').toString());
+        },
+
+        testHmacHelper: function () {
+            Y.Assert.areEqual(C.algo.HMAC.create(C.algo.SHA1, C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).finalize('Hi There').toString(), C.HmacSHA1('Hi There', C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).toString());
+        }
+    }));
+}, '$Rev$');
diff --git a/test/sha224-test.js b/test/sha224-test.js
new file mode 100644
index 0000000..e426555
--- /dev/null
+++ b/test/sha224-test.js
@@ -0,0 +1,19 @@
+YUI.add('algo-sha224-test', function (Y) {
+    var C = CryptoJS;
+
+    Y.Test.Runner.add(new Y.Test.Case({
+        name: 'SHA224',
+
+        testVector1: function () {
+            Y.Assert.areEqual('d14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f', C.SHA224('').toString());
+        },
+
+        testVector2: function () {
+            Y.Assert.areEqual('730e109bd7a8a32b1cb9d9a09aa2325d2430587ddbc0c38bad911525', C.SHA224('The quick brown fox jumps over the lazy dog').toString());
+        },
+
+        testVector3: function () {
+            Y.Assert.areEqual('619cba8e8e05826e9b8c519c0a5c68f4fb653e8a3d8aa04bb2c8cd4c', C.SHA224('The quick brown fox jumps over the lazy dog.').toString());
+        }
+    }));
+}, '$Rev$');
diff --git a/test/sha256-profile.js b/test/sha256-profile.js
new file mode 100644
index 0000000..c935dee
--- /dev/null
+++ b/test/sha256-profile.js
@@ -0,0 +1,24 @@
+YUI.add('algo-sha256-profile', function (Y) {
+    var C = CryptoJS;
+
+    Y.Profiler.add({
+        name: 'SHA256',
+
+        profileSinglePartMessage: function () {
+            var singlePartMessage = '';
+            for (var i = 0; i < 500; i++) {
+                singlePartMessage += '12345678901234567890123456789012345678901234567890';
+            }
+
+            C.algo.SHA256.create().finalize(singlePartMessage) + '';
+        },
+
+        profileMultiPartMessage: function () {
+            var sha256 = C.algo.SHA256.create();
+            for (var i = 0; i < 500; i++) {
+                sha256.update('12345678901234567890123456789012345678901234567890');
+            }
+            sha256.finalize() + '';
+        }
+    });
+}, '$Rev$');
diff --git a/test/sha256-test.js b/test/sha256-test.js
new file mode 100644
index 0000000..e98bfaf
--- /dev/null
+++ b/test/sha256-test.js
@@ -0,0 +1,70 @@
+YUI.add('algo-sha256-test', function (Y) {
+    var C = CryptoJS;
+
+    Y.Test.Runner.add(new Y.Test.Case({
+        name: 'SHA256',
+
+        testVector1: function () {
+            Y.Assert.areEqual('e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', C.SHA256('').toString());
+        },
+
+        testVector2: function () {
+            Y.Assert.areEqual('ca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb', C.SHA256('a').toString());
+        },
+
+        testVector3: function () {
+            Y.Assert.areEqual('ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad', C.SHA256('abc').toString());
+        },
+
+        testVector4: function () {
+            Y.Assert.areEqual('f7846f55cf23e14eebeab5b4e1550cad5b509e3348fbc4efa3a1413d393cb650', C.SHA256('message digest').toString());
+        },
+
+        testVector5: function () {
+            Y.Assert.areEqual('71c480df93d6ae2f1efad1447c66c9525e316218cf51fc8d9ed832f2daf18b73', C.SHA256('abcdefghijklmnopqrstuvwxyz').toString());
+        },
+
+        testVector6: function () {
+            Y.Assert.areEqual('db4bfcbd4da0cd85a60c3c37d3fbd8805c77f15fc6b1fdfe614ee0a7c8fdb4c0', C.SHA256('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789').toString());
+        },
+
+        testVector7: function () {
+            Y.Assert.areEqual('f371bc4a311f2b009eef952dd83ca80e2b60026c8e935592d0f9c308453c813e', C.SHA256('12345678901234567890123456789012345678901234567890123456789012345678901234567890').toString());
+        },
+
+        testUpdateAndLongMessage: function () {
+            var sha256 = C.algo.SHA256.create();
+            for (var i = 0; i < 100; i++) {
+                sha256.update('12345678901234567890123456789012345678901234567890');
+            }
+
+            Y.Assert.areEqual('f8146961d9b73d8da49ccd526fca65439cdd5b402f76971556d5f52fd129843e', sha256.finalize().toString());
+        },
+
+        testClone: function () {
+            var sha256 = C.algo.SHA256.create();
+
+            Y.Assert.areEqual(C.SHA256('a').toString(), sha256.update('a').clone().finalize().toString());
+            Y.Assert.areEqual(C.SHA256('ab').toString(), sha256.update('b').clone().finalize().toString());
+            Y.Assert.areEqual(C.SHA256('abc').toString(), sha256.update('c').clone().finalize().toString());
+        },
+
+        testInputIntegrity: function () {
+            var message = C.lib.WordArray.create([0x12345678]);
+
+            var expected = message.toString();
+
+            C.SHA256(message);
+
+            Y.Assert.areEqual(expected, message.toString());
+        },
+
+        testHelper: function () {
+            Y.Assert.areEqual(C.algo.SHA256.create().finalize('').toString(), C.SHA256('').toString());
+        },
+
+        testHmacHelper: function () {
+            Y.Assert.areEqual(C.algo.HMAC.create(C.algo.SHA256, C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).finalize('Hi There').toString(), C.HmacSHA256('Hi There', C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).toString());
+        }
+    }));
+}, '$Rev$');
diff --git a/test/sha3-profile.js b/test/sha3-profile.js
new file mode 100644
index 0000000..85f13da
--- /dev/null
+++ b/test/sha3-profile.js
@@ -0,0 +1,24 @@
+YUI.add('algo-sha3-profile', function (Y) {
+    var C = CryptoJS;
+
+    Y.Profiler.add({
+        name: 'SHA3',
+
+        profileSinglePartMessage: function () {
+            var singlePartMessage = '';
+            for (var i = 0; i < 500; i++) {
+                singlePartMessage += '12345678901234567890123456789012345678901234567890';
+            }
+
+            C.algo.SHA3.create().finalize(singlePartMessage) + '';
+        },
+
+        profileMultiPartMessage: function () {
+            var sha3 = C.algo.SHA3.create();
+            for (var i = 0; i < 500; i++) {
+                sha3.update('12345678901234567890123456789012345678901234567890');
+            }
+            sha3.finalize() + '';
+        }
+    });
+}, '$Rev$');
diff --git a/test/sha3-test.js b/test/sha3-test.js
new file mode 100644
index 0000000..e274900
--- /dev/null
+++ b/test/sha3-test.js
@@ -0,0 +1,69 @@
+YUI.add('algo-sha3-test', function (Y) {
+    var C = CryptoJS;
+
+    Y.Test.Runner.add(new Y.Test.Case({
+        name: 'SHA3',
+
+        testVector1: function () {
+            Y.Assert.areEqual('0eab42de4c3ceb9235fc91acffe746b29c29a8c366b7c60e4e67c466f36a4304c00fa9caf9d87976ba469bcbe06713b435f091ef2769fb160cdab33d3670680e', C.SHA3('', { outputLength: 512 }).toString());
+        },
+
+        testVector2: function () {
+            Y.Assert.areEqual('81950e7096d31d4f22e3db71cac725bf59e81af54c7ca9e6aeee71c010fc5467466312a01aa5c137cfb140646941556796f612c9351268737c7e9a2b9631d1fa', C.SHA3(C.enc.Hex.parse('3a3a819c48efde2ad914fbf00e18ab6bc4f14513ab27d0c178a188b61431e7f5623cb66b23346775d386b50e982c493adbbfc54b9a3cd383382336a1a0b2150a15358f336d03ae18f666c7573d55c4fd181c29e6ccfde63ea35f0adf5885cfc0a3d84a2b2e4dd24496db789e663170cef74798aa1bbcd4574ea0bba40489d764b2f83aadc66b148b4a0cd95246c127d5871c4f11418690a5ddf01246a0c80a43c70088b6183639dcfda4125bd113a8f49ee23ed306faac576c3fb0c1e256671d817fc2534a52f5b439f72e424de376f4c565cca82307dd9ef76da5b7c4eb7e085172e328807c02d011ffbf33785378d79dc266f6a5be6bb0e4a92eceebaeb1'), { outputLength: 512 }).toString());
+        },
+
+        testVector3: function () {
+            Y.Assert.areEqual('2c23146a63a29acf99e73b88f8c24eaa7dc60aa771780ccc006afbfa8fe2479b2dd2b21362337441ac12b515911957ff', C.SHA3('', { outputLength: 384 }).toString());
+        },
+
+        testVector4: function () {
+            Y.Assert.areEqual('6bff1c8405a3fe594e360e3bccea1ebcd509310dc79b9e45c263783d7a5dd662c6789b18bd567dbdda1554f5bee6a860', C.SHA3(C.enc.Hex.parse('3a3a819c48efde2ad914fbf00e18ab6bc4f14513ab27d0c178a188b61431e7f5623cb66b23346775d386b50e982c493adbbfc54b9a3cd383382336a1a0b2150a15358f336d03ae18f666c7573d55c4fd181c29e6ccfde63ea35f0adf5885cfc0a3d84a2b2e4dd24496db789e663170cef74798aa1bbcd4574ea0bba40489d764b2f83aadc66b148b4a0cd95246c127d5871c4f11418690a5ddf01246a0c80a43c70088b6183639dcfda4125bd113a8f49ee23ed306faac576c3fb0c1e256671d817fc2534a52f5b439f72e424de376f4c565cca82307dd9ef76da5b7c4eb7e085172e328807c02d011ffbf33785378d79dc266f6a5be6bb0e4a92eceebaeb1'), { outputLength: 384 }).toString());
+        },
+
+        testVector5: function () {
+            Y.Assert.areEqual('c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470', C.SHA3('', { outputLength: 256 }).toString());
+        },
+
+        testVector6: function () {
+            Y.Assert.areEqual('348fb774adc970a16b1105669442625e6adaa8257a89effdb5a802f161b862ea', C.SHA3(C.enc.Hex.parse('3a3a819c48efde2ad914fbf00e18ab6bc4f14513ab27d0c178a188b61431e7f5623cb66b23346775d386b50e982c493adbbfc54b9a3cd383382336a1a0b2150a15358f336d03ae18f666c7573d55c4fd181c29e6ccfde63ea35f0adf5885cfc0a3d84a2b2e4dd24496db789e663170cef74798aa1bbcd4574ea0bba40489d764b2f83aadc66b148b4a0cd95246c127d5871c4f11418690a5ddf01246a0c80a43c70088b6183639dcfda4125bd113a8f49ee23ed306faac576c3fb0c1e256671d817fc2534a52f5b439f72e424de376f4c565cca82307dd9ef76da5b7c4eb7e085172e328807c02d011ffbf33785378d79dc266f6a5be6bb0e4a92eceebaeb1'), { outputLength: 256 }).toString());
+        },
+
+        testVector7: function () {
+            Y.Assert.areEqual('f71837502ba8e10837bdd8d365adb85591895602fc552b48b7390abd', C.SHA3('', { outputLength: 224 }).toString());
+        },
+
+        testVector8: function () {
+            Y.Assert.areEqual('5af56987ea9cf11fcd0eac5ebc14b037365e9b1123e31cb2dfc7929a', C.SHA3(C.enc.Hex.parse('3a3a819c48efde2ad914fbf00e18ab6bc4f14513ab27d0c178a188b61431e7f5623cb66b23346775d386b50e982c493adbbfc54b9a3cd383382336a1a0b2150a15358f336d03ae18f666c7573d55c4fd181c29e6ccfde63ea35f0adf5885cfc0a3d84a2b2e4dd24496db789e663170cef74798aa1bbcd4574ea0bba40489d764b2f83aadc66b148b4a0cd95246c127d5871c4f11418690a5ddf01246a0c80a43c70088b6183639dcfda4125bd113a8f49ee23ed306faac576c3fb0c1e256671d817fc2534a52f5b439f72e424de376f4c565cca82307dd9ef76da5b7c4eb7e085172e328807c02d011ffbf33785378d79dc266f6a5be6bb0e4a92eceebaeb1'), { outputLength: 224 }).toString());
+        },
+
+        testDefaultOutputLength: function () {
+            Y.Assert.areEqual('0eab42de4c3ceb9235fc91acffe746b29c29a8c366b7c60e4e67c466f36a4304c00fa9caf9d87976ba469bcbe06713b435f091ef2769fb160cdab33d3670680e', C.SHA3('').toString());
+        },
+
+        testClone: function () {
+            var sha3 = C.algo.SHA3.create();
+
+            Y.Assert.areEqual(C.SHA3('a').toString(), sha3.update('a').clone().finalize().toString());
+            Y.Assert.areEqual(C.SHA3('ab').toString(), sha3.update('b').clone().finalize().toString());
+            Y.Assert.areEqual(C.SHA3('abc').toString(), sha3.update('c').clone().finalize().toString());
+        },
+
+        testInputIntegrity: function () {
+            var message = C.lib.WordArray.create([0x12345678]);
+
+            var expected = message.toString();
+
+            C.SHA3(message);
+
+            Y.Assert.areEqual(expected, message.toString());
+        },
+
+        testHelper: function () {
+            Y.Assert.areEqual(C.algo.SHA3.create({ outputLength: 256 }).finalize('').toString(), C.SHA3('', { outputLength: 256 }).toString());
+        },
+
+        testHmacHelper: function () {
+            Y.Assert.areEqual(C.algo.HMAC.create(C.algo.SHA3, C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).finalize('Hi There').toString(), C.HmacSHA3('Hi There', C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).toString());
+        }
+    }));
+}, '$Rev$');
diff --git a/test/sha384-test.js b/test/sha384-test.js
new file mode 100644
index 0000000..b7bdfdc
--- /dev/null
+++ b/test/sha384-test.js
@@ -0,0 +1,54 @@
+YUI.add('algo-sha384-test', function (Y) {
+    var C = CryptoJS;
+
+    Y.Test.Runner.add(new Y.Test.Case({
+        name: 'SHA384',
+
+        testVector1: function () {
+            Y.Assert.areEqual('38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b', C.SHA384('').toString());
+        },
+
+        testVector2: function () {
+            Y.Assert.areEqual('ca737f1014a48f4c0b6dd43cb177b0afd9e5169367544c494011e3317dbf9a509cb1e5dc1e85a941bbee3d7f2afbc9b1', C.SHA384('The quick brown fox jumps over the lazy dog').toString());
+        },
+
+        testVector3: function () {
+            Y.Assert.areEqual('ed892481d8272ca6df370bf706e4d7bc1b5739fa2177aae6c50e946678718fc67a7af2819a021c2fc34e91bdb63409d7', C.SHA384('The quick brown fox jumps over the lazy dog.').toString());
+        },
+
+        testUpdateAndLongMessage: function () {
+            var sha384 = C.algo.SHA384.create();
+            for (var i = 0; i < 100; i++) {
+                sha384.update('12345678901234567890123456789012345678901234567890');
+            }
+
+            Y.Assert.areEqual('297a519246d6f639a4020119e1f03fc8d77171647b2ff75ea4125b7150fed0cdcc93f8dca1c3c6a624d5e88d780d82cd', sha384.finalize().toString());
+        },
+
+        testClone: function () {
+            var sha384 = C.algo.SHA384.create();
+
+            Y.Assert.areEqual(C.SHA384('a').toString(), sha384.update('a').clone().finalize().toString());
+            Y.Assert.areEqual(C.SHA384('ab').toString(), sha384.update('b').clone().finalize().toString());
+            Y.Assert.areEqual(C.SHA384('abc').toString(), sha384.update('c').clone().finalize().toString());
+        },
+
+        testInputIntegrity: function () {
+            var message = C.lib.WordArray.create([0x12345678]);
+
+            var expected = message.toString();
+
+            C.SHA384(message);
+
+            Y.Assert.areEqual(expected, message.toString());
+        },
+
+        testHelper: function () {
+            Y.Assert.areEqual(C.algo.SHA384.create().finalize('').toString(), C.SHA384('').toString());
+        },
+
+        testHmacHelper: function () {
+            Y.Assert.areEqual(C.algo.HMAC.create(C.algo.SHA384, C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).finalize('Hi There').toString(), C.HmacSHA384('Hi There', C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).toString());
+        }
+    }));
+}, '$Rev$');
diff --git a/test/sha512-profile.js b/test/sha512-profile.js
new file mode 100644
index 0000000..c26da6e
--- /dev/null
+++ b/test/sha512-profile.js
@@ -0,0 +1,24 @@
+YUI.add('algo-sha512-profile', function (Y) {
+    var C = CryptoJS;
+
+    Y.Profiler.add({
+        name: 'SHA512',
+
+        profileSinglePartMessage: function () {
+            var singlePartMessage = '';
+            for (var i = 0; i < 500; i++) {
+                singlePartMessage += '12345678901234567890123456789012345678901234567890';
+            }
+
+            C.algo.SHA512.create().finalize(singlePartMessage) + '';
+        },
+
+        profileMultiPartMessage: function () {
+            var sha512 = C.algo.SHA512.create();
+            for (var i = 0; i < 500; i++) {
+                sha512.update('12345678901234567890123456789012345678901234567890');
+            }
+            sha512.finalize() + '';
+        }
+    });
+}, '$Rev$');
diff --git a/test/sha512-test.js b/test/sha512-test.js
new file mode 100644
index 0000000..6761202
--- /dev/null
+++ b/test/sha512-test.js
@@ -0,0 +1,54 @@
+YUI.add('algo-sha512-test', function (Y) {
+    var C = CryptoJS;
+
+    Y.Test.Runner.add(new Y.Test.Case({
+        name: 'SHA512',
+
+        testVector1: function () {
+            Y.Assert.areEqual('cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e', C.SHA512('').toString());
+        },
+
+        testVector2: function () {
+            Y.Assert.areEqual('07e547d9586f6a73f73fbac0435ed76951218fb7d0c8d788a309d785436bbb642e93a252a954f23912547d1e8a3b5ed6e1bfd7097821233fa0538f3db854fee6', C.SHA512('The quick brown fox jumps over the lazy dog').toString());
+        },
+
+        testVector3: function () {
+            Y.Assert.areEqual('91ea1245f20d46ae9a037a989f54f1f790f0a47607eeb8a14d12890cea77a1bbc6c7ed9cf205e67b7f2b8fd4c7dfd3a7a8617e45f3c463d481c7e586c39ac1ed', C.SHA512('The quick brown fox jumps over the lazy dog.').toString());
+        },
+
+        testUpdateAndLongMessage: function () {
+            var sha512 = C.algo.SHA512.create();
+            for (var i = 0; i < 100; i++) {
+                sha512.update('12345678901234567890123456789012345678901234567890');
+            }
+
+            Y.Assert.areEqual('9bc64f37c54606dff234b6607e06683c7ba248558d0ec74a11525d9f59e0be566489cc9413c00ca5e9db705fc52ba71214bcf118f65072fe284af8f8cf9500af', sha512.finalize().toString());
+        },
+
+        testClone: function () {
+            var sha512 = C.algo.SHA512.create();
+
+            Y.Assert.areEqual(C.SHA512('a').toString(), sha512.update('a').clone().finalize().toString());
+            Y.Assert.areEqual(C.SHA512('ab').toString(), sha512.update('b').clone().finalize().toString());
+            Y.Assert.areEqual(C.SHA512('abc').toString(), sha512.update('c').clone().finalize().toString());
+        },
+
+        testInputIntegrity: function () {
+            var message = C.lib.WordArray.create([0x12345678]);
+
+            var expected = message.toString();
+
+            C.SHA512(message);
+
+            Y.Assert.areEqual(expected, message.toString());
+        },
+
+        testHelper: function () {
+            Y.Assert.areEqual(C.algo.SHA512.create().finalize('').toString(), C.SHA512('').toString());
+        },
+
+        testHmacHelper: function () {
+            Y.Assert.areEqual(C.algo.HMAC.create(C.algo.SHA512, C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).finalize('Hi There').toString(), C.HmacSHA512('Hi There', C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).toString());
+        }
+    }));
+}, '$Rev$');
diff --git a/test/test-build.html b/test/test-build.html
new file mode 100644
index 0000000..c6eb05c
--- /dev/null
+++ b/test/test-build.html
@@ -0,0 +1,105 @@
+<!doctype html>
+<html>
+    <head>
+        <meta charset="utf-8">
+        <title>CryptoJS Test Suite</title>
+
+        <!-- CryptoJS -->
+        <script src="../build/crypto-js.js"></script>
+
+        <!-- YUI -->
+        <script src="http://yui.yahooapis.com/3.5.1/build/yui/yui-min.js"></script>
+
+        <!-- Tests -->
+        <script src="lib-base-test.js"></script>
+        <script src="lib-wordarray-test.js"></script>
+        <script src="lib-typedarrays-test.js"></script>
+        <script src="x64-word-test.js"></script>
+        <script src="x64-wordarray-test.js"></script>
+        <script src="enc-hex-test.js"></script>
+        <script src="enc-latin1-test.js"></script>
+        <script src="enc-utf8-test.js"></script>
+        <script src="enc-utf16-test.js"></script>
+        <script src="enc-base64-test.js"></script>
+        <script src="md5-test.js"></script>
+        <script src="sha1-test.js"></script>
+        <script src="sha256-test.js"></script>
+        <script src="sha224-test.js"></script>
+        <script src="sha512-test.js"></script>
+        <script src="sha384-test.js"></script>
+        <script src="sha3-test.js"></script>
+        <script src="ripemd160-test.js"></script>
+        <script src="hmac-md5-test.js"></script>
+        <script src="hmac-sha224-test.js"></script>
+        <script src="hmac-sha256-test.js"></script>
+        <script src="hmac-sha384-test.js"></script>
+        <script src="hmac-sha512-test.js"></script>
+        <script src="pbkdf2-test.js"></script>
+        <script src="evpkdf-test.js"></script>
+        <script src="mode-cbc-test.js"></script>
+        <script src="mode-cfb-test.js"></script>
+        <script src="mode-ctr-test.js"></script>
+        <script src="mode-ofb-test.js"></script>
+        <script src="mode-ecb-test.js"></script>
+        <script src="pad-pkcs7-test.js"></script>
+        <script src="pad-ansix923-test.js"></script>
+        <script src="pad-iso10126-test.js"></script>
+        <script src="pad-zeropadding-test.js"></script>
+        <script src="pad-iso97971-test.js"></script>
+        <script src="lib-cipherparams-test.js"></script>
+        <script src="format-openssl-test.js"></script>
+        <script src="lib-serializablecipher-test.js"></script>
+        <script src="kdf-openssl-test.js"></script>
+        <script src="lib-passwordbasedcipher-test.js"></script>
+        <script src="rc4-test.js"></script>
+        <script src="rabbit-test.js"></script>
+        <script src="rabbit-legacy-test.js"></script>
+        <script src="cipher-test.js"></script>
+        <script src="aes-test.js"></script>
+        <script src="des-test.js"></script>
+        <script src="tripledes-test.js"></script>
+
+        <!-- Test runner -->
+        <script>
+            YUI().use('test', 'console', function (Y) {
+                Y.use('*', function (Y) {
+                    new Y.Console({
+                        style: 'block',
+                        width: '600px',
+                        height: '600px',
+                        entryTemplate:
+                          '<div class="{entry_class} {cat_class} {src_class}">' +
+                          '    <p class="{entry_meta_class}">' +
+                          '        <span class="{entry_cat_class}">{category}</span>' +
+                          '    </p>' +
+                          '    <pre class="{entry_content_class}">{message}</pre>' +
+                          '</div>',
+                        newestOnTop: false,
+                        consoleLimit: 500,
+                        render: true
+                    });
+
+                    Y.Test.Runner.run();
+                });
+            });
+        </script>
+
+        <style>
+            body.yui3-skin-sam .yui3-console-entry-meta,
+            body.yui3-skin-sam .yui3-console-entry-content {
+                display: inline-block;
+                vertical-align: top;
+            }
+            body.yui3-skin-sam .yui3-console-entry-cat {
+                display: inline-block;
+                width: 35px;
+                text-align: center;
+            }
+            body.yui3-skin-sam .yui3-console-entry {
+                min-height: 0;
+            }
+        </style>
+    </head>
+    <body class="yui3-skin-sam">
+    </body>
+</html>
diff --git a/test/test.html b/test/test.html
new file mode 100644
index 0000000..70a0edf
--- /dev/null
+++ b/test/test.html
@@ -0,0 +1,138 @@
+<!doctype html>
+<html>
+    <head>
+        <meta charset="utf-8">
+        <title>CryptoJS Test Suite</title>
+
+        <!-- CryptoJS -->
+        <script src="../src/core.js"></script>
+        <script src="../src/lib-typedarrays.js"></script>
+        <script src="../src/x64-core.js"></script>
+        <script src="../src/enc-utf16.js"></script>
+        <script src="../src/enc-base64.js"></script>
+        <script src="../src/md5.js"></script>
+        <script src="../src/sha1.js"></script>
+        <script src="../src/sha256.js"></script>
+        <script src="../src/sha224.js"></script>
+        <script src="../src/sha512.js"></script>
+        <script src="../src/sha384.js"></script>
+        <script src="../src/sha3.js"></script>
+        <script src="../src/ripemd160.js"></script>
+        <script src="../src/hmac.js"></script>
+        <script src="../src/pbkdf2.js"></script>
+        <script src="../src/evpkdf.js"></script>
+        <script src="../src/cipher-core.js"></script>
+        <script src="../src/mode-cfb.js"></script>
+        <script src="../src/mode-ctr.js"></script>
+        <script src="../src/mode-ofb.js"></script>
+        <script src="../src/mode-ecb.js"></script>
+        <script src="../src/pad-ansix923.js"></script>
+        <script src="../src/pad-iso10126.js"></script>
+        <script src="../src/pad-zeropadding.js"></script>
+        <script src="../src/pad-iso97971.js"></script>
+        <script src="../src/pad-nopadding.js"></script>
+        <script src="../src/rc4.js"></script>
+        <script src="../src/rabbit.js"></script>
+        <script src="../src/rabbit-legacy.js"></script>
+        <script src="../src/aes.js"></script>
+        <script src="../src/blowfish.js"></script>
+        <script src="../src/tripledes.js"></script>
+
+        <!-- YUI -->
+        <script src="http://yui.yahooapis.com/3.5.1/build/yui/yui-min.js"></script>
+
+        <!-- Tests -->
+        <script src="lib-base-test.js"></script>
+        <script src="lib-wordarray-test.js"></script>
+        <script src="lib-typedarrays-test.js"></script>
+        <script src="x64-word-test.js"></script>
+        <script src="x64-wordarray-test.js"></script>
+        <script src="enc-hex-test.js"></script>
+        <script src="enc-latin1-test.js"></script>
+        <script src="enc-utf8-test.js"></script>
+        <script src="enc-utf16-test.js"></script>
+        <script src="enc-base64-test.js"></script>
+        <script src="md5-test.js"></script>
+        <script src="sha1-test.js"></script>
+        <script src="sha256-test.js"></script>
+        <script src="sha224-test.js"></script>
+        <script src="sha512-test.js"></script>
+        <script src="sha384-test.js"></script>
+        <script src="sha3-test.js"></script>
+        <script src="ripemd160-test.js"></script>
+        <script src="hmac-md5-test.js"></script>
+        <script src="hmac-sha224-test.js"></script>
+        <script src="hmac-sha256-test.js"></script>
+        <script src="hmac-sha384-test.js"></script>
+        <script src="hmac-sha512-test.js"></script>
+        <script src="pbkdf2-test.js"></script>
+        <script src="evpkdf-test.js"></script>
+        <script src="mode-cbc-test.js"></script>
+        <script src="mode-cfb-test.js"></script>
+        <script src="mode-ctr-test.js"></script>
+        <script src="mode-ofb-test.js"></script>
+        <script src="mode-ecb-test.js"></script>
+        <script src="pad-pkcs7-test.js"></script>
+        <script src="pad-ansix923-test.js"></script>
+        <script src="pad-iso10126-test.js"></script>
+        <script src="pad-zeropadding-test.js"></script>
+        <script src="pad-iso97971-test.js"></script>
+        <script src="lib-cipherparams-test.js"></script>
+        <script src="format-openssl-test.js"></script>
+        <script src="lib-serializablecipher-test.js"></script>
+        <script src="kdf-openssl-test.js"></script>
+        <script src="lib-passwordbasedcipher-test.js"></script>
+        <script src="rc4-test.js"></script>
+        <script src="rabbit-test.js"></script>
+        <script src="rabbit-legacy-test.js"></script>
+        <script src="cipher-test.js"></script>
+        <script src="aes-test.js"></script>
+        <script src="des-test.js"></script>
+        <script src="tripledes-test.js"></script>
+        <script src="config-test.js"></script>
+        <script src="blowfish-test.js"></script>
+
+        <!-- Test runner -->
+        <script>
+            YUI().use('test', 'console', function (Y) {
+                Y.use('*', function (Y) {
+                    new Y.Console({
+                        style: 'block',
+                        width: '600px',
+                        height: '600px',
+                        entryTemplate:
+                          '<div class="{entry_class} {cat_class} {src_class}">' +
+                          '    <p class="{entry_meta_class}">' +
+                          '        <span class="{entry_cat_class}">{category}</span>' +
+                          '    </p>' +
+                          '    <pre class="{entry_content_class}">{message}</pre>' +
+                          '</div>',
+                        newestOnTop: false,
+                        consoleLimit: 500,
+                        render: true
+                    });
+
+                    Y.Test.Runner.run();
+                });
+            });
+        </script>
+
+        <style>
+            body.yui3-skin-sam .yui3-console-entry-meta,
+            body.yui3-skin-sam .yui3-console-entry-content {
+                display: inline-block;
+                vertical-align: top;
+            }
+            body.yui3-skin-sam .yui3-console-entry-cat {
+                display: inline-block;
+                width: 35px;
+                text-align: center;
+            }
+            body.yui3-skin-sam .yui3-console-entry {
+                min-height: 0;
+            }
+        </style>
+    </head>
+    <body class="yui3-skin-sam">
+    </body>
+</html>
diff --git a/test/test1.html b/test/test1.html
new file mode 100644
index 0000000..731b877
--- /dev/null
+++ b/test/test1.html
@@ -0,0 +1,63 @@
+<!doctype html>
+<html>
+<head>
+    <meta charset="utf-8">
+    <title>CryptoJS Test Suite</title>
+
+    <!-- CryptoJS -->
+    <script src="../src/core.js"></script>
+    <script src="../src/lib-typedarrays.js"></script>
+    <script src="../src/x64-core.js"></script>
+    <script src="../src/enc-utf16.js"></script>
+    <script src="../src/enc-base64.js"></script>
+    <script src="../src/enc-base64url.js"></script>
+    <script src="../src/md5.js"></script>
+    <script src="../src/sha1.js"></script>
+    <script src="../src/sha256.js"></script>
+    <script src="../src/sha224.js"></script>
+    <script src="../src/sha512.js"></script>
+    <script src="../src/sha384.js"></script>
+    <script src="../src/sha3.js"></script>
+    <script src="../src/ripemd160.js"></script>
+    <script src="../src/hmac.js"></script>
+    <script src="../src/pbkdf2.js"></script>
+    <script src="../src/evpkdf.js"></script>
+    <script src="../src/cipher-core.js"></script>
+    <script src="../src/mode-cfb.js"></script>
+    <script src="../src/mode-ctr.js"></script>
+    <script src="../src/mode-ofb.js"></script>
+    <script src="../src/mode-ecb.js"></script>
+    <script src="../src/pad-ansix923.js"></script>
+    <script src="../src/pad-iso10126.js"></script>
+    <script src="../src/pad-zeropadding.js"></script>
+    <script src="../src/pad-iso97971.js"></script>
+    <script src="../src/pad-nopadding.js"></script>
+    <script src="../src/rc4.js"></script>
+    <script src="../src/rabbit.js"></script>
+    <script src="../src/rabbit-legacy.js"></script>
+    <script src="../src/aes.js"></script>
+    <script src="../src/tripledes.js"></script>
+
+
+    <!-- Test runner -->
+    <script>
+      var message = "152999073894506063@http://localhost:3000/protected/index@89effb07-588e-4bf4-ba16-c10b2a136ae9@1553508995647";
+      var key = "u-rXsMB_aegAnzC_CJt27plLGNqOfR2EHI5o2ro1NO";
+      var baseKey = CryptoJS.enc.Base64url.parse(key);
+      console.log("key："+baseKey.toString());
+      var hash = CryptoJS.HmacSHA256(message, baseKey);
+      var hashInBase64 = CryptoJS.enc.Base64url.stringify(hash);
+      document.write(hashInBase64);
+      document.write("\n");
+      var shashInBase64 = CryptoJS.enc.Base64url.stringify(hash);
+      console.log("result："+hash.toString())
+      document.write(shashInBase64);
+      console.log("done："+shashInBase64);
+      var url = 'http://www.ctyun.cn/serviceValidate?service=http://localhost:3000/protected/index&ticket=89effb07-588e-4bf4-ba16-c10b2a136ae9&timestamp=1553508995647&appId=152999073894506063&signature=evvc3Ix87nk-KkuIaQJrLP7Vu76dTsh-BwnC6AHXFfU'
+    </script>
+
+
+</head>
+<body>
+</body>
+</html>
\ No newline at end of file
diff --git a/test/tripledes-profile.js b/test/tripledes-profile.js
new file mode 100644
index 0000000..9ae1828
--- /dev/null
+++ b/test/tripledes-profile.js
@@ -0,0 +1,31 @@
+YUI.add('algo-tripledes-profile', function (Y) {
+    var C = CryptoJS;
+
+    Y.Profiler.add({
+        name: 'TripleDES',
+
+        setUp: function () {
+            this.data = {
+                key: C.enc.Hex.parse('0001020304050607'),
+                iv: C.enc.Hex.parse('08090a0b0c0d0e0f')
+            };
+        },
+
+        profileSinglePartMessage: function () {
+            var singlePartMessage = '';
+            for (var i = 0; i < 100; i++) {
+                singlePartMessage += '12345678901234567890123456789012345678901234567890';
+            }
+
+            C.algo.TripleDES.createEncryptor(this.data.key, { iv: this.data.iv }).finalize(singlePartMessage) + '';
+        },
+
+        profileMultiPartMessage: function () {
+            var des = C.algo.TripleDES.createEncryptor(this.data.key, { iv: this.data.iv });
+            for (var i = 0; i < 100; i++) {
+                des.process('12345678901234567890123456789012345678901234567890') + '';
+            }
+            des.finalize() + '';
+        }
+    });
+}, '$Rev$');
diff --git a/test/tripledes-test.js b/test/tripledes-test.js
new file mode 100644
index 0000000..dcc7f4a
--- /dev/null
+++ b/test/tripledes-test.js
@@ -0,0 +1,121 @@
+YUI.add('algo-tripledes-test', function (Y) {
+    var C = CryptoJS;
+
+    Y.Test.Runner.add(new Y.Test.Case({
+        name: 'TripleDES',
+
+        testEncrypt1: function () {
+            Y.Assert.areEqual('95a8d72813daa94d', C.TripleDES.encrypt(C.enc.Hex.parse('0000000000000000'), C.enc.Hex.parse('800101010101010180010101010101018001010101010101'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).ciphertext.toString());
+        },
+
+        testEncrypt2: function () {
+            Y.Assert.areEqual('869efd7f9f265a09', C.TripleDES.encrypt(C.enc.Hex.parse('0000000000000000'), C.enc.Hex.parse('010101010101010201010101010101020101010101010102'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).ciphertext.toString());
+        },
+
+        testEncrypt3: function () {
+            Y.Assert.areEqual('95f8a5e5dd31d900', C.TripleDES.encrypt(C.enc.Hex.parse('8000000000000000'), C.enc.Hex.parse('010101010101010101010101010101010101010101010101'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).ciphertext.toString());
+        },
+
+        testEncrypt4: function () {
+            Y.Assert.areEqual('166b40b44aba4bd6', C.TripleDES.encrypt(C.enc.Hex.parse('0000000000000001'), C.enc.Hex.parse('010101010101010101010101010101010101010101010101'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).ciphertext.toString());
+        },
+
+        testDecrypt1: function () {
+            Y.Assert.areEqual('0000000000000000', C.TripleDES.decrypt(C.lib.CipherParams.create({ ciphertext: C.enc.Hex.parse('95a8d72813daa94d') }), C.enc.Hex.parse('800101010101010180010101010101018001010101010101'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString());
+        },
+
+        testDecrypt2: function () {
+            Y.Assert.areEqual('0000000000000000', C.TripleDES.decrypt(C.lib.CipherParams.create({ ciphertext: C.enc.Hex.parse('869efd7f9f265a09') }), C.enc.Hex.parse('010101010101010201010101010101020101010101010102'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString());
+        },
+
+        testDecrypt3: function () {
+            Y.Assert.areEqual('8000000000000000', C.TripleDES.decrypt(C.lib.CipherParams.create({ ciphertext: C.enc.Hex.parse('95f8a5e5dd31d900') }), C.enc.Hex.parse('010101010101010101010101010101010101010101010101'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString());
+        },
+
+        testDecrypt4: function () {
+            Y.Assert.areEqual('0000000000000001', C.TripleDES.decrypt(C.lib.CipherParams.create({ ciphertext: C.enc.Hex.parse('166b40b44aba4bd6') }), C.enc.Hex.parse('010101010101010101010101010101010101010101010101'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString());
+        },
+
+        testMultiPart: function () {
+            var des = C.algo.TripleDES.createEncryptor(C.enc.Hex.parse('000102030405060708090a0b0c0d0e0f1011121314151617'), { mode: C.mode.ECB, padding: C.pad.NoPadding });
+            var ciphertext1 = des.process(C.enc.Hex.parse('001122334455'));
+            var ciphertext2 = des.process(C.enc.Hex.parse('66778899aa'));
+            var ciphertext3 = des.process(C.enc.Hex.parse('bbccddeeff'));
+            var ciphertext4 = des.finalize();
+
+            Y.Assert.areEqual(C.TripleDES.encrypt(C.enc.Hex.parse('00112233445566778899aabbccddeeff'), C.enc.Hex.parse('000102030405060708090a0b0c0d0e0f1011121314151617'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).ciphertext.toString(), ciphertext1.concat(ciphertext2).concat(ciphertext3).concat(ciphertext4).toString());
+        },
+
+        testInputIntegrity: function () {
+            var message = C.enc.Hex.parse('00112233445566778899aabbccddeeff');
+            var key = C.enc.Hex.parse('000102030405060708090a0b0c0d0e0f1011121314151617');
+            var iv = C.enc.Hex.parse('08090a0b0c0d0e0f');
+
+            var expectedMessage = message.toString();
+            var expectedKey = key.toString();
+            var expectedIv = iv.toString();
+
+            C.TripleDES.encrypt(message, key, { iv: iv });
+
+            Y.Assert.areEqual(expectedMessage, message.toString());
+            Y.Assert.areEqual(expectedKey, key.toString());
+            Y.Assert.areEqual(expectedIv, iv.toString());
+        },
+
+        test64BitKey: function() {
+            var message = C.enc.Hex.parse('00112233445566778899aabbccddeeff');
+            var key = C.enc.Hex.parse('0011223344556677');
+            var extendedKey = C.enc.Hex.parse('001122334455667700112233445566770011223344556677')
+            
+            var output1 = C.TripleDES.encrypt(message, key, { mode: C.mode.ECB }).toString();
+            var output2 = C.TripleDES.encrypt(message, extendedKey, { mode: C.mode.ECB }).toString();
+
+            Y.Assert.areEqual(output1, output2);
+        },
+
+        test128BitKey: function() {
+            var message = C.enc.Hex.parse('00112233445566778899aabbccddeeff');
+            var key = C.enc.Hex.parse('00112233445566778899aabbccddeeff');
+            var extendedKey = C.enc.Hex.parse('00112233445566778899aabbccddeeff0011223344556677')
+            
+            var output1 = C.TripleDES.encrypt(message, key, { mode: C.mode.ECB }).toString();
+            var output2 = C.TripleDES.encrypt(message, extendedKey, { mode: C.mode.ECB }).toString();
+
+            Y.Assert.areEqual(output1, output2);
+        },
+
+        test256BitKey: function() {
+            var message = C.enc.Hex.parse('00112233445566778899aabbccddeeff');
+            var key = C.enc.Hex.parse('00112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0');
+            var truncatedKey = C.enc.Hex.parse('00112233445566778899aabbccddeeff0112233445566778')
+            
+            var output1 = C.TripleDES.encrypt(message, key, { mode: C.mode.ECB }).toString();
+            var output2 = C.TripleDES.encrypt(message, truncatedKey, { mode: C.mode.ECB }).toString();
+
+            Y.Assert.areEqual(output1, output2);
+        },
+
+        testHelper: function () {
+            // Save original random method
+            var random = C.lib.WordArray.random;
+
+            // Replace random method with one that returns a predictable value
+            C.lib.WordArray.random = function (nBytes) {
+                var words = [];
+                for (var i = 0; i < nBytes; i += 4) {
+                    words.push([0x11223344]);
+                }
+
+                return C.lib.WordArray.create(words, nBytes);
+            };
+
+            // Test
+            Y.Assert.areEqual(C.algo.TripleDES.createEncryptor(C.SHA256('Jefe'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).finalize('Hi There').toString(), C.TripleDES.encrypt('Hi There', C.SHA256('Jefe'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).ciphertext.toString());
+            Y.Assert.areEqual(C.lib.SerializableCipher.encrypt(C.algo.TripleDES, 'Hi There', C.SHA256('Jefe'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString(), C.TripleDES.encrypt('Hi There', C.SHA256('Jefe'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString());
+            Y.Assert.areEqual(C.lib.PasswordBasedCipher.encrypt(C.algo.TripleDES, 'Hi There', 'Jefe', { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString(), C.TripleDES.encrypt('Hi There', 'Jefe', { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString());
+
+            // Restore random method
+            C.lib.WordArray.random = random;
+        }
+    }));
+}, '$Rev$');
diff --git a/test/x64-word-test.js b/test/x64-word-test.js
new file mode 100644
index 0000000..296cf69
--- /dev/null
+++ b/test/x64-word-test.js
@@ -0,0 +1,99 @@
+YUI.add('x64-word-test', function (Y) {
+    var C = CryptoJS;
+
+    Y.Test.Runner.add(new Y.Test.Case({
+        name: 'X64Word',
+
+        testInit: function () {
+            var word = C.x64.Word.create(0x00010203, 0x04050607);
+
+            Y.Assert.areEqual(0x00010203, word.high, 'word.high');
+            Y.Assert.areEqual(0x04050607, word.low, 'word.low');
+        }
+
+        // testNot: function () {
+            // var word = C.x64.Word.create(0x00010203, 0x04050607).not();
+
+            // Y.Assert.areEqual(~0x00010203, word.high, 'word.high');
+            // Y.Assert.areEqual(~0x04050607, word.low, 'word.low');
+        // },
+
+        // testAnd: function () {
+            // var word1 = C.x64.Word.create(0x00010203, 0x04050607);
+            // var word2 = C.x64.Word.create(0x18191a1b, 0x1c1d1e1f);
+            // var anded = word1.and(word2);
+
+            // Y.Assert.areEqual(0x00010203 & 0x18191a1b, anded.high, 'word.high');
+            // Y.Assert.areEqual(0x04050607 & 0x1c1d1e1f, anded.low, 'word.low');
+        // },
+
+        // testOr: function () {
+            // var word1 = C.x64.Word.create(0x00010203, 0x04050607);
+            // var word2 = C.x64.Word.create(0x18191a1b, 0x1c1d1e1f);
+            // var ored = word1.or(word2);
+
+            // Y.Assert.areEqual(0x00010203 | 0x18191a1b, ored.high, 'word.high');
+            // Y.Assert.areEqual(0x04050607 | 0x1c1d1e1f, ored.low, 'word.low');
+        // },
+
+        // testXor: function () {
+            // var word1 = C.x64.Word.create(0x00010203, 0x04050607);
+            // var word2 = C.x64.Word.create(0x18191a1b, 0x1c1d1e1f);
+            // var xored = word1.xor(word2);
+
+            // Y.Assert.areEqual(0x00010203 ^ 0x18191a1b, xored.high, 'word.high');
+            // Y.Assert.areEqual(0x04050607 ^ 0x1c1d1e1f, xored.low, 'word.low');
+        // },
+
+        // testShiftL25: function () {
+            // var word = C.x64.Word.create(0x00010203, 0x04050607).shiftL(25);
+
+            // Y.Assert.areEqual(0x06080a0c, word.high, 'word.high');
+            // Y.Assert.areEqual(0x0e000000, word.low, 'word.low');
+        // },
+
+        // testShiftL32: function () {
+            // var word = C.x64.Word.create(0x00010203, 0x04050607).shiftL(32);
+
+            // Y.Assert.areEqual(0x04050607, word.high, 'word.high');
+            // Y.Assert.areEqual(0x00000000, word.low, 'word.low');
+        // },
+
+        // testShiftR7: function () {
+            // var word = C.x64.Word.create(0x00010203, 0x04050607).shiftR(7);
+
+            // Y.Assert.areEqual(0x00000204, word.high, 'word.high');
+            // Y.Assert.areEqual(0x06080A0C, word.low, 'word.low');
+        // },
+
+        // testShiftR32: function () {
+            // var word = C.x64.Word.create(0x00010203, 0x04050607).shiftR(32);
+
+            // Y.Assert.areEqual(0x00000000, word.high, 'word.high');
+            // Y.Assert.areEqual(0x00010203, word.low, 'word.low');
+        // },
+
+        // testRotL: function () {
+            // var word = C.x64.Word.create(0x00010203, 0x04050607).rotL(25);
+
+            // Y.Assert.areEqual(0x06080a0c, word.high, 'word.high');
+            // Y.Assert.areEqual(0x0e000204, word.low, 'word.low');
+        // },
+
+        // testRotR: function () {
+            // var word = C.x64.Word.create(0x00010203, 0x04050607).rotR(7);
+
+            // Y.Assert.areEqual(0x0e000204, word.high, 'word.high');
+            // Y.Assert.areEqual(0x06080a0c, word.low, 'word.low');
+        // },
+
+        // testAdd: function () {
+            // var word1 = C.x64.Word.create(0x00010203, 0x04050607);
+            // var word2 = C.x64.Word.create(0x18191a1b, 0x1c1d1e1f);
+            // var added = word1.add(word2);
+
+            // Y.Assert.areEqual(0x181a1c1e, added.high, 'word.high');
+            // Y.Assert.areEqual(0x20222426, added.low, 'word.low');
+        // }
+    }));
+}, '$Rev$');
diff --git a/test/x64-wordarray-test.js b/test/x64-wordarray-test.js
new file mode 100644
index 0000000..638b5e8
--- /dev/null
+++ b/test/x64-wordarray-test.js
@@ -0,0 +1,38 @@
+YUI.add('x64-wordarray-test', function (Y) {
+    var C = CryptoJS;
+
+    Y.Test.Runner.add(new Y.Test.Case({
+        name: 'X64WordArray',
+
+        testInit0: function () {
+            Y.Assert.areEqual('', C.x64.WordArray.create().toX32().toString());
+        },
+
+        testInit1: function () {
+            var wordArray = C.x64.WordArray.create([
+                C.x64.Word.create(0x00010203, 0x04050607),
+                C.x64.Word.create(0x18191a1b, 0x1c1d1e1f)
+            ]);
+
+            Y.Assert.areEqual('000102030405060718191a1b1c1d1e1f', wordArray.toX32().toString());
+        },
+
+        testInit2: function () {
+            var wordArray = C.x64.WordArray.create([
+                C.x64.Word.create(0x00010203, 0x04050607),
+                C.x64.Word.create(0x18191a1b, 0x1c1d1e1f)
+            ], 10);
+
+            Y.Assert.areEqual('00010203040506071819', wordArray.toX32().toString());
+        },
+
+        testToX32: function () {
+            var wordArray = C.x64.WordArray.create([
+                C.x64.Word.create(0x00010203, 0x04050607),
+                C.x64.Word.create(0x18191a1b, 0x1c1d1e1f)
+            ], 10);
+
+            Y.Assert.areEqual('00010203040506071819', wordArray.toX32().toString());
+        }
+    }));
+}, '$Rev$');

Fixed code: node_modules
build
.svn
{
  "bitwise": false, // Prohibits the use of bitwise operators (not confuse & with &&)
  "curly": true, // Requires to always put curly braces around blocks in loops and conditionals
  "eqeqeq": false, // Prohibits the use of == and != in favor of === and !==
  "eqnull": true, // Suppresses warnings about == null comparisons
  "immed": true, // Requires immediate invocations to be wrapped in parens e.g. `(function () { } ());`
  "latedef": false, // Prohibits the use of a variable before it was defined
  "newcap": false, // Requires to capitalize names of constructor functions
  "noarg": true, // Prohibits the use of arguments.caller and arguments.callee
  "strict": false, // Requires all functions to run in ECMAScript 5's strict mode
  "undef": true, // Require non-global variables to be declared (prevents global leaks)
  "asi": true, // Suppresses warnings about missing semicolons
  "funcscope": false,
  "shadow": true,
  "expr": true,
  "-W041": true,
  "-W018": true,
  "globals": {
    "CryptoJS": true,
    "escape": true,
    "unescape": true,
    "Int8Array": true,
    "Int16Array": true,
    "Int32Array": true,
    "Uint8Array": true,
    "Uint16Array": true,
    "Uint32Array": true,
    "Uint8ClampedArray": true,
    "ArrayBuffer": true,
    "Float32Array": true,
    "Float64Array": true
  }
}
dist: trusty
sudo: false

language: node_js
node_js:
  - "6"
  - "7"

before_script:
  - npm install -g grunt-cli
  - npm install build

cache:
  directories:
    - "node_modules"
# Contribution

# Git Flow 

The crypto-js project uses [git flow](https://github.com/nvie/gitflow) to manage branches. 
Do your changes on the `develop` or even better on a `feature/*` branch. Don't do any changes on the `master` branch.

# Pull request

Target your pull request on `develop` branch. Other pull request won't be accepted.

# How to build

1. Clone

2. Run

    ```sh
    npm install
    ```

3. Run

    ```sh
    npm run build
    ```
    
4. Check `build` folder
/*jshint node: true*/

'use strict';

var path = require('path');

module.exports = function (grunt) {

    // Load all grunt tasks from node_modules, and config from /grunt/config
    require('load-grunt-config')(grunt, {
        configPath: path.join(process.cwd(), 'grunt/config'),
        config: {
            pkg: grunt.file.readJSON('package.json'),
            meta: {
                cwd: '',
                cwdAll: '**/*',

                source: 'src/',
                sourceAll: 'src/**/*',

                build: 'build/',
                buildAll: 'build/**/*',

                test: 'test/',
                testAll: 'test/**/*',

                npm: 'node_modules/',
                npmAll: 'node_modules/**/*'
            }
        }
    });
    
    

    // Will load the custom tasks
    grunt.loadTasks('./grunt/tasks');

    grunt.registerTask('build', 'Build a bundle', [
        'clean:build',
        'modularize:build',
        'copy:build',
        'update_json:npm',
        'update_json:bower'
    ]);

    grunt.registerTask('default', 'Run code checker', [
        'jsonlint',
        'jshint'
    ]);

};
# License

[The MIT License (MIT)](http://opensource.org/licenses/MIT)

Copyright (c) 2009-2013 Jeff Mott  
Copyright (c) 2013-2016 Evan Vosberg

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
# crypto-js

JavaScript library of crypto standards.

## Discontinued

Active development of CryptoJS has been discontinued. This library is no longer maintained.

Nowadays, NodeJS and modern browsers have a native `Crypto` module. The latest version of CryptoJS already uses the native Crypto module for random number generation, since `Math.random()` is not crypto-safe. Further development of CryptoJS would result in it only being a wrapper of native Crypto. Therefore, development and maintenance has been discontinued, it is time to go for the native `crypto` module.

## Node.js (Install)

Requirements:

- Node.js
- npm (Node.js package manager)

```bash
npm install crypto-js
```

### Usage

ES6 import for typical API call signing use case:

```javascript
import sha256 from 'crypto-js/sha256';
import hmacSHA512 from 'crypto-js/hmac-sha512';
import Base64 from 'crypto-js/enc-base64';

const message, nonce, path, privateKey; // ...
const hashDigest = sha256(nonce + message);
const hmacDigest = Base64.stringify(hmacSHA512(path + hashDigest, privateKey));
```

Modular include:

```javascript
var AES = require("crypto-js/aes");
var SHA256 = require("crypto-js/sha256");
...
console.log(SHA256("Message"));
```

Including all libraries, for access to extra methods:

```javascript
var CryptoJS = require("crypto-js");
console.log(CryptoJS.HmacSHA1("Message", "Key"));
```

## Client (browser)

Requirements:

- Node.js
- Bower (package manager for frontend)

```bash
bower install crypto-js
```

### Usage

Modular include:

```javascript
require.config({
    packages: [
        {
            name: 'crypto-js',
            location: 'path-to/bower_components/crypto-js',
            main: 'index'
        }
    ]
});

require(["crypto-js/aes", "crypto-js/sha256"], function (AES, SHA256) {
    console.log(SHA256("Message"));
});
```

Including all libraries, for access to extra methods:

```javascript
// Above-mentioned will work or use this simple form
require.config({
    paths: {
        'crypto-js': 'path-to/bower_components/crypto-js/crypto-js'
    }
});

require(["crypto-js"], function (CryptoJS) {
    console.log(CryptoJS.HmacSHA1("Message", "Key"));
});
```

### Usage without RequireJS

```html
<script type="text/javascript" src="path-to/bower_components/crypto-js/crypto-js.js"></script>
<script type="text/javascript">
    var encrypted = CryptoJS.AES(...);
    var encrypted = CryptoJS.SHA256(...);
</script>
```

## API

See: https://cryptojs.gitbook.io/docs/

### AES Encryption

#### Plain text encryption

```javascript
var CryptoJS = require("crypto-js");

// Encrypt
var ciphertext = CryptoJS.AES.encrypt('my message', 'secret key 123').toString();

// Decrypt
var bytes  = CryptoJS.AES.decrypt(ciphertext, 'secret key 123');
var originalText = bytes.toString(CryptoJS.enc.Utf8);

console.log(originalText); // 'my message'
```

#### Object encryption

```javascript
var CryptoJS = require("crypto-js");

var data = [{id: 1}, {id: 2}]

// Encrypt
var ciphertext = CryptoJS.AES.encrypt(JSON.stringify(data), 'secret key 123').toString();

// Decrypt
var bytes  = CryptoJS.AES.decrypt(ciphertext, 'secret key 123');
var decryptedData = JSON.parse(bytes.toString(CryptoJS.enc.Utf8));

console.log(decryptedData); // [{id: 1}, {id: 2}]
```

### List of modules


- ```crypto-js/core```
- ```crypto-js/x64-core```
- ```crypto-js/lib-typedarrays```

---

- ```crypto-js/md5```
- ```crypto-js/sha1```
- ```crypto-js/sha256```
- ```crypto-js/sha224```
- ```crypto-js/sha512```
- ```crypto-js/sha384```
- ```crypto-js/sha3```
- ```crypto-js/ripemd160```

---

- ```crypto-js/hmac-md5```
- ```crypto-js/hmac-sha1```
- ```crypto-js/hmac-sha256```
- ```crypto-js/hmac-sha224```
- ```crypto-js/hmac-sha512```
- ```crypto-js/hmac-sha384```
- ```crypto-js/hmac-sha3```
- ```crypto-js/hmac-ripemd160```

---

- ```crypto-js/pbkdf2```

---

- ```crypto-js/aes```
- ```crypto-js/tripledes```
- ```crypto-js/rc4```
- ```crypto-js/rabbit```
- ```crypto-js/rabbit-legacy```
- ```crypto-js/evpkdf```

---

- ```crypto-js/format-openssl```
- ```crypto-js/format-hex```

---

- ```crypto-js/enc-latin1```
- ```crypto-js/enc-utf8```
- ```crypto-js/enc-hex```
- ```crypto-js/enc-utf16```
- ```crypto-js/enc-base64```

---

- ```crypto-js/mode-cfb```
- ```crypto-js/mode-ctr```
- ```crypto-js/mode-ctr-gladman```
- ```crypto-js/mode-ofb```
- ```crypto-js/mode-ecb```

---

- ```crypto-js/pad-pkcs7```
- ```crypto-js/pad-ansix923```
- ```crypto-js/pad-iso10126```
- ```crypto-js/pad-iso97971```
- ```crypto-js/pad-zeropadding```
- ```crypto-js/pad-nopadding```


## Release notes

### 4.1.1

Fix module order in bundled release.

Include the browser field in the released package.json.

### 4.1.0

Added url safe variant of base64 encoding. [357](https://github.com/brix/crypto-js/pull/357)

Avoid webpack to add crypto-browser package. [364](https://github.com/brix/crypto-js/pull/364)

### 4.0.0

This is an update including breaking changes for some environments.

In this version `Math.random()` has been replaced by the random methods of the native crypto module.

For this reason CryptoJS might not run in some JavaScript environments without native crypto module. Such as IE 10 or before or React Native.

### 3.3.0

Rollback, `3.3.0` is the same as `3.1.9-1`.

The move of using native secure crypto module will be shifted to a new `4.x.x` version. As it is a breaking change the impact is too big for a minor release.

### 3.2.1

The usage of the native crypto module has been fixed. The import and access of the native crypto module has been improved.

### 3.2.0

In this version `Math.random()` has been replaced by the random methods of the native crypto module.

For this reason CryptoJS might does not run in some JavaScript environments without native crypto module. Such as IE 10 or before.

If it's absolute required to run CryptoJS in such an environment, stay with `3.1.x` version. Encrypting and decrypting stays compatible. But keep in mind `3.1.x` versions still use `Math.random()` which is cryptographically not secure, as it's not random enough. 

This version came along with `CRITICAL` `BUG`. 

DO NOT USE THIS VERSION! Please, go for a newer version!

### 3.1.x

The `3.1.x` are based on the original CryptoJS, wrapped in CommonJS modules.


<wiki:toc/>

----

= Quick-start Guide =

== Hashers ==

=== The Hasher Algorithms ===

==== MD5 ====

MD5 is a widely used hash function. It's been used in a variety of security applications and is also commonly used to check the integrity of files. Though, MD5 is not collision resistant, and it isn't suitable for applications like SSL certificates or digital signatures that rely on this property.

{{{
<script src="http://crypto-js.googlecode.com/svn/tags/3.1/build/rollups/md5.js"></script>
<script>
    var hash = CryptoJS.MD5("Message");
</script>
}}}

==== SHA-1 ====

The SHA hash functions were designed by the National Security Agency (NSA). SHA-1 is the most established of the existing SHA hash functions, and it's used in a variety of security applications and protocols. Though, SHA-1's collision resistance has been weakening as new attacks are discovered or improved.

{{{
<script src="http://crypto-js.googlecode.com/svn/tags/3.1/build/rollups/sha1.js"></script>
<script>
    var hash = CryptoJS.SHA1("Message");
</script>
}}}

==== SHA-2 ====

SHA-256 is one of the four variants in the SHA-2 set. It isn't as widely used as SHA-1, though it appears to provide much better security.

{{{
<script src="http://crypto-js.googlecode.com/svn/tags/3.1/build/rollups/sha256.js"></script>
<script>
    var hash = CryptoJS.SHA256("Message");
</script>
}}}

SHA-512 is largely identical to SHA-256 but operates on 64-bit words rather than 32.

{{{
<script src="http://crypto-js.googlecode.com/svn/tags/3.1/build/rollups/sha512.js"></script>
<script>
    var hash = CryptoJS.SHA512("Message");
</script>
}}}

CryptoJS also supports SHA-224 and SHA-384, which are largely identical but truncated versions of SHA-256 and SHA-512 respectively.

==== SHA-3 ====

SHA-3 is the winner of a five-year competition to select a new cryptographic hash algorithm where 64 competing designs were evaluated.

{{{
<script src="http://crypto-js.googlecode.com/svn/tags/3.1/build/rollups/sha3.js"></script>
<script>
    var hash = CryptoJS.SHA3("Message");
</script>
}}}

SHA-3 can be configured to output hash lengths of one of 224, 256, 384, or 512 bits. The default is 512 bits.

{{{
<script src="http://crypto-js.googlecode.com/svn/tags/3.1/build/rollups/sha3.js"></script>
<script>
    var hash = CryptoJS.SHA3("Message", { outputLength: 512 });
    var hash = CryptoJS.SHA3("Message", { outputLength: 384 });
    var hash = CryptoJS.SHA3("Message", { outputLength: 256 });
    var hash = CryptoJS.SHA3("Message", { outputLength: 224 });
</script>
}}}

==== RIPEMD-160 ====

{{{
<script src="http://crypto-js.googlecode.com/svn/tags/3.1/build/rollups/ripemd160.js"></script>
<script>
    var hash = CryptoJS.RIPEMD160("Message");
</script>
}}}

=== The Hasher Input ===

The hash algorithms accept either strings or instances of CryptoJS.lib.WordArray. A WordArray object represents an array of 32-bit words. When you pass a string, it's automatically converted to a WordArray encoded as UTF-8.

=== The Hasher Output ===

The hash you get back isn't a string yet. It's a WordArray object. When you use a WordArray object in a string context, it's automatically converted to a hex string.

{{{
<script src="http://crypto-js.googlecode.com/svn/tags/3.1/build/rollups/sha256.js"></script>
<script>
    var hash = CryptoJS.SHA256("Message");

    alert(typeof hash); // object

    alert(hash); // 2f77668a9dfbf8d5848b9eeb4a7145ca94c6ed9236e4a773f6dcafa5132b2f91
</script>
}}}

You can convert a WordArray object to other formats by explicitly calling the toString method and passing an encoder.

{{{
<script src="http://crypto-js.googlecode.com/svn/tags/3.1/build/rollups/sha256.js"></script>
<script src="http://crypto-js.googlecode.com/svn/tags/3.1/build/components/enc-base64-min.js"></script>
<script>
    var hash = CryptoJS.SHA256("Message");

    alert(hash.toString(CryptoJS.enc.Base64)); // L3dmip37+NWEi57rSnFFypTG7ZI25Kdz9tyvpRMrL5E=

    alert(hash.toString(CryptoJS.enc.Latin1)); // /wf��ûøÕ���ëJqEÊ�Æí�6ä§söÜ¯¥+/�

    alert(hash.toString(CryptoJS.enc.Hex)); // 2f77668a9dfbf8d5848b9eeb4a7145ca94c6ed9236e4a773f6dcafa5132b2f91
</script>
}}}

=== Progressive Hashing ===

{{{
<script src="http://crypto-js.googlecode.com/svn/tags/3.1/build/rollups/sha256.js"></script>
<script>
    var sha256 = CryptoJS.algo.SHA256.create();

    sha256.update("Message Part 1");
    sha256.update("Message Part 2");
    sha256.update("Message Part 3");

    var hash = sha256.finalize();
</script>
}}}

== HMAC ==

Keyed-hash message authentication codes (HMAC) is a mechanism for message authentication using cryptographic hash functions.

HMAC can be used in combination with any iterated cryptographic hash function.

{{{
<script src="http://crypto-js.googlecode.com/svn/tags/3.1/build/rollups/hmac-md5.js"></script>
<script src="http://crypto-js.googlecode.com/svn/tags/3.1/build/rollups/hmac-sha1.js"></script>
<script src="http://crypto-js.googlecode.com/svn/tags/3.1/build/rollups/hmac-sha256.js"></script>
<script src="http://crypto-js.googlecode.com/svn/tags/3.1/build/rollups/hmac-sha512.js"></script>
<script>
    var hash = CryptoJS.HmacMD5("Message", "Secret Passphrase");
    var hash = CryptoJS.HmacSHA1("Message", "Secret Passphrase");
    var hash = CryptoJS.HmacSHA256("Message", "Secret Passphrase");
    var hash = CryptoJS.HmacSHA512("Message", "Secret Passphrase");
</script>
}}}

=== Progressive HMAC Hashing ===

{{{
<script src="http://crypto-js.googlecode.com/svn/tags/3.1/build/rollups/hmac-sha256.js"></script>
<script>
    var hmac = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA256, "Secret Passphrase");

    hmac.update("Message Part 1");
    hmac.update("Message Part 2");
    hmac.update("Message Part 3");

    var hash = hmac.finalize();
</script>
}}}

== PBKDF2 ==

PBKDF2 is a password-based key derivation function. In many applications of cryptography, user security is ultimately dependent on a password, and because a password usually can't be used directly as a cryptographic key, some processing is required.

A salt provides a large set of keys for any given password, and an iteration count increases the cost of producing keys from a password, thereby also increasing the difficulty of attack.

{{{
<script src="http://crypto-js.googlecode.com/svn/tags/3.1/build/rollups/pbkdf2.js"></script>
<script>
    var salt = CryptoJS.lib.WordArray.random(128/8);

    var key128Bits = CryptoJS.PBKDF2("Secret Passphrase", salt, { keySize: 128/32 });
    var key256Bits = CryptoJS.PBKDF2("Secret Passphrase", salt, { keySize: 256/32 });
    var key512Bits = CryptoJS.PBKDF2("Secret Passphrase", salt, { keySize: 512/32 });

    var key512Bits1000Iterations = CryptoJS.PBKDF2("Secret Passphrase", salt, { keySize: 512/32, iterations: 1000 });
</script>
}}}

== Ciphers ==

=== The Cipher Algorithms ===

==== AES ====

The Advanced Encryption Standard (AES) is a U.S. Federal Information Processing Standard (FIPS). It was selected after a 5-year process where 15 competing designs were evaluated.

{{{
<script src="http://crypto-js.googlecode.com/svn/tags/3.1/build/rollups/aes.js"></script>
<script>
    var encrypted = CryptoJS.AES.encrypt("Message", "Secret Passphrase");

    var decrypted = CryptoJS.AES.decrypt(encrypted, "Secret Passphrase");
</script>
}}}

CryptoJS supports AES-128, AES-192, and AES-256. It will pick the variant by the size of the key you pass in. If you use a passphrase, then it will generate a 256-bit key.

==== DES, Triple DES ====

DES is a previously dominant algorithm for encryption, and was published as an official Federal Information Processing Standard (FIPS). DES is now considered to be insecure due to the small key size.

{{{
<script src="http://crypto-js.googlecode.com/svn/tags/3.1/build/rollups/tripledes.js"></script>
<script>
    var encrypted = CryptoJS.DES.encrypt("Message", "Secret Passphrase");

    var decrypted = CryptoJS.DES.decrypt(encrypted, "Secret Passphrase");
</script>
}}}

Triple DES applies DES three times to each block to increase the key size. The algorithm is believed to be secure in this form.

{{{
<script src="http://crypto-js.googlecode.com/svn/tags/3.1/build/rollups/tripledes.js"></script>
<script>
    var encrypted = CryptoJS.TripleDES.encrypt("Message", "Secret Passphrase");

    var decrypted = CryptoJS.TripleDES.decrypt(encrypted, "Secret Passphrase");
</script>
}}}

==== Rabbit ====

Rabbit is a high-performance stream cipher and a finalist in the eSTREAM Portfolio. It is one of the four designs selected after a 3 1/2-year process where 22 designs were evaluated.

{{{
<script src="http://crypto-js.googlecode.com/svn/tags/3.1/build/rollups/rabbit.js"></script>
<script>
    var encrypted = CryptoJS.Rabbit.encrypt("Message", "Secret Passphrase");

    var decrypted = CryptoJS.Rabbit.decrypt(encrypted, "Secret Passphrase");
</script>
}}}

==== RC4, RC4Drop ====

RC4 is a widely-used stream cipher. It's used in popular protocols such as SSL and WEP. Although remarkable for its simplicity and speed, the algorithm's history doesn't inspire confidence in its security.

{{{
<script src="http://crypto-js.googlecode.com/svn/tags/3.1/build/rollups/rc4.js"></script>
<script>
    var encrypted = CryptoJS.RC4.encrypt("Message", "Secret Passphrase");

    var decrypted = CryptoJS.RC4.decrypt(encrypted, "Secret Passphrase");
</script>
}}}

It was discovered that the first few bytes of keystream are strongly non-random and leak information about the key. We can defend against this attack by discarding the initial portion of the keystream. This modified algorithm is traditionally called RC4-drop.

By default, 192 words (768 bytes) are dropped, but you can configure the algorithm to drop any number of words.

{{{
<script src="http://crypto-js.googlecode.com/svn/tags/3.1/build/rollups/rc4.js"></script>
<script>
    var encrypted = CryptoJS.RC4Drop.encrypt("Message", "Secret Passphrase");

    var encrypted = CryptoJS.RC4Drop.encrypt("Message", "Secret Passphrase", { drop: 3072/4 });

    var decrypted = CryptoJS.RC4Drop.decrypt(encrypted, "Secret Passphrase", { drop: 3072/4 });
</script>
}}}

=== Custom Key and IV ===

{{{
<script src="http://crypto-js.googlecode.com/svn/tags/3.1/build/rollups/aes.js"></script>
<script>
    var key = CryptoJS.enc.Hex.parse('000102030405060708090a0b0c0d0e0f');
    var iv  = CryptoJS.enc.Hex.parse('101112131415161718191a1b1c1d1e1f');

    var encrypted = CryptoJS.AES.encrypt("Message", key, { iv: iv });
</script>
}}}

=== Block Modes and Padding ===

{{{
<script src="http://crypto-js.googlecode.com/svn/tags/3.1/build/rollups/aes.js"></script>
<script src="http://crypto-js.googlecode.com/svn/tags/3.1/build/components/mode-cfb-min.js"></script>
<script src="http://crypto-js.googlecode.com/svn/tags/3.1/build/components/pad-ansix923-min.js"></script>
<script>
    var encrypted = CryptoJS.AES.encrypt("Message", "Secret Passphrase", { mode: CryptoJS.mode.CFB, padding: CryptoJS.pad.AnsiX923 });
</script>
}}}

CryptoJS supports the following modes:

  * CBC (the default)
  * CFB
  * CTR
  * OFB
  * ECB

And CryptoJS supports the following padding schemes:

  * Pkcs7 (the default)
  * Iso97971
  * AnsiX923
  * Iso10126
  * ZeroPadding
  * NoPadding

=== The Cipher Input ===

For the plaintext message, the cipher algorithms accept either strings or instances of CryptoJS.lib.WordArray.

For the key, when you pass a string, it's treated as a passphrase and used to derive an actual key and IV. Or you can pass a WordArray that represents the actual key. If you pass the actual key, you must also pass the actual IV.

For the ciphertext, the cipher algorithms accept either strings or instances of CryptoJS.lib.CipherParams. A CipherParams object represents a collection of parameters such as the IV, a salt, and the raw ciphertext itself. When you pass a string, it's automatically converted to a CipherParams object according to a configurable format strategy.

=== The Cipher Output ===

The plaintext you get back after decryption is a WordArray object. See Hashers' Output for more detail.

The ciphertext you get back after encryption isn't a string yet. It's a CipherParams object. A CipherParams object gives you access to all the parameters used during encryption. When you use a CipherParams object in a string context, it's automatically converted to a string according to a format strategy. The default is an OpenSSL-compatible format.

{{{
<script src="http://crypto-js.googlecode.com/svn/tags/3.1/build/rollups/aes.js"></script>
<script>
    var encrypted = CryptoJS.AES.encrypt("Message", "Secret Passphrase");

    alert(encrypted.key);        // 74eb593087a982e2a6f5dded54ecd96d1fd0f3d44a58728cdcd40c55227522223
    alert(encrypted.iv);         // 7781157e2629b094f0e3dd48c4d786115
    alert(encrypted.salt);       // 7a25f9132ec6a8b34
    alert(encrypted.ciphertext); // 73e54154a15d1beeb509d9e12f1e462a0

    alert(encrypted);            // U2FsdGVkX1+iX5Ey7GqLND5UFUoV0b7rUJ2eEvHkYqA=
</script>
}}}

You can define your own formats in order to be compatible with other crypto implementations. A format is an object with two methods—stringify and parse—that converts between CipherParams objects and ciphertext strings.

Here's how you might write a JSON formatter:

{{{
<script src="http://crypto-js.googlecode.com/svn/tags/3.1/build/rollups/aes.js"></script>
<script>
    var JsonFormatter = {
        stringify: function (cipherParams) {
            // create json object with ciphertext
            var jsonObj = {
                ct: cipherParams.ciphertext.toString(CryptoJS.enc.Base64)
            };

            // optionally add iv and salt
            if (cipherParams.iv) {
                jsonObj.iv = cipherParams.iv.toString();
            }
            if (cipherParams.salt) {
                jsonObj.s = cipherParams.salt.toString();
            }

            // stringify json object
            return JSON.stringify(jsonObj);
        },

        parse: function (jsonStr) {
            // parse json string
            var jsonObj = JSON.parse(jsonStr);

            // extract ciphertext from json object, and create cipher params object
            var cipherParams = CryptoJS.lib.CipherParams.create({
                ciphertext: CryptoJS.enc.Base64.parse(jsonObj.ct)
            });

            // optionally extract iv and salt
            if (jsonObj.iv) {
                cipherParams.iv = CryptoJS.enc.Hex.parse(jsonObj.iv)
            }
            if (jsonObj.s) {
                cipherParams.salt = CryptoJS.enc.Hex.parse(jsonObj.s)
            }

            return cipherParams;
        }
    };

    var encrypted = CryptoJS.AES.encrypt("Message", "Secret Passphrase", { format: JsonFormatter });

    alert(encrypted); // {"ct":"tZ4MsEnfbcDOwqau68aOrQ==","iv":"8a8c8fd8fe33743d3638737ea4a00698","s":"ba06373c8f57179c"}

    var decrypted = CryptoJS.AES.decrypt(encrypted, "Secret Passphrase", { format: JsonFormatter });

    alert(decrypted.toString(CryptoJS.enc.Utf8)); // Message
</script>
}}}

=== Progressive Ciphering ===

{{{
<script src="http://crypto-js.googlecode.com/svn/tags/3.1/build/rollups/aes.js"></script>
<script>
    var key = CryptoJS.enc.Hex.parse('000102030405060708090a0b0c0d0e0f');
    var iv  = CryptoJS.enc.Hex.parse('101112131415161718191a1b1c1d1e1f');

    var aesEncryptor = CryptoJS.algo.AES.createEncryptor(key, { iv: iv });

    var ciphertextPart1 = aesEncryptor.process("Message Part 1");
    var ciphertextPart2 = aesEncryptor.process("Message Part 2");
    var ciphertextPart3 = aesEncryptor.process("Message Part 3");
    var ciphertextPart4 = aesEncryptor.finalize();

    var aesDecryptor = CryptoJS.algo.AES.createDecryptor(key, { iv: iv });

    var plaintextPart1 = aesDecryptor.process(ciphertextPart1);
    var plaintextPart2 = aesDecryptor.process(ciphertextPart2);
    var plaintextPart3 = aesDecryptor.process(ciphertextPart3);
    var plaintextPart4 = aesDecryptor.process(ciphertextPart4);
    var plaintextPart5 = aesDecryptor.finalize();
</script>
}}}

=== Interoperability ===

==== With OpenSSL ====

Encrypt with OpenSSL:

{{{
openssl enc -aes-256-cbc -in infile -out outfile -pass pass:"Secret Passphrase" -e -base64
}}}

Decrypt with CryptoJS:

{{{
<script src="http://crypto-js.googlecode.com/svn/tags/3.1/build/rollups/aes.js"></script>
<script>
    var decrypted = CryptoJS.AES.decrypt(openSSLEncrypted, "Secret Passphrase");
</script>
}}}

== Encoders ==

CryptoJS can convert from encoding formats such as Base64, Latin1 or Hex to WordArray objects and vica versa.

{{{
<script src="http://crypto-js.googlecode.com/svn/tags/3.1/build/components/core-min.js"></script>
<script src="http://crypto-js.googlecode.com/svn/tags/3.1/build/components/enc-utf16-min.js"></script>
<script src="http://crypto-js.googlecode.com/svn/tags/3.1/build/components/enc-base64-min.js"></script>
<script>
    var words  = CryptoJS.enc.Base64.parse('SGVsbG8sIFdvcmxkIQ==');
    var base64 = CryptoJS.enc.Base64.stringify(words);

    var words  = CryptoJS.enc.Latin1.parse('Hello, World!');
    var latin1 = CryptoJS.enc.Latin1.stringify(words);

    var words = CryptoJS.enc.Hex.parse('48656c6c6f2c20576f726c6421');
    var hex   = CryptoJS.enc.Hex.stringify(words);

    var words = CryptoJS.enc.Utf8.parse('𤭢');
    var utf8  = CryptoJS.enc.Utf8.stringify(words);

    var words = CryptoJS.enc.Utf16.parse('Hello, World!');
    var utf16 = CryptoJS.enc.Utf16.stringify(words);

    var words = CryptoJS.enc.Utf16LE.parse('Hello, World!');
    var utf16 = CryptoJS.enc.Utf16LE.stringify(words);
</script>
}}}
/*jshint node: true*/

'use strict';

module.exports = {
    build: [
        '<%= meta.build %>'
    ]
};
/*jshint node: true*/

'use strict';

module.exports = {
    build: {
        files: [{
            expand: false,
            cwd: '<%= meta.cwd %>',
            src: [
                'README.md',
                'CONTRIBUTING.md',
                'LICENSE',
                'docs/**/*'
            ],
            dest: '<%= meta.build %>'
        }]
    }
};
/*jshint node: true*/

'use strict';

module.exports = {
    dev: {
        options: {
            jshintrc: process.cwd() + '/.jshintrc',
            reporterOutput: ''
        },
        files: {
            src: [
                '<%= meta.cwdAll %>.js',
                '!<%= meta.buildAll %>',
                '!<%= meta.testAll %>',
                '!<%= meta.npmAll %>'
            ]
        }
    }
};
/*jshint node: true*/

'use strict';

module.exports = {
    all: {
        files: {
            src: [
                '<%= meta.cwdAll %>.json',
                '!<%= meta.buildAll %>',
                '!<%= meta.npmAll %>'
            ]
        }
    }
};
/*jshint node: true*/

module.exports = {
    build: {
        files: [{
            expand: false,
            cwd: '<%= meta.cwd %>',
            src: ['<%= meta.source %>'],
            dest: '<%= meta.build %>'
        }],
        options: {
            // all
            "index": {
                "global": "CryptoJS",
                "exports": "CryptoJS",
                "components": ["core", "x64-core", "lib-typedarrays", "enc-utf16", "enc-base64", "enc-base64url", "md5", "sha1", "sha256", "sha224", "sha512", "sha384", "sha3", "ripemd160", "hmac", "pbkdf2", "evpkdf", "cipher-core", "mode-cfb", "mode-ctr", "mode-ctr-gladman", "mode-ofb", "mode-ecb", "pad-ansix923", "pad-iso10126", "pad-iso97971", "pad-zeropadding", "pad-nopadding", "format-hex", "aes", "tripledes", "rc4", "rabbit", "rabbit-legacy","blowfish"]
            },
            "crypto-js": {
                "pack": true,
                "global": "CryptoJS",
                "exports": "CryptoJS",
                "components": ["core", "x64-core", "lib-typedarrays", "enc-utf16", "enc-base64", "enc-base64url", "md5", "sha1", "sha256", "sha224", "sha512", "sha384", "sha3", "ripemd160", "hmac", "pbkdf2", "evpkdf", "cipher-core", "mode-cfb", "mode-ctr", "mode-ctr-gladman", "mode-ofb", "mode-ecb", "pad-ansix923", "pad-iso10126", "pad-iso97971", "pad-zeropadding", "pad-nopadding", "format-hex", "aes", "tripledes", "rc4", "rabbit", "rabbit-legacy","blowfish"]
            },

            // hash
            "md5": {
                "exports": "CryptoJS.MD5",
                "components": ["core", "md5"]
            },
            "sha1": {
                "exports": "CryptoJS.SHA1",
                "components": ["core", "sha1"]
            },
            "sha256": {
                "exports": "CryptoJS.SHA256",
                "components": ["core", "sha256"]
            },
            "sha224": {
                "exports": "CryptoJS.SHA224",
                "components": ["core", "sha256", "sha224"]
            },
            "sha512": {
                "exports": "CryptoJS.SHA512",
                "components": ["core", "x64-core", "sha512"]
            },
            "sha384": {
                "exports": "CryptoJS.SHA384",
                "components": ["core", "x64-core", "sha512", "sha384"]
            },
            "sha3": {
                "exports": "CryptoJS.SHA3",
                "components": ["core", "x64-core", "sha3"]
            },
            "ripemd160": {
                "exports": "CryptoJS.RIPEMD160",
                "components": ["core", "ripemd160"]
            },

            // hmac hash
            "hmac-md5": {
                "exports": "CryptoJS.HmacMD5",
                "components": ["core", "md5", "hmac"]
            },
            "hmac-sha1": {
                "exports": "CryptoJS.HmacSHA1",
                "components": ["core", "sha1", "hmac"]
            },
            "hmac-sha256": {
                "exports": "CryptoJS.HmacSHA256",
                "components": ["core", "sha256", "hmac"]
            },
            "hmac-sha224": {
                "exports": "CryptoJS.HmacSHA224",
                "components": ["core", "sha256", "sha224", "hmac"]
            },
            "hmac-sha512": {
                "exports": "CryptoJS.HmacSHA512",
                "components": ["core", "x64-core", "sha512", "hmac"]
            },
            "hmac-sha384": {
                "exports": "CryptoJS.HmacSHA384",
                "components": ["core", "x64-core", "sha512", "sha384", "hmac"]
            },
            "hmac-sha3": {
                "exports": "CryptoJS.HmacSHA3",
                "components": ["core", "x64-core", "sha3", "hmac"]
            },
            "hmac-ripemd160": {
                "exports": "CryptoJS.HmacRIPEMD160",
                "components": ["core", "ripemd160", "hmac"]
            },
            "pbkdf2": {
                "exports": "CryptoJS.PBKDF2",
                "components": ["core", "sha256", "hmac", "pbkdf2"]
            },
            "evpkdf": {
                "exports": "CryptoJS.EvpKDF",
                "components": ["core", "sha1", "hmac", "evpkdf"]
            },

            // cipher
            "aes": {
                "exports": "CryptoJS.AES",
                "components": ["core", "enc-base64", "md5", "evpkdf", "cipher-core", "aes"]
            },
            "blowfish": {
                "exports": "CryptoJS.Blowfish",
                "components": ["core", "enc-base64", "md5", "evpkdf", "cipher-core", "blowfish"]
            },
            "tripledes": {
                "exports": "CryptoJS.TripleDES",
                "components": ["core", "enc-base64", "md5", "evpkdf", "cipher-core", "tripledes"]
            },
            "rc4": {
                "exports": "CryptoJS.RC4",
                "components": ["core", "enc-base64", "md5", "evpkdf", "cipher-core", "rc4"]
            },
            "rabbit": {
                "exports": "CryptoJS.Rabbit",
                "components": ["core", "enc-base64", "md5", "evpkdf", "cipher-core", "rabbit"]
            },
            "rabbit-legacy": {
                "exports": "CryptoJS.RabbitLegacy",
                "components": ["core", "enc-base64", "md5", "evpkdf", "cipher-core", "rabbit-legacy"]
            },

            // core
            "core": {
                "exports": "CryptoJS",
                "components": ["core"],
                "global": "CryptoJS"
            },
            "x64-core": {
                "exports": "CryptoJS",
                "components": ["core", "x64-core"]
            },
            "hmac": {
                "components": ["core", "hmac"]
            },
            "cipher-core": {
                "components": ["core", "evpkdf", "cipher-core"]
            },

            // lib
            "lib-typedarrays": {
                "exports": "CryptoJS.lib.WordArray",
                "components": ["core", "lib-typedarrays"]
            },

            // format
            "format-openssl": {
                "exports": "CryptoJS.format.OpenSSL",
                "components": ["core", "cipher-core"]
            },
            "format-hex": {
                "exports": "CryptoJS.format.Hex",
                "components": ["core", "cipher-core", "format-hex"]
            },

            // enc
            "enc-latin1": {
                "exports": "CryptoJS.enc.Latin1",
                "components": ["core"]
            },
            "enc-utf8": {
                "exports": "CryptoJS.enc.Utf8",
                "components": ["core"]
            },
            "enc-hex": {
                "exports": "CryptoJS.enc.Hex",
                "components": ["core"]
            },
            "enc-utf16": {
                "exports": "CryptoJS.enc.Utf16",
                "components": ["core", "enc-utf16"]
            },
            "enc-base64": {
                "exports": "CryptoJS.enc.Base64",
                "components": ["core", "enc-base64"]
            },
            "enc-base64url": {
                "exports": "CryptoJS.enc.Base64url",
                "components": ["core", "enc-base64url"]
            },

            // mode
            "mode-cfb": {
                "exports": "CryptoJS.mode.CFB",
                "components": ["core", "cipher-core", "mode-cfb"]
            },
            "mode-ctr": {
                "exports": "CryptoJS.mode.CTR",
                "components": ["core", "cipher-core", "mode-ctr"]
            },
            "mode-ctr-gladman": {
                "exports": "CryptoJS.mode.CTRGladman",
                "components": ["core", "cipher-core", "mode-ctr-gladman"]
            },
            "mode-ofb": {
                "exports": "CryptoJS.mode.OFB",
                "components": ["core", "cipher-core", "mode-ofb"]
            },
            "mode-ecb": {
                "exports": "CryptoJS.mode.ECB",
                "components": ["core", "cipher-core", "mode-ecb"]
            },

            // pad
            "pad-pkcs7": {
                "exports": "CryptoJS.pad.Pkcs7",
                "components": ["core", "cipher-core", "pad-pkcs7"]
            },
            "pad-ansix923": {
                "exports": "CryptoJS.pad.Ansix923",
                "components": ["core", "cipher-core", "pad-ansix923"]
            },
            "pad-iso10126": {
                "exports": "CryptoJS.pad.Iso10126",
                "components": ["core", "cipher-core", "pad-iso10126"]
            },
            "pad-iso97971": {
                "exports": "CryptoJS.pad.Iso97971",
                "components": ["core", "cipher-core", "pad-iso97971"]
            },
            "pad-zeropadding": {
                "exports": "CryptoJS.pad.ZeroPadding",
                "components": ["core", "cipher-core", "pad-zeropadding"]
            },
            "pad-nopadding": {
                "exports": "CryptoJS.pad.NoPadding",
                "components": ["core", "cipher-core", "pad-nopadding"]
            }
        }
    }
};
/*jshint node: true*/

'use strict';

module.exports = {
    options: {
        indent: '  '
    },
    npm: {
        src: '<%= meta.cwd %>package.json',
        dest: '<%= meta.build %>package.json',
        fields: {
            'name': null,
            'version': null,
            'description': null,
            'license': null,
            'author': null,
            'homepage': null,
            'repository': null,
            'keywords': null,
            'main': null,
            'dependencies': null,
            'browser': null
        }
    },
    bower: {
        src: '<%= meta.cwd %>package.json',
        dest: '<%= meta.build %>bower.json',
        fields: {
            'name': null,
            'version': null,
            'description': null,
            'license': null,
            'author': 'authors',
            'homepage': null,
            'repository': null,
            'keywords': null,
            'main': null,
            'dependencies': null,
            'browser': null,
            'ignore': []
        }
    }
};
/*jshint node: true*/
/*jshint esversion: 6*/

var _ = require("lodash"),

    fmd = require("fmd");

module.exports = function (grunt) {

    grunt.registerMultiTask('modularize', function () {
        var options = this.options(),

            done = this.async(),

            modules = {},

            config = {
                target: this.target + '/',
                factories: ["commonjs", "amd", "global"],
                trim_whitespace: true,
                new_line: "unix",
                indent: "\t"
            };

        // Prepare Factory-Module-Definition settings
        _.each(options, (conf, name) => {
            var sources = [],

                opts = {
                    depends: {}
                },

                deps = [];

            if (conf.exports) {
                opts.exports = conf.exports;
            }

            if (conf.global) {
                opts.global = conf.global;
            }

            // Find and add self as source
            _.each(this.filesSrc, (source) => {
                if (grunt.file.exists(source + name + ".js")) {
                    sources.push(source + name + ".js");
                }
            });

            if (conf.pack) {
                // Collect all components
                deps = _.chain(conf.components)
                    .map(depName => options[depName].components)
                    .flatten()
                    .uniq()
                    .without(name)
                    .sort((a, b) => {
                        if (options[a].components.includes(b)) {
                            return 1
                        }

                        if (options[b].components.includes(a)) {
                            return -1
                        }

                        return 0;
                    })
                    .value();

                // Add components as source files -> results a single file
                _.each(this.filesSrc, (source) => {
                    _.each(deps, (depName) => {
                        if (grunt.file.exists(source + depName + ".js")) {
                            sources.push(source + depName + ".js");
                        }
                    });
                });
            } else {
                // Read components and add them as dependecies
                _.each(_.without(conf.components, name), (value, i) => {
                    opts.depends['./' + value] = value === "core" ? "CryptoJS" : null;
                });
            }

            // Remove duplicates
            sources = _.uniq(sources);

            // Add module settings to fmd definition
            modules[name] = [sources, opts];
        });

        // Build packege modules
        fmd(config)
            .define(modules)
            .build(() => {

                done();
            });

    });

};
{
  "name": "crypto-js",
  "title": "crypto-js",
  "description": "JavaScript library of crypto standards.",
  "version": "4.1.1",
  "homepage": "http://github.com/brix/crypto-js",
  "author": {
    "name": "Evan Vosberg",
    "url": "http://github.com/evanvosberg"
  },
  "repository": {
    "type": "git",
    "url": "http://github.com/brix/crypto-js.git"
  },
  "bugs": {
    "url": "http://github.com/brix/crypto-js/issues"
  },
  "license": "MIT",
  "scripts": {
    "build": "grunt build",
    "test": "grunt default"
  },
  "main": "index.js",
  "browser": {
    "crypto": false
  },
  "dependencies": {},
  "devDependencies": {
    "fmd": "~0.0.3",
    "grunt": "^1.4.3",
    "grunt-cli": "^1.4.3",
    "grunt-contrib-clean": "^2.0.0",
    "grunt-contrib-copy": "^1.0.0",
    "grunt-contrib-jshint": "^3.0.0",
    "grunt-jsonlint": "^2.1.3",
    "grunt-update-json": "^0.2.2",
    "load-grunt-config": "^4.0.0",
    "lodash": "^4.17.21"
  },
  "keywords": [
    "security",
    "crypto",
    "Hash",
    "MD5",
    "SHA1",
    "SHA-1",
    "SHA256",
    "SHA-256",
    "RC4",
    "Rabbit",
    "AES",
    "DES",
    "PBKDF2",
    "HMAC",
    "OFB",
    "CFB",
    "CTR",
    "CBC",
    "Base64",
    "Base64url"
  ]
}
(function () {
    // Shortcuts
    var C = CryptoJS;
    var C_lib = C.lib;
    var BlockCipher = C_lib.BlockCipher;
    var C_algo = C.algo;

    // Lookup tables
    var SBOX = [];
    var INV_SBOX = [];
    var SUB_MIX_0 = [];
    var SUB_MIX_1 = [];
    var SUB_MIX_2 = [];
    var SUB_MIX_3 = [];
    var INV_SUB_MIX_0 = [];
    var INV_SUB_MIX_1 = [];
    var INV_SUB_MIX_2 = [];
    var INV_SUB_MIX_3 = [];

    // Compute lookup tables
    (function () {
        // Compute double table
        var d = [];
        for (var i = 0; i < 256; i++) {
            if (i < 128) {
                d[i] = i << 1;
            } else {
                d[i] = (i << 1) ^ 0x11b;
            }
        }

        // Walk GF(2^8)
        var x = 0;
        var xi = 0;
        for (var i = 0; i < 256; i++) {
            // Compute sbox
            var sx = xi ^ (xi << 1) ^ (xi << 2) ^ (xi << 3) ^ (xi << 4);
            sx = (sx >>> 8) ^ (sx & 0xff) ^ 0x63;
            SBOX[x] = sx;
            INV_SBOX[sx] = x;

            // Compute multiplication
            var x2 = d[x];
            var x4 = d[x2];
            var x8 = d[x4];

            // Compute sub bytes, mix columns tables
            var t = (d[sx] * 0x101) ^ (sx * 0x1010100);
            SUB_MIX_0[x] = (t << 24) | (t >>> 8);
            SUB_MIX_1[x] = (t << 16) | (t >>> 16);
            SUB_MIX_2[x] = (t << 8)  | (t >>> 24);
            SUB_MIX_3[x] = t;

            // Compute inv sub bytes, inv mix columns tables
            var t = (x8 * 0x1010101) ^ (x4 * 0x10001) ^ (x2 * 0x101) ^ (x * 0x1010100);
            INV_SUB_MIX_0[sx] = (t << 24) | (t >>> 8);
            INV_SUB_MIX_1[sx] = (t << 16) | (t >>> 16);
            INV_SUB_MIX_2[sx] = (t << 8)  | (t >>> 24);
            INV_SUB_MIX_3[sx] = t;

            // Compute next counter
            if (!x) {
                x = xi = 1;
            } else {
                x = x2 ^ d[d[d[x8 ^ x2]]];
                xi ^= d[d[xi]];
            }
        }
    }());

    // Precomputed Rcon lookup
    var RCON = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36];

    /**
     * AES block cipher algorithm.
     */
    var AES = C_algo.AES = BlockCipher.extend({
        _doReset: function () {
            var t;
            
            // Skip reset of nRounds has been set before and key did not change
            if (this._nRounds && this._keyPriorReset === this._key) {
                return;
            }

            // Shortcuts
            var key = this._keyPriorReset = this._key;
            var keyWords = key.words;
            var keySize = key.sigBytes / 4;

            // Compute number of rounds
            var nRounds = this._nRounds = keySize + 6;

            // Compute number of key schedule rows
            var ksRows = (nRounds + 1) * 4;

            // Compute key schedule
            var keySchedule = this._keySchedule = [];
            for (var ksRow = 0; ksRow < ksRows; ksRow++) {
                if (ksRow < keySize) {
                    keySchedule[ksRow] = keyWords[ksRow];
                } else {
                    t = keySchedule[ksRow - 1];

                    if (!(ksRow % keySize)) {
                        // Rot word
                        t = (t << 8) | (t >>> 24);

                        // Sub word
                        t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff];

                        // Mix Rcon
                        t ^= RCON[(ksRow / keySize) | 0] << 24;
                    } else if (keySize > 6 && ksRow % keySize == 4) {
                        // Sub word
                        t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff];
                    }

                    keySchedule[ksRow] = keySchedule[ksRow - keySize] ^ t;
                }
            }

            // Compute inv key schedule
            var invKeySchedule = this._invKeySchedule = [];
            for (var invKsRow = 0; invKsRow < ksRows; invKsRow++) {
                var ksRow = ksRows - invKsRow;

                if (invKsRow % 4) {
                    var t = keySchedule[ksRow];
                } else {
                    var t = keySchedule[ksRow - 4];
                }

                if (invKsRow < 4 || ksRow <= 4) {
                    invKeySchedule[invKsRow] = t;
                } else {
                    invKeySchedule[invKsRow] = INV_SUB_MIX_0[SBOX[t >>> 24]] ^ INV_SUB_MIX_1[SBOX[(t >>> 16) & 0xff]] ^
                                               INV_SUB_MIX_2[SBOX[(t >>> 8) & 0xff]] ^ INV_SUB_MIX_3[SBOX[t & 0xff]];
                }
            }
        },

        encryptBlock: function (M, offset) {
            this._doCryptBlock(M, offset, this._keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX);
        },

        decryptBlock: function (M, offset) {
            // Swap 2nd and 4th rows
            var t = M[offset + 1];
            M[offset + 1] = M[offset + 3];
            M[offset + 3] = t;

            this._doCryptBlock(M, offset, this._invKeySchedule, INV_SUB_MIX_0, INV_SUB_MIX_1, INV_SUB_MIX_2, INV_SUB_MIX_3, INV_SBOX);

            // Inv swap 2nd and 4th rows
            var t = M[offset + 1];
            M[offset + 1] = M[offset + 3];
            M[offset + 3] = t;
        },

        _doCryptBlock: function (M, offset, keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX) {
            // Shortcut
            var nRounds = this._nRounds;

            // Get input, add round key
            var s0 = M[offset]     ^ keySchedule[0];
            var s1 = M[offset + 1] ^ keySchedule[1];
            var s2 = M[offset + 2] ^ keySchedule[2];
            var s3 = M[offset + 3] ^ keySchedule[3];

            // Key schedule row counter
            var ksRow = 4;

            // Rounds
            for (var round = 1; round < nRounds; round++) {
                // Shift rows, sub bytes, mix columns, add round key
                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++];
                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++];
                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++];
                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++];

                // Update state
                s0 = t0;
                s1 = t1;
                s2 = t2;
                s3 = t3;
            }

            // Shift rows, sub bytes, add round key
            var t0 = ((SBOX[s0 >>> 24] << 24) | (SBOX[(s1 >>> 16) & 0xff] << 16) | (SBOX[(s2 >>> 8) & 0xff] << 8) | SBOX[s3 & 0xff]) ^ keySchedule[ksRow++];
            var t1 = ((SBOX[s1 >>> 24] << 24) | (SBOX[(s2 >>> 16) & 0xff] << 16) | (SBOX[(s3 >>> 8) & 0xff] << 8) | SBOX[s0 & 0xff]) ^ keySchedule[ksRow++];
            var t2 = ((SBOX[s2 >>> 24] << 24) | (SBOX[(s3 >>> 16) & 0xff] << 16) | (SBOX[(s0 >>> 8) & 0xff] << 8) | SBOX[s1 & 0xff]) ^ keySchedule[ksRow++];
            var t3 = ((SBOX[s3 >>> 24] << 24) | (SBOX[(s0 >>> 16) & 0xff] << 16) | (SBOX[(s1 >>> 8) & 0xff] << 8) | SBOX[s2 & 0xff]) ^ keySchedule[ksRow++];

            // Set output
            M[offset]     = t0;
            M[offset + 1] = t1;
            M[offset + 2] = t2;
            M[offset + 3] = t3;
        },

        keySize: 256/32
    });

    /**
     * Shortcut functions to the cipher's object interface.
     *
     * @example
     *
     *     var ciphertext = CryptoJS.AES.encrypt(message, key, cfg);
     *     var plaintext  = CryptoJS.AES.decrypt(ciphertext, key, cfg);
     */
    C.AES = BlockCipher._createHelper(AES);
}());
(function () {
    // Shortcuts
    var C = CryptoJS;
    var C_lib = C.lib;
    var BlockCipher = C_lib.BlockCipher;
    var C_algo = C.algo;

    const N = 16;
    
    //Origin pbox and sbox, derived from PI
    const ORIG_P = [
        0x243F6A88, 0x85A308D3, 0x13198A2E, 0x03707344,
        0xA4093822, 0x299F31D0, 0x082EFA98, 0xEC4E6C89,
        0x452821E6, 0x38D01377, 0xBE5466CF, 0x34E90C6C,
        0xC0AC29B7, 0xC97C50DD, 0x3F84D5B5, 0xB5470917,
        0x9216D5D9, 0x8979FB1B
    ];

    const ORIG_S = [
        [   0xD1310BA6, 0x98DFB5AC, 0x2FFD72DB, 0xD01ADFB7,
            0xB8E1AFED, 0x6A267E96, 0xBA7C9045, 0xF12C7F99,
            0x24A19947, 0xB3916CF7, 0x0801F2E2, 0x858EFC16,
            0x636920D8, 0x71574E69, 0xA458FEA3, 0xF4933D7E,
            0x0D95748F, 0x728EB658, 0x718BCD58, 0x82154AEE,
            0x7B54A41D, 0xC25A59B5, 0x9C30D539, 0x2AF26013,
            0xC5D1B023, 0x286085F0, 0xCA417918, 0xB8DB38EF,
            0x8E79DCB0, 0x603A180E, 0x6C9E0E8B, 0xB01E8A3E,
            0xD71577C1, 0xBD314B27, 0x78AF2FDA, 0x55605C60,
            0xE65525F3, 0xAA55AB94, 0x57489862, 0x63E81440,
            0x55CA396A, 0x2AAB10B6, 0xB4CC5C34, 0x1141E8CE,
            0xA15486AF, 0x7C72E993, 0xB3EE1411, 0x636FBC2A,
            0x2BA9C55D, 0x741831F6, 0xCE5C3E16, 0x9B87931E,
            0xAFD6BA33, 0x6C24CF5C, 0x7A325381, 0x28958677,
            0x3B8F4898, 0x6B4BB9AF, 0xC4BFE81B, 0x66282193,
            0x61D809CC, 0xFB21A991, 0x487CAC60, 0x5DEC8032,
            0xEF845D5D, 0xE98575B1, 0xDC262302, 0xEB651B88,
            0x23893E81, 0xD396ACC5, 0x0F6D6FF3, 0x83F44239,
            0x2E0B4482, 0xA4842004, 0x69C8F04A, 0x9E1F9B5E,
            0x21C66842, 0xF6E96C9A, 0x670C9C61, 0xABD388F0,
            0x6A51A0D2, 0xD8542F68, 0x960FA728, 0xAB5133A3,
            0x6EEF0B6C, 0x137A3BE4, 0xBA3BF050, 0x7EFB2A98,
            0xA1F1651D, 0x39AF0176, 0x66CA593E, 0x82430E88,
            0x8CEE8619, 0x456F9FB4, 0x7D84A5C3, 0x3B8B5EBE,
            0xE06F75D8, 0x85C12073, 0x401A449F, 0x56C16AA6,
            0x4ED3AA62, 0x363F7706, 0x1BFEDF72, 0x429B023D,
            0x37D0D724, 0xD00A1248, 0xDB0FEAD3, 0x49F1C09B,
            0x075372C9, 0x80991B7B, 0x25D479D8, 0xF6E8DEF7,
            0xE3FE501A, 0xB6794C3B, 0x976CE0BD, 0x04C006BA,
            0xC1A94FB6, 0x409F60C4, 0x5E5C9EC2, 0x196A2463,
            0x68FB6FAF, 0x3E6C53B5, 0x1339B2EB, 0x3B52EC6F,
            0x6DFC511F, 0x9B30952C, 0xCC814544, 0xAF5EBD09,
            0xBEE3D004, 0xDE334AFD, 0x660F2807, 0x192E4BB3,
            0xC0CBA857, 0x45C8740F, 0xD20B5F39, 0xB9D3FBDB,
            0x5579C0BD, 0x1A60320A, 0xD6A100C6, 0x402C7279,
            0x679F25FE, 0xFB1FA3CC, 0x8EA5E9F8, 0xDB3222F8,
            0x3C7516DF, 0xFD616B15, 0x2F501EC8, 0xAD0552AB,
            0x323DB5FA, 0xFD238760, 0x53317B48, 0x3E00DF82,
            0x9E5C57BB, 0xCA6F8CA0, 0x1A87562E, 0xDF1769DB,
            0xD542A8F6, 0x287EFFC3, 0xAC6732C6, 0x8C4F5573,
            0x695B27B0, 0xBBCA58C8, 0xE1FFA35D, 0xB8F011A0,
            0x10FA3D98, 0xFD2183B8, 0x4AFCB56C, 0x2DD1D35B,
            0x9A53E479, 0xB6F84565, 0xD28E49BC, 0x4BFB9790,
            0xE1DDF2DA, 0xA4CB7E33, 0x62FB1341, 0xCEE4C6E8,
            0xEF20CADA, 0x36774C01, 0xD07E9EFE, 0x2BF11FB4,
            0x95DBDA4D, 0xAE909198, 0xEAAD8E71, 0x6B93D5A0,
            0xD08ED1D0, 0xAFC725E0, 0x8E3C5B2F, 0x8E7594B7,
            0x8FF6E2FB, 0xF2122B64, 0x8888B812, 0x900DF01C,
            0x4FAD5EA0, 0x688FC31C, 0xD1CFF191, 0xB3A8C1AD,
            0x2F2F2218, 0xBE0E1777, 0xEA752DFE, 0x8B021FA1,
            0xE5A0CC0F, 0xB56F74E8, 0x18ACF3D6, 0xCE89E299,
            0xB4A84FE0, 0xFD13E0B7, 0x7CC43B81, 0xD2ADA8D9,
            0x165FA266, 0x80957705, 0x93CC7314, 0x211A1477,
            0xE6AD2065, 0x77B5FA86, 0xC75442F5, 0xFB9D35CF,
            0xEBCDAF0C, 0x7B3E89A0, 0xD6411BD3, 0xAE1E7E49,
            0x00250E2D, 0x2071B35E, 0x226800BB, 0x57B8E0AF,
            0x2464369B, 0xF009B91E, 0x5563911D, 0x59DFA6AA,
            0x78C14389, 0xD95A537F, 0x207D5BA2, 0x02E5B9C5,
            0x83260376, 0x6295CFA9, 0x11C81968, 0x4E734A41,
            0xB3472DCA, 0x7B14A94A, 0x1B510052, 0x9A532915,
            0xD60F573F, 0xBC9BC6E4, 0x2B60A476, 0x81E67400,
            0x08BA6FB5, 0x571BE91F, 0xF296EC6B, 0x2A0DD915,
            0xB6636521, 0xE7B9F9B6, 0xFF34052E, 0xC5855664,
            0x53B02D5D, 0xA99F8FA1, 0x08BA4799, 0x6E85076A   ],
        [   0x4B7A70E9, 0xB5B32944, 0xDB75092E, 0xC4192623,
            0xAD6EA6B0, 0x49A7DF7D, 0x9CEE60B8, 0x8FEDB266,
            0xECAA8C71, 0x699A17FF, 0x5664526C, 0xC2B19EE1,
            0x193602A5, 0x75094C29, 0xA0591340, 0xE4183A3E,
            0x3F54989A, 0x5B429D65, 0x6B8FE4D6, 0x99F73FD6,
            0xA1D29C07, 0xEFE830F5, 0x4D2D38E6, 0xF0255DC1,
            0x4CDD2086, 0x8470EB26, 0x6382E9C6, 0x021ECC5E,
            0x09686B3F, 0x3EBAEFC9, 0x3C971814, 0x6B6A70A1,
            0x687F3584, 0x52A0E286, 0xB79C5305, 0xAA500737,
            0x3E07841C, 0x7FDEAE5C, 0x8E7D44EC, 0x5716F2B8,
            0xB03ADA37, 0xF0500C0D, 0xF01C1F04, 0x0200B3FF,
            0xAE0CF51A, 0x3CB574B2, 0x25837A58, 0xDC0921BD,
            0xD19113F9, 0x7CA92FF6, 0x94324773, 0x22F54701,
            0x3AE5E581, 0x37C2DADC, 0xC8B57634, 0x9AF3DDA7,
            0xA9446146, 0x0FD0030E, 0xECC8C73E, 0xA4751E41,
            0xE238CD99, 0x3BEA0E2F, 0x3280BBA1, 0x183EB331,
            0x4E548B38, 0x4F6DB908, 0x6F420D03, 0xF60A04BF,
            0x2CB81290, 0x24977C79, 0x5679B072, 0xBCAF89AF,
            0xDE9A771F, 0xD9930810, 0xB38BAE12, 0xDCCF3F2E,
            0x5512721F, 0x2E6B7124, 0x501ADDE6, 0x9F84CD87,
            0x7A584718, 0x7408DA17, 0xBC9F9ABC, 0xE94B7D8C,
            0xEC7AEC3A, 0xDB851DFA, 0x63094366, 0xC464C3D2,
            0xEF1C1847, 0x3215D908, 0xDD433B37, 0x24C2BA16,
            0x12A14D43, 0x2A65C451, 0x50940002, 0x133AE4DD,
            0x71DFF89E, 0x10314E55, 0x81AC77D6, 0x5F11199B,
            0x043556F1, 0xD7A3C76B, 0x3C11183B, 0x5924A509,
            0xF28FE6ED, 0x97F1FBFA, 0x9EBABF2C, 0x1E153C6E,
            0x86E34570, 0xEAE96FB1, 0x860E5E0A, 0x5A3E2AB3,
            0x771FE71C, 0x4E3D06FA, 0x2965DCB9, 0x99E71D0F,
            0x803E89D6, 0x5266C825, 0x2E4CC978, 0x9C10B36A,
            0xC6150EBA, 0x94E2EA78, 0xA5FC3C53, 0x1E0A2DF4,
            0xF2F74EA7, 0x361D2B3D, 0x1939260F, 0x19C27960,
            0x5223A708, 0xF71312B6, 0xEBADFE6E, 0xEAC31F66,
            0xE3BC4595, 0xA67BC883, 0xB17F37D1, 0x018CFF28,
            0xC332DDEF, 0xBE6C5AA5, 0x65582185, 0x68AB9802,
            0xEECEA50F, 0xDB2F953B, 0x2AEF7DAD, 0x5B6E2F84,
            0x1521B628, 0x29076170, 0xECDD4775, 0x619F1510,
            0x13CCA830, 0xEB61BD96, 0x0334FE1E, 0xAA0363CF,
            0xB5735C90, 0x4C70A239, 0xD59E9E0B, 0xCBAADE14,
            0xEECC86BC, 0x60622CA7, 0x9CAB5CAB, 0xB2F3846E,
            0x648B1EAF, 0x19BDF0CA, 0xA02369B9, 0x655ABB50,
            0x40685A32, 0x3C2AB4B3, 0x319EE9D5, 0xC021B8F7,
            0x9B540B19, 0x875FA099, 0x95F7997E, 0x623D7DA8,
            0xF837889A, 0x97E32D77, 0x11ED935F, 0x16681281,
            0x0E358829, 0xC7E61FD6, 0x96DEDFA1, 0x7858BA99,
            0x57F584A5, 0x1B227263, 0x9B83C3FF, 0x1AC24696,
            0xCDB30AEB, 0x532E3054, 0x8FD948E4, 0x6DBC3128,
            0x58EBF2EF, 0x34C6FFEA, 0xFE28ED61, 0xEE7C3C73,
            0x5D4A14D9, 0xE864B7E3, 0x42105D14, 0x203E13E0,
            0x45EEE2B6, 0xA3AAABEA, 0xDB6C4F15, 0xFACB4FD0,
            0xC742F442, 0xEF6ABBB5, 0x654F3B1D, 0x41CD2105,
            0xD81E799E, 0x86854DC7, 0xE44B476A, 0x3D816250,
            0xCF62A1F2, 0x5B8D2646, 0xFC8883A0, 0xC1C7B6A3,
            0x7F1524C3, 0x69CB7492, 0x47848A0B, 0x5692B285,
            0x095BBF00, 0xAD19489D, 0x1462B174, 0x23820E00,
            0x58428D2A, 0x0C55F5EA, 0x1DADF43E, 0x233F7061,
            0x3372F092, 0x8D937E41, 0xD65FECF1, 0x6C223BDB,
            0x7CDE3759, 0xCBEE7460, 0x4085F2A7, 0xCE77326E,
            0xA6078084, 0x19F8509E, 0xE8EFD855, 0x61D99735,
            0xA969A7AA, 0xC50C06C2, 0x5A04ABFC, 0x800BCADC,
            0x9E447A2E, 0xC3453484, 0xFDD56705, 0x0E1E9EC9,
            0xDB73DBD3, 0x105588CD, 0x675FDA79, 0xE3674340,
            0xC5C43465, 0x713E38D8, 0x3D28F89E, 0xF16DFF20,
            0x153E21E7, 0x8FB03D4A, 0xE6E39F2B, 0xDB83ADF7   ],
        [   0xE93D5A68, 0x948140F7, 0xF64C261C, 0x94692934,
            0x411520F7, 0x7602D4F7, 0xBCF46B2E, 0xD4A20068,
            0xD4082471, 0x3320F46A, 0x43B7D4B7, 0x500061AF,
            0x1E39F62E, 0x97244546, 0x14214F74, 0xBF8B8840,
            0x4D95FC1D, 0x96B591AF, 0x70F4DDD3, 0x66A02F45,
            0xBFBC09EC, 0x03BD9785, 0x7FAC6DD0, 0x31CB8504,
            0x96EB27B3, 0x55FD3941, 0xDA2547E6, 0xABCA0A9A,
            0x28507825, 0x530429F4, 0x0A2C86DA, 0xE9B66DFB,
            0x68DC1462, 0xD7486900, 0x680EC0A4, 0x27A18DEE,
            0x4F3FFEA2, 0xE887AD8C, 0xB58CE006, 0x7AF4D6B6,
            0xAACE1E7C, 0xD3375FEC, 0xCE78A399, 0x406B2A42,
            0x20FE9E35, 0xD9F385B9, 0xEE39D7AB, 0x3B124E8B,
            0x1DC9FAF7, 0x4B6D1856, 0x26A36631, 0xEAE397B2,
            0x3A6EFA74, 0xDD5B4332, 0x6841E7F7, 0xCA7820FB,
            0xFB0AF54E, 0xD8FEB397, 0x454056AC, 0xBA489527,
            0x55533A3A, 0x20838D87, 0xFE6BA9B7, 0xD096954B,
            0x55A867BC, 0xA1159A58, 0xCCA92963, 0x99E1DB33,
            0xA62A4A56, 0x3F3125F9, 0x5EF47E1C, 0x9029317C,
            0xFDF8E802, 0x04272F70, 0x80BB155C, 0x05282CE3,
            0x95C11548, 0xE4C66D22, 0x48C1133F, 0xC70F86DC,
            0x07F9C9EE, 0x41041F0F, 0x404779A4, 0x5D886E17,
            0x325F51EB, 0xD59BC0D1, 0xF2BCC18F, 0x41113564,
            0x257B7834, 0x602A9C60, 0xDFF8E8A3, 0x1F636C1B,
            0x0E12B4C2, 0x02E1329E, 0xAF664FD1, 0xCAD18115,
            0x6B2395E0, 0x333E92E1, 0x3B240B62, 0xEEBEB922,
            0x85B2A20E, 0xE6BA0D99, 0xDE720C8C, 0x2DA2F728,
            0xD0127845, 0x95B794FD, 0x647D0862, 0xE7CCF5F0,
            0x5449A36F, 0x877D48FA, 0xC39DFD27, 0xF33E8D1E,
            0x0A476341, 0x992EFF74, 0x3A6F6EAB, 0xF4F8FD37,
            0xA812DC60, 0xA1EBDDF8, 0x991BE14C, 0xDB6E6B0D,
            0xC67B5510, 0x6D672C37, 0x2765D43B, 0xDCD0E804,
            0xF1290DC7, 0xCC00FFA3, 0xB5390F92, 0x690FED0B,
            0x667B9FFB, 0xCEDB7D9C, 0xA091CF0B, 0xD9155EA3,
            0xBB132F88, 0x515BAD24, 0x7B9479BF, 0x763BD6EB,
            0x37392EB3, 0xCC115979, 0x8026E297, 0xF42E312D,
            0x6842ADA7, 0xC66A2B3B, 0x12754CCC, 0x782EF11C,
            0x6A124237, 0xB79251E7, 0x06A1BBE6, 0x4BFB6350,
            0x1A6B1018, 0x11CAEDFA, 0x3D25BDD8, 0xE2E1C3C9,
            0x44421659, 0x0A121386, 0xD90CEC6E, 0xD5ABEA2A,
            0x64AF674E, 0xDA86A85F, 0xBEBFE988, 0x64E4C3FE,
            0x9DBC8057, 0xF0F7C086, 0x60787BF8, 0x6003604D,
            0xD1FD8346, 0xF6381FB0, 0x7745AE04, 0xD736FCCC,
            0x83426B33, 0xF01EAB71, 0xB0804187, 0x3C005E5F,
            0x77A057BE, 0xBDE8AE24, 0x55464299, 0xBF582E61,
            0x4E58F48F, 0xF2DDFDA2, 0xF474EF38, 0x8789BDC2,
            0x5366F9C3, 0xC8B38E74, 0xB475F255, 0x46FCD9B9,
            0x7AEB2661, 0x8B1DDF84, 0x846A0E79, 0x915F95E2,
            0x466E598E, 0x20B45770, 0x8CD55591, 0xC902DE4C,
            0xB90BACE1, 0xBB8205D0, 0x11A86248, 0x7574A99E,
            0xB77F19B6, 0xE0A9DC09, 0x662D09A1, 0xC4324633,
            0xE85A1F02, 0x09F0BE8C, 0x4A99A025, 0x1D6EFE10,
            0x1AB93D1D, 0x0BA5A4DF, 0xA186F20F, 0x2868F169,
            0xDCB7DA83, 0x573906FE, 0xA1E2CE9B, 0x4FCD7F52,
            0x50115E01, 0xA70683FA, 0xA002B5C4, 0x0DE6D027,
            0x9AF88C27, 0x773F8641, 0xC3604C06, 0x61A806B5,
            0xF0177A28, 0xC0F586E0, 0x006058AA, 0x30DC7D62,
            0x11E69ED7, 0x2338EA63, 0x53C2DD94, 0xC2C21634,
            0xBBCBEE56, 0x90BCB6DE, 0xEBFC7DA1, 0xCE591D76,
            0x6F05E409, 0x4B7C0188, 0x39720A3D, 0x7C927C24,
            0x86E3725F, 0x724D9DB9, 0x1AC15BB4, 0xD39EB8FC,
            0xED545578, 0x08FCA5B5, 0xD83D7CD3, 0x4DAD0FC4,
            0x1E50EF5E, 0xB161E6F8, 0xA28514D9, 0x6C51133C,
            0x6FD5C7E7, 0x56E14EC4, 0x362ABFCE, 0xDDC6C837,
            0xD79A3234, 0x92638212, 0x670EFA8E, 0x406000E0  ],
        [   0x3A39CE37, 0xD3FAF5CF, 0xABC27737, 0x5AC52D1B,
            0x5CB0679E, 0x4FA33742, 0xD3822740, 0x99BC9BBE,
            0xD5118E9D, 0xBF0F7315, 0xD62D1C7E, 0xC700C47B,
            0xB78C1B6B, 0x21A19045, 0xB26EB1BE, 0x6A366EB4,
            0x5748AB2F, 0xBC946E79, 0xC6A376D2, 0x6549C2C8,
            0x530FF8EE, 0x468DDE7D, 0xD5730A1D, 0x4CD04DC6,
            0x2939BBDB, 0xA9BA4650, 0xAC9526E8, 0xBE5EE304,
            0xA1FAD5F0, 0x6A2D519A, 0x63EF8CE2, 0x9A86EE22,
            0xC089C2B8, 0x43242EF6, 0xA51E03AA, 0x9CF2D0A4,
            0x83C061BA, 0x9BE96A4D, 0x8FE51550, 0xBA645BD6,
            0x2826A2F9, 0xA73A3AE1, 0x4BA99586, 0xEF5562E9,
            0xC72FEFD3, 0xF752F7DA, 0x3F046F69, 0x77FA0A59,
            0x80E4A915, 0x87B08601, 0x9B09E6AD, 0x3B3EE593,
            0xE990FD5A, 0x9E34D797, 0x2CF0B7D9, 0x022B8B51,
            0x96D5AC3A, 0x017DA67D, 0xD1CF3ED6, 0x7C7D2D28,
            0x1F9F25CF, 0xADF2B89B, 0x5AD6B472, 0x5A88F54C,
            0xE029AC71, 0xE019A5E6, 0x47B0ACFD, 0xED93FA9B,
            0xE8D3C48D, 0x283B57CC, 0xF8D56629, 0x79132E28,
            0x785F0191, 0xED756055, 0xF7960E44, 0xE3D35E8C,
            0x15056DD4, 0x88F46DBA, 0x03A16125, 0x0564F0BD,
            0xC3EB9E15, 0x3C9057A2, 0x97271AEC, 0xA93A072A,
            0x1B3F6D9B, 0x1E6321F5, 0xF59C66FB, 0x26DCF319,
            0x7533D928, 0xB155FDF5, 0x03563482, 0x8ABA3CBB,
            0x28517711, 0xC20AD9F8, 0xABCC5167, 0xCCAD925F,
            0x4DE81751, 0x3830DC8E, 0x379D5862, 0x9320F991,
            0xEA7A90C2, 0xFB3E7BCE, 0x5121CE64, 0x774FBE32,
            0xA8B6E37E, 0xC3293D46, 0x48DE5369, 0x6413E680,
            0xA2AE0810, 0xDD6DB224, 0x69852DFD, 0x09072166,
            0xB39A460A, 0x6445C0DD, 0x586CDECF, 0x1C20C8AE,
            0x5BBEF7DD, 0x1B588D40, 0xCCD2017F, 0x6BB4E3BB,
            0xDDA26A7E, 0x3A59FF45, 0x3E350A44, 0xBCB4CDD5,
            0x72EACEA8, 0xFA6484BB, 0x8D6612AE, 0xBF3C6F47,
            0xD29BE463, 0x542F5D9E, 0xAEC2771B, 0xF64E6370,
            0x740E0D8D, 0xE75B1357, 0xF8721671, 0xAF537D5D,
            0x4040CB08, 0x4EB4E2CC, 0x34D2466A, 0x0115AF84,
            0xE1B00428, 0x95983A1D, 0x06B89FB4, 0xCE6EA048,
            0x6F3F3B82, 0x3520AB82, 0x011A1D4B, 0x277227F8,
            0x611560B1, 0xE7933FDC, 0xBB3A792B, 0x344525BD,
            0xA08839E1, 0x51CE794B, 0x2F32C9B7, 0xA01FBAC9,
            0xE01CC87E, 0xBCC7D1F6, 0xCF0111C3, 0xA1E8AAC7,
            0x1A908749, 0xD44FBD9A, 0xD0DADECB, 0xD50ADA38,
            0x0339C32A, 0xC6913667, 0x8DF9317C, 0xE0B12B4F,
            0xF79E59B7, 0x43F5BB3A, 0xF2D519FF, 0x27D9459C,
            0xBF97222C, 0x15E6FC2A, 0x0F91FC71, 0x9B941525,
            0xFAE59361, 0xCEB69CEB, 0xC2A86459, 0x12BAA8D1,
            0xB6C1075E, 0xE3056A0C, 0x10D25065, 0xCB03A442,
            0xE0EC6E0E, 0x1698DB3B, 0x4C98A0BE, 0x3278E964,
            0x9F1F9532, 0xE0D392DF, 0xD3A0342B, 0x8971F21E,
            0x1B0A7441, 0x4BA3348C, 0xC5BE7120, 0xC37632D8,
            0xDF359F8D, 0x9B992F2E, 0xE60B6F47, 0x0FE3F11D,
            0xE54CDA54, 0x1EDAD891, 0xCE6279CF, 0xCD3E7E6F,
            0x1618B166, 0xFD2C1D05, 0x848FD2C5, 0xF6FB2299,
            0xF523F357, 0xA6327623, 0x93A83531, 0x56CCCD02,
            0xACF08162, 0x5A75EBB5, 0x6E163697, 0x88D273CC,
            0xDE966292, 0x81B949D0, 0x4C50901B, 0x71C65614,
            0xE6C6C7BD, 0x327A140A, 0x45E1D006, 0xC3F27B9A,
            0xC9AA53FD, 0x62A80F00, 0xBB25BFE2, 0x35BDD2F6,
            0x71126905, 0xB2040222, 0xB6CBCF7C, 0xCD769C2B,
            0x53113EC0, 0x1640E3D3, 0x38ABBD60, 0x2547ADF0,
            0xBA38209C, 0xF746CE76, 0x77AFA1C5, 0x20756060,
            0x85CBFE4E, 0x8AE88DD8, 0x7AAAF9B0, 0x4CF9AA7E,
            0x1948C25C, 0x02FB8A8C, 0x01C36AE4, 0xD6EBE1F9,
            0x90D4F869, 0xA65CDEA0, 0x3F09252D, 0xC208E69F,
            0xB74E6132, 0xCE77E25B, 0x578FDFE3, 0x3AC372E6  ]
    ];

    var BLOWFISH_CTX = {
        pbox: [],
        sbox: []
    }

    function F(ctx, x){
        let a = (x >> 24) & 0xFF;
        let b = (x >> 16) & 0xFF;
        let c = (x >> 8) & 0xFF;
        let d = x & 0xFF;

        let y = ctx.sbox[0][a] + ctx.sbox[1][b];
        y = y ^ ctx.sbox[2][c];
        y = y + ctx.sbox[3][d];

        return y;
    }

    function BlowFish_Encrypt(ctx, left, right){
        let Xl = left;
        let Xr = right;
        let temp;

        for(let i = 0; i < N; ++i){
            Xl = Xl ^ ctx.pbox[i];
            Xr = F(ctx, Xl) ^ Xr;

            temp = Xl;
            Xl = Xr;
            Xr = temp;
        }

        temp = Xl;
        Xl = Xr;
        Xr = temp;

        Xr = Xr ^ ctx.pbox[N];
        Xl = Xl ^ ctx.pbox[N + 1];

        return {left: Xl, right: Xr};
    }

    function BlowFish_Decrypt(ctx, left, right){
        let Xl = left;
        let Xr = right;
        let temp;

        for(let i = N + 1; i > 1; --i){
            Xl = Xl ^ ctx.pbox[i];
            Xr = F(ctx, Xl) ^ Xr;

            temp = Xl;
            Xl = Xr;
            Xr = temp;
        }

        temp = Xl;
        Xl = Xr;
        Xr = temp;

        Xr = Xr ^ ctx.pbox[1];
        Xl = Xl ^ ctx.pbox[0];

        return {left: Xl, right: Xr};
    }

    /**
     * Initialization ctx's pbox and sbox.
     *
     * @param {Object} ctx The object has pbox and sbox.
     * @param {Array} key An array of 32-bit words.
     * @param {int} keysize The length of the key.
     *
     * @example
     *
     *     BlowFishInit(BLOWFISH_CTX, key, 128/32);
     */
    function BlowFishInit(ctx, key, keysize)
    {
        for(let Row = 0; Row < 4; Row++)
        {
            ctx.sbox[Row] = [];
            for(let Col = 0; Col < 256; Col++)
            {
                ctx.sbox[Row][Col] = ORIG_S[Row][Col];
            }
        }

        let keyIndex = 0;
        for(let index = 0; index < N + 2; index++)
        {
            ctx.pbox[index] = ORIG_P[index] ^ key[keyIndex];
            keyIndex++;
            if(keyIndex >= keysize)
            {
                keyIndex = 0;
            }
        }

        let Data1 = 0;
        let Data2 = 0;
        let res = 0;
        for(let i = 0; i < N + 2; i += 2)
        {
            res = BlowFish_Encrypt(ctx, Data1, Data2);
            Data1 = res.left;
            Data2 = res.right;
            ctx.pbox[i] = Data1;
            ctx.pbox[i + 1] = Data2;
        }
        
        for(let i = 0; i < 4; i++)
        {
            for(let j = 0; j < 256; j += 2)
            {
                res = BlowFish_Encrypt(ctx, Data1, Data2);
                Data1 = res.left;
                Data2 = res.right;
                ctx.sbox[i][j] = Data1;
                ctx.sbox[i][j + 1] = Data2;
            }
        }

        return true;
    }

    /**
     * Blowfish block cipher algorithm.
     */
    var Blowfish = C_algo.Blowfish = BlockCipher.extend({
        _doReset: function () {
            // Skip reset of nRounds has been set before and key did not change
            if (this._keyPriorReset === this._key) {
                return;
            }

            // Shortcuts
            var key = this._keyPriorReset = this._key;
            var keyWords = key.words;
            var keySize = key.sigBytes / 4;

            //Initialization pbox and sbox
            BlowFishInit(BLOWFISH_CTX, keyWords, keySize);
        },

        encryptBlock: function (M, offset) {
            var res = BlowFish_Encrypt(BLOWFISH_CTX, M[offset], M[offset + 1]);
            M[offset] = res.left;
            M[offset + 1] = res.right;
        },

        decryptBlock: function (M, offset) {
            var res = BlowFish_Decrypt(BLOWFISH_CTX, M[offset], M[offset + 1]);
            M[offset] = res.left;
            M[offset + 1] = res.right;
        },

        blockSize: 64/32,

        keySize: 128/32,

        ivSize: 64/32
    });

    /**
     * Shortcut functions to the cipher's object interface.
     *
     * @example
     *
     *     var ciphertext = CryptoJS.Blowfish.encrypt(message, key, cfg);
     *     var plaintext  = CryptoJS.Blowfish.decrypt(ciphertext, key, cfg);
     */
    C.Blowfish = BlockCipher._createHelper(Blowfish);
}());
/**
 * Cipher core components.
 */
CryptoJS.lib.Cipher || (function (undefined) {
    // Shortcuts
    var C = CryptoJS;
    var C_lib = C.lib;
    var Base = C_lib.Base;
    var WordArray = C_lib.WordArray;
    var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm;
    var C_enc = C.enc;
    var Utf8 = C_enc.Utf8;
    var Base64 = C_enc.Base64;
    var C_algo = C.algo;
    var EvpKDF = C_algo.EvpKDF;

    /**
     * Abstract base cipher template.
     *
     * @property {number} keySize This cipher's key size. Default: 4 (128 bits)
     * @property {number} ivSize This cipher's IV size. Default: 4 (128 bits)
     * @property {number} _ENC_XFORM_MODE A constant representing encryption mode.
     * @property {number} _DEC_XFORM_MODE A constant representing decryption mode.
     */
    var Cipher = C_lib.Cipher = BufferedBlockAlgorithm.extend({
        /**
         * Configuration options.
         *
         * @property {WordArray} iv The IV to use for this operation.
         */
        cfg: Base.extend(),

        /**
         * Creates this cipher in encryption mode.
         *
         * @param {WordArray} key The key.
         * @param {Object} cfg (Optional) The configuration options to use for this operation.
         *
         * @return {Cipher} A cipher instance.
         *
         * @static
         *
         * @example
         *
         *     var cipher = CryptoJS.algo.AES.createEncryptor(keyWordArray, { iv: ivWordArray });
         */
        createEncryptor: function (key, cfg) {
            return this.create(this._ENC_XFORM_MODE, key, cfg);
        },

        /**
         * Creates this cipher in decryption mode.
         *
         * @param {WordArray} key The key.
         * @param {Object} cfg (Optional) The configuration options to use for this operation.
         *
         * @return {Cipher} A cipher instance.
         *
         * @static
         *
         * @example
         *
         *     var cipher = CryptoJS.algo.AES.createDecryptor(keyWordArray, { iv: ivWordArray });
         */
        createDecryptor: function (key, cfg) {
            return this.create(this._DEC_XFORM_MODE, key, cfg);
        },

        /**
         * Initializes a newly created cipher.
         *
         * @param {number} xformMode Either the encryption or decryption transormation mode constant.
         * @param {WordArray} key The key.
         * @param {Object} cfg (Optional) The configuration options to use for this operation.
         *
         * @example
         *
         *     var cipher = CryptoJS.algo.AES.create(CryptoJS.algo.AES._ENC_XFORM_MODE, keyWordArray, { iv: ivWordArray });
         */
        init: function (xformMode, key, cfg) {
            // Apply config defaults
            this.cfg = this.cfg.extend(cfg);

            // Store transform mode and key
            this._xformMode = xformMode;
            this._key = key;

            // Set initial values
            this.reset();
        },

        /**
         * Resets this cipher to its initial state.
         *
         * @example
         *
         *     cipher.reset();
         */
        reset: function () {
            // Reset data buffer
            BufferedBlockAlgorithm.reset.call(this);

            // Perform concrete-cipher logic
            this._doReset();
        },

        /**
         * Adds data to be encrypted or decrypted.
         *
         * @param {WordArray|string} dataUpdate The data to encrypt or decrypt.
         *
         * @return {WordArray} The data after processing.
         *
         * @example
         *
         *     var encrypted = cipher.process('data');
         *     var encrypted = cipher.process(wordArray);
         */
        process: function (dataUpdate) {
            // Append
            this._append(dataUpdate);

            // Process available blocks
            return this._process();
        },

        /**
         * Finalizes the encryption or decryption process.
         * Note that the finalize operation is effectively a destructive, read-once operation.
         *
         * @param {WordArray|string} dataUpdate The final data to encrypt or decrypt.
         *
         * @return {WordArray} The data after final processing.
         *
         * @example
         *
         *     var encrypted = cipher.finalize();
         *     var encrypted = cipher.finalize('data');
         *     var encrypted = cipher.finalize(wordArray);
         */
        finalize: function (dataUpdate) {
            // Final data update
            if (dataUpdate) {
                this._append(dataUpdate);
            }

            // Perform concrete-cipher logic
            var finalProcessedData = this._doFinalize();

            return finalProcessedData;
        },

        keySize: 128/32,

        ivSize: 128/32,

        _ENC_XFORM_MODE: 1,

        _DEC_XFORM_MODE: 2,

        /**
         * Creates shortcut functions to a cipher's object interface.
         *
         * @param {Cipher} cipher The cipher to create a helper for.
         *
         * @return {Object} An object with encrypt and decrypt shortcut functions.
         *
         * @static
         *
         * @example
         *
         *     var AES = CryptoJS.lib.Cipher._createHelper(CryptoJS.algo.AES);
         */
        _createHelper: (function () {
            function selectCipherStrategy(key) {
                if (typeof key == 'string') {
                    return PasswordBasedCipher;
                } else {
                    return SerializableCipher;
                }
            }

            return function (cipher) {
                return {
                    encrypt: function (message, key, cfg) {
                        return selectCipherStrategy(key).encrypt(cipher, message, key, cfg);
                    },

                    decrypt: function (ciphertext, key, cfg) {
                        return selectCipherStrategy(key).decrypt(cipher, ciphertext, key, cfg);
                    }
                };
            };
        }())
    });

    /**
     * Abstract base stream cipher template.
     *
     * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 1 (32 bits)
     */
    var StreamCipher = C_lib.StreamCipher = Cipher.extend({
        _doFinalize: function () {
            // Process partial blocks
            var finalProcessedBlocks = this._process(!!'flush');

            return finalProcessedBlocks;
        },

        blockSize: 1
    });

    /**
     * Mode namespace.
     */
    var C_mode = C.mode = {};

    /**
     * Abstract base block cipher mode template.
     */
    var BlockCipherMode = C_lib.BlockCipherMode = Base.extend({
        /**
         * Creates this mode for encryption.
         *
         * @param {Cipher} cipher A block cipher instance.
         * @param {Array} iv The IV words.
         *
         * @static
         *
         * @example
         *
         *     var mode = CryptoJS.mode.CBC.createEncryptor(cipher, iv.words);
         */
        createEncryptor: function (cipher, iv) {
            return this.Encryptor.create(cipher, iv);
        },

        /**
         * Creates this mode for decryption.
         *
         * @param {Cipher} cipher A block cipher instance.
         * @param {Array} iv The IV words.
         *
         * @static
         *
         * @example
         *
         *     var mode = CryptoJS.mode.CBC.createDecryptor(cipher, iv.words);
         */
        createDecryptor: function (cipher, iv) {
            return this.Decryptor.create(cipher, iv);
        },

        /**
         * Initializes a newly created mode.
         *
         * @param {Cipher} cipher A block cipher instance.
         * @param {Array} iv The IV words.
         *
         * @example
         *
         *     var mode = CryptoJS.mode.CBC.Encryptor.create(cipher, iv.words);
         */
        init: function (cipher, iv) {
            this._cipher = cipher;
            this._iv = iv;
        }
    });

    /**
     * Cipher Block Chaining mode.
     */
    var CBC = C_mode.CBC = (function () {
        /**
         * Abstract base CBC mode.
         */
        var CBC = BlockCipherMode.extend();

        /**
         * CBC encryptor.
         */
        CBC.Encryptor = CBC.extend({
            /**
             * Processes the data block at offset.
             *
             * @param {Array} words The data words to operate on.
             * @param {number} offset The offset where the block starts.
             *
             * @example
             *
             *     mode.processBlock(data.words, offset);
             */
            processBlock: function (words, offset) {
                // Shortcuts
                var cipher = this._cipher;
                var blockSize = cipher.blockSize;

                // XOR and encrypt
                xorBlock.call(this, words, offset, blockSize);
                cipher.encryptBlock(words, offset);

                // Remember this block to use with next block
                this._prevBlock = words.slice(offset, offset + blockSize);
            }
        });

        /**
         * CBC decryptor.
         */
        CBC.Decryptor = CBC.extend({
            /**
             * Processes the data block at offset.
             *
             * @param {Array} words The data words to operate on.
             * @param {number} offset The offset where the block starts.
             *
             * @example
             *
             *     mode.processBlock(data.words, offset);
             */
            processBlock: function (words, offset) {
                // Shortcuts
                var cipher = this._cipher;
                var blockSize = cipher.blockSize;

                // Remember this block to use with next block
                var thisBlock = words.slice(offset, offset + blockSize);

                // Decrypt and XOR
                cipher.decryptBlock(words, offset);
                xorBlock.call(this, words, offset, blockSize);

                // This block becomes the previous block
                this._prevBlock = thisBlock;
            }
        });

        function xorBlock(words, offset, blockSize) {
            var block;

            // Shortcut
            var iv = this._iv;

            // Choose mixing block
            if (iv) {
                block = iv;

                // Remove IV for subsequent blocks
                this._iv = undefined;
            } else {
                block = this._prevBlock;
            }

            // XOR blocks
            for (var i = 0; i < blockSize; i++) {
                words[offset + i] ^= block[i];
            }
        }

        return CBC;
    }());

    /**
     * Padding namespace.
     */
    var C_pad = C.pad = {};

    /**
     * PKCS #5/7 padding strategy.
     */
    var Pkcs7 = C_pad.Pkcs7 = {
        /**
         * Pads data using the algorithm defined in PKCS #5/7.
         *
         * @param {WordArray} data The data to pad.
         * @param {number} blockSize The multiple that the data should be padded to.
         *
         * @static
         *
         * @example
         *
         *     CryptoJS.pad.Pkcs7.pad(wordArray, 4);
         */
        pad: function (data, blockSize) {
            // Shortcut
            var blockSizeBytes = blockSize * 4;

            // Count padding bytes
            var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes;

            // Create padding word
            var paddingWord = (nPaddingBytes << 24) | (nPaddingBytes << 16) | (nPaddingBytes << 8) | nPaddingBytes;

            // Create padding
            var paddingWords = [];
            for (var i = 0; i < nPaddingBytes; i += 4) {
                paddingWords.push(paddingWord);
            }
            var padding = WordArray.create(paddingWords, nPaddingBytes);

            // Add padding
            data.concat(padding);
        },

        /**
         * Unpads data that had been padded using the algorithm defined in PKCS #5/7.
         *
         * @param {WordArray} data The data to unpad.
         *
         * @static
         *
         * @example
         *
         *     CryptoJS.pad.Pkcs7.unpad(wordArray);
         */
        unpad: function (data) {
            // Get number of padding bytes from last byte
            var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;

            // Remove padding
            data.sigBytes -= nPaddingBytes;
        }
    };

    /**
     * Abstract base block cipher template.
     *
     * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 4 (128 bits)
     */
    var BlockCipher = C_lib.BlockCipher = Cipher.extend({
        /**
         * Configuration options.
         *
         * @property {Mode} mode The block mode to use. Default: CBC
         * @property {Padding} padding The padding strategy to use. Default: Pkcs7
         */
        cfg: Cipher.cfg.extend({
            mode: CBC,
            padding: Pkcs7
        }),

        reset: function () {
            var modeCreator;

            // Reset cipher
            Cipher.reset.call(this);

            // Shortcuts
            var cfg = this.cfg;
            var iv = cfg.iv;
            var mode = cfg.mode;

            // Reset block mode
            if (this._xformMode == this._ENC_XFORM_MODE) {
                modeCreator = mode.createEncryptor;
            } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {
                modeCreator = mode.createDecryptor;
                // Keep at least one block in the buffer for unpadding
                this._minBufferSize = 1;
            }

            if (this._mode && this._mode.__creator == modeCreator) {
                this._mode.init(this, iv && iv.words);
            } else {
                this._mode = modeCreator.call(mode, this, iv && iv.words);
                this._mode.__creator = modeCreator;
            }
        },

        _doProcessBlock: function (words, offset) {
            this._mode.processBlock(words, offset);
        },

        _doFinalize: function () {
            var finalProcessedBlocks;

            // Shortcut
            var padding = this.cfg.padding;

            // Finalize
            if (this._xformMode == this._ENC_XFORM_MODE) {
                // Pad data
                padding.pad(this._data, this.blockSize);

                // Process final blocks
                finalProcessedBlocks = this._process(!!'flush');
            } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {
                // Process final blocks
                finalProcessedBlocks = this._process(!!'flush');

                // Unpad data
                padding.unpad(finalProcessedBlocks);
            }

            return finalProcessedBlocks;
        },

        blockSize: 128/32
    });

    /**
     * A collection of cipher parameters.
     *
     * @property {WordArray} ciphertext The raw ciphertext.
     * @property {WordArray} key The key to this ciphertext.
     * @property {WordArray} iv The IV used in the ciphering operation.
     * @property {WordArray} salt The salt used with a key derivation function.
     * @property {Cipher} algorithm The cipher algorithm.
     * @property {Mode} mode The block mode used in the ciphering operation.
     * @property {Padding} padding The padding scheme used in the ciphering operation.
     * @property {number} blockSize The block size of the cipher.
     * @property {Format} formatter The default formatting strategy to convert this cipher params object to a string.
     */
    var CipherParams = C_lib.CipherParams = Base.extend({
        /**
         * Initializes a newly created cipher params object.
         *
         * @param {Object} cipherParams An object with any of the possible cipher parameters.
         *
         * @example
         *
         *     var cipherParams = CryptoJS.lib.CipherParams.create({
         *         ciphertext: ciphertextWordArray,
         *         key: keyWordArray,
         *         iv: ivWordArray,
         *         salt: saltWordArray,
         *         algorithm: CryptoJS.algo.AES,
         *         mode: CryptoJS.mode.CBC,
         *         padding: CryptoJS.pad.PKCS7,
         *         blockSize: 4,
         *         formatter: CryptoJS.format.OpenSSL
         *     });
         */
        init: function (cipherParams) {
            this.mixIn(cipherParams);
        },

        /**
         * Converts this cipher params object to a string.
         *
         * @param {Format} formatter (Optional) The formatting strategy to use.
         *
         * @return {string} The stringified cipher params.
         *
         * @throws Error If neither the formatter nor the default formatter is set.
         *
         * @example
         *
         *     var string = cipherParams + '';
         *     var string = cipherParams.toString();
         *     var string = cipherParams.toString(CryptoJS.format.OpenSSL);
         */
        toString: function (formatter) {
            return (formatter || this.formatter).stringify(this);
        }
    });

    /**
     * Format namespace.
     */
    var C_format = C.format = {};

    /**
     * OpenSSL formatting strategy.
     */
    var OpenSSLFormatter = C_format.OpenSSL = {
        /**
         * Converts a cipher params object to an OpenSSL-compatible string.
         *
         * @param {CipherParams} cipherParams The cipher params object.
         *
         * @return {string} The OpenSSL-compatible string.
         *
         * @static
         *
         * @example
         *
         *     var openSSLString = CryptoJS.format.OpenSSL.stringify(cipherParams);
         */
        stringify: function (cipherParams) {
            var wordArray;

            // Shortcuts
            var ciphertext = cipherParams.ciphertext;
            var salt = cipherParams.salt;

            // Format
            if (salt) {
                wordArray = WordArray.create([0x53616c74, 0x65645f5f]).concat(salt).concat(ciphertext);
            } else {
                wordArray = ciphertext;
            }

            return wordArray.toString(Base64);
        },

        /**
         * Converts an OpenSSL-compatible string to a cipher params object.
         *
         * @param {string} openSSLStr The OpenSSL-compatible string.
         *
         * @return {CipherParams} The cipher params object.
         *
         * @static
         *
         * @example
         *
         *     var cipherParams = CryptoJS.format.OpenSSL.parse(openSSLString);
         */
        parse: function (openSSLStr) {
            var salt;

            // Parse base64
            var ciphertext = Base64.parse(openSSLStr);

            // Shortcut
            var ciphertextWords = ciphertext.words;

            // Test for salt
            if (ciphertextWords[0] == 0x53616c74 && ciphertextWords[1] == 0x65645f5f) {
                // Extract salt
                salt = WordArray.create(ciphertextWords.slice(2, 4));

                // Remove salt from ciphertext
                ciphertextWords.splice(0, 4);
                ciphertext.sigBytes -= 16;
            }

            return CipherParams.create({ ciphertext: ciphertext, salt: salt });
        }
    };

    /**
     * A cipher wrapper that returns ciphertext as a serializable cipher params object.
     */
    var SerializableCipher = C_lib.SerializableCipher = Base.extend({
        /**
         * Configuration options.
         *
         * @property {Formatter} format The formatting strategy to convert cipher param objects to and from a string. Default: OpenSSL
         */
        cfg: Base.extend({
            format: OpenSSLFormatter
        }),

        /**
         * Encrypts a message.
         *
         * @param {Cipher} cipher The cipher algorithm to use.
         * @param {WordArray|string} message The message to encrypt.
         * @param {WordArray} key The key.
         * @param {Object} cfg (Optional) The configuration options to use for this operation.
         *
         * @return {CipherParams} A cipher params object.
         *
         * @static
         *
         * @example
         *
         *     var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key);
         *     var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv });
         *     var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv, format: CryptoJS.format.OpenSSL });
         */
        encrypt: function (cipher, message, key, cfg) {
            // Apply config defaults
            cfg = this.cfg.extend(cfg);

            // Encrypt
            var encryptor = cipher.createEncryptor(key, cfg);
            var ciphertext = encryptor.finalize(message);

            // Shortcut
            var cipherCfg = encryptor.cfg;

            // Create and return serializable cipher params
            return CipherParams.create({
                ciphertext: ciphertext,
                key: key,
                iv: cipherCfg.iv,
                algorithm: cipher,
                mode: cipherCfg.mode,
                padding: cipherCfg.padding,
                blockSize: cipher.blockSize,
                formatter: cfg.format
            });
        },

        /**
         * Decrypts serialized ciphertext.
         *
         * @param {Cipher} cipher The cipher algorithm to use.
         * @param {CipherParams|string} ciphertext The ciphertext to decrypt.
         * @param {WordArray} key The key.
         * @param {Object} cfg (Optional) The configuration options to use for this operation.
         *
         * @return {WordArray} The plaintext.
         *
         * @static
         *
         * @example
         *
         *     var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, key, { iv: iv, format: CryptoJS.format.OpenSSL });
         *     var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, key, { iv: iv, format: CryptoJS.format.OpenSSL });
         */
        decrypt: function (cipher, ciphertext, key, cfg) {
            // Apply config defaults
            cfg = this.cfg.extend(cfg);

            // Convert string to CipherParams
            ciphertext = this._parse(ciphertext, cfg.format);

            // Decrypt
            var plaintext = cipher.createDecryptor(key, cfg).finalize(ciphertext.ciphertext);

            return plaintext;
        },

        /**
         * Converts serialized ciphertext to CipherParams,
         * else assumed CipherParams already and returns ciphertext unchanged.
         *
         * @param {CipherParams|string} ciphertext The ciphertext.
         * @param {Formatter} format The formatting strategy to use to parse serialized ciphertext.
         *
         * @return {CipherParams} The unserialized ciphertext.
         *
         * @static
         *
         * @example
         *
         *     var ciphertextParams = CryptoJS.lib.SerializableCipher._parse(ciphertextStringOrParams, format);
         */
        _parse: function (ciphertext, format) {
            if (typeof ciphertext == 'string') {
                return format.parse(ciphertext, this);
            } else {
                return ciphertext;
            }
        }
    });

    /**
     * Key derivation function namespace.
     */
    var C_kdf = C.kdf = {};

    /**
     * OpenSSL key derivation function.
     */
    var OpenSSLKdf = C_kdf.OpenSSL = {
        /**
         * Derives a key and IV from a password.
         *
         * @param {string} password The password to derive from.
         * @param {number} keySize The size in words of the key to generate.
         * @param {number} ivSize The size in words of the IV to generate.
         * @param {WordArray|string} salt (Optional) A 64-bit salt to use. If omitted, a salt will be generated randomly.
         *
         * @return {CipherParams} A cipher params object with the key, IV, and salt.
         *
         * @static
         *
         * @example
         *
         *     var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32);
         *     var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32, 'saltsalt');
         */
        execute: function (password, keySize, ivSize, salt, hasher) {
            // Generate random salt
            if (!salt) {
                salt = WordArray.random(64/8);
            }

            // Derive key and IV
            if (!hasher) {
                var key = EvpKDF.create({ keySize: keySize + ivSize }).compute(password, salt);
            } else {
                var key = EvpKDF.create({ keySize: keySize + ivSize, hasher: hasher }).compute(password, salt);
            }
            

            // Separate key and IV
            var iv = WordArray.create(key.words.slice(keySize), ivSize * 4);
            key.sigBytes = keySize * 4;

            // Return params
            return CipherParams.create({ key: key, iv: iv, salt: salt });
        }
    };

    /**
     * A serializable cipher wrapper that derives the key from a password,
     * and returns ciphertext as a serializable cipher params object.
     */
    var PasswordBasedCipher = C_lib.PasswordBasedCipher = SerializableCipher.extend({
        /**
         * Configuration options.
         *
         * @property {KDF} kdf The key derivation function to use to generate a key and IV from a password. Default: OpenSSL
         */
        cfg: SerializableCipher.cfg.extend({
            kdf: OpenSSLKdf
        }),

        /**
         * Encrypts a message using a password.
         *
         * @param {Cipher} cipher The cipher algorithm to use.
         * @param {WordArray|string} message The message to encrypt.
         * @param {string} password The password.
         * @param {Object} cfg (Optional) The configuration options to use for this operation.
         *
         * @return {CipherParams} A cipher params object.
         *
         * @static
         *
         * @example
         *
         *     var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password');
         *     var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password', { format: CryptoJS.format.OpenSSL });
         */
        encrypt: function (cipher, message, password, cfg) {
            // Apply config defaults
            cfg = this.cfg.extend(cfg);

            // Derive key and other params
            var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize, cfg.salt, cfg.hasher);

            // Add IV to config
            cfg.iv = derivedParams.iv;

            // Encrypt
            var ciphertext = SerializableCipher.encrypt.call(this, cipher, message, derivedParams.key, cfg);

            // Mix in derived params
            ciphertext.mixIn(derivedParams);

            return ciphertext;
        },

        /**
         * Decrypts serialized ciphertext using a password.
         *
         * @param {Cipher} cipher The cipher algorithm to use.
         * @param {CipherParams|string} ciphertext The ciphertext to decrypt.
         * @param {string} password The password.
         * @param {Object} cfg (Optional) The configuration options to use for this operation.
         *
         * @return {WordArray} The plaintext.
         *
         * @static
         *
         * @example
         *
         *     var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, 'password', { format: CryptoJS.format.OpenSSL });
         *     var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, 'password', { format: CryptoJS.format.OpenSSL });
         */
        decrypt: function (cipher, ciphertext, password, cfg) {
            // Apply config defaults
            cfg = this.cfg.extend(cfg);

            // Convert string to CipherParams
            ciphertext = this._parse(ciphertext, cfg.format);

            // Derive key and other params
            var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize, ciphertext.salt, cfg.hasher);

            // Add IV to config
            cfg.iv = derivedParams.iv;

            // Decrypt
            var plaintext = SerializableCipher.decrypt.call(this, cipher, ciphertext, derivedParams.key, cfg);

            return plaintext;
        }
    });
}());
/*globals window, global, require*/

/**
 * CryptoJS core components.
 */
var CryptoJS = CryptoJS || (function (Math, undefined) {

    var crypto;

    // Native crypto from window (Browser)
    if (typeof window !== 'undefined' && window.crypto) {
        crypto = window.crypto;
    }

    // Native crypto in web worker (Browser)
    if (typeof self !== 'undefined' && self.crypto) {
        crypto = self.crypto;
    }

    // Native crypto from worker
    if (typeof globalThis !== 'undefined' && globalThis.crypto) {
        crypto = globalThis.crypto;
    }

    // Native (experimental IE 11) crypto from window (Browser)
    if (!crypto && typeof window !== 'undefined' && window.msCrypto) {
        crypto = window.msCrypto;
    }

    // Native crypto from global (NodeJS)
    if (!crypto && typeof global !== 'undefined' && global.crypto) {
        crypto = global.crypto;
    }

    // Native crypto import via require (NodeJS)
    if (!crypto && typeof require === 'function') {
        try {
            crypto = require('crypto');
        } catch (err) {}
    }

    /*
     * Cryptographically secure pseudorandom number generator
     *
     * As Math.random() is cryptographically not safe to use
     */
    var cryptoSecureRandomInt = function () {
        if (crypto) {
            // Use getRandomValues method (Browser)
            if (typeof crypto.getRandomValues === 'function') {
                try {
                    return crypto.getRandomValues(new Uint32Array(1))[0];
                } catch (err) {}
            }

            // Use randomBytes method (NodeJS)
            if (typeof crypto.randomBytes === 'function') {
                try {
                    return crypto.randomBytes(4).readInt32LE();
                } catch (err) {}
            }
        }

        throw new Error('Native crypto module could not be used to get secure random number.');
    };

    /*
     * Local polyfill of Object.create

     */
    var create = Object.create || (function () {
        function F() {}

        return function (obj) {
            var subtype;

            F.prototype = obj;

            subtype = new F();

            F.prototype = null;

            return subtype;
        };
    }());

    /**
     * CryptoJS namespace.
     */
    var C = {};

    /**
     * Library namespace.
     */
    var C_lib = C.lib = {};

    /**
     * Base object for prototypal inheritance.
     */
    var Base = C_lib.Base = (function () {


        return {
            /**
             * Creates a new object that inherits from this object.
             *
             * @param {Object} overrides Properties to copy into the new object.
             *
             * @return {Object} The new object.
             *
             * @static
             *
             * @example
             *
             *     var MyType = CryptoJS.lib.Base.extend({
             *         field: 'value',
             *
             *         method: function () {
             *         }
             *     });
             */
            extend: function (overrides) {
                // Spawn
                var subtype = create(this);

                // Augment
                if (overrides) {
                    subtype.mixIn(overrides);
                }

                // Create default initializer
                if (!subtype.hasOwnProperty('init') || this.init === subtype.init) {
                    subtype.init = function () {
                        subtype.$super.init.apply(this, arguments);
                    };
                }

                // Initializer's prototype is the subtype object
                subtype.init.prototype = subtype;

                // Reference supertype
                subtype.$super = this;

                return subtype;
            },

            /**
             * Extends this object and runs the init method.
             * Arguments to create() will be passed to init().
             *
             * @return {Object} The new object.
             *
             * @static
             *
             * @example
             *
             *     var instance = MyType.create();
             */
            create: function () {
                var instance = this.extend();
                instance.init.apply(instance, arguments);

                return instance;
            },

            /**
             * Initializes a newly created object.
             * Override this method to add some logic when your objects are created.
             *
             * @example
             *
             *     var MyType = CryptoJS.lib.Base.extend({
             *         init: function () {
             *             // ...
             *         }
             *     });
             */
            init: function () {
            },

            /**
             * Copies properties into this object.
             *
             * @param {Object} properties The properties to mix in.
             *
             * @example
             *
             *     MyType.mixIn({
             *         field: 'value'
             *     });
             */
            mixIn: function (properties) {
                for (var propertyName in properties) {
                    if (properties.hasOwnProperty(propertyName)) {
                        this[propertyName] = properties[propertyName];
                    }
                }

                // IE won't copy toString using the loop above
                if (properties.hasOwnProperty('toString')) {
                    this.toString = properties.toString;
                }
            },

            /**
             * Creates a copy of this object.
             *
             * @return {Object} The clone.
             *
             * @example
             *
             *     var clone = instance.clone();
             */
            clone: function () {
                return this.init.prototype.extend(this);
            }
        };
    }());

    /**
     * An array of 32-bit words.
     *
     * @property {Array} words The array of 32-bit words.
     * @property {number} sigBytes The number of significant bytes in this word array.
     */
    var WordArray = C_lib.WordArray = Base.extend({
        /**
         * Initializes a newly created word array.
         *
         * @param {Array} words (Optional) An array of 32-bit words.
         * @param {number} sigBytes (Optional) The number of significant bytes in the words.
         *
         * @example
         *
         *     var wordArray = CryptoJS.lib.WordArray.create();
         *     var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]);
         *     var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6);
         */
        init: function (words, sigBytes) {
            words = this.words = words || [];

            if (sigBytes != undefined) {
                this.sigBytes = sigBytes;
            } else {
                this.sigBytes = words.length * 4;
            }
        },

        /**
         * Converts this word array to a string.
         *
         * @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex
         *
         * @return {string} The stringified word array.
         *
         * @example
         *
         *     var string = wordArray + '';
         *     var string = wordArray.toString();
         *     var string = wordArray.toString(CryptoJS.enc.Utf8);
         */
        toString: function (encoder) {
            return (encoder || Hex).stringify(this);
        },

        /**
         * Concatenates a word array to this word array.
         *
         * @param {WordArray} wordArray The word array to append.
         *
         * @return {WordArray} This word array.
         *
         * @example
         *
         *     wordArray1.concat(wordArray2);
         */
        concat: function (wordArray) {
            // Shortcuts
            var thisWords = this.words;
            var thatWords = wordArray.words;
            var thisSigBytes = this.sigBytes;
            var thatSigBytes = wordArray.sigBytes;

            // Clamp excess bits
            this.clamp();

            // Concat
            if (thisSigBytes % 4) {
                // Copy one byte at a time
                for (var i = 0; i < thatSigBytes; i++) {
                    var thatByte = (thatWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
                    thisWords[(thisSigBytes + i) >>> 2] |= thatByte << (24 - ((thisSigBytes + i) % 4) * 8);
                }
            } else {
                // Copy one word at a time
                for (var j = 0; j < thatSigBytes; j += 4) {
                    thisWords[(thisSigBytes + j) >>> 2] = thatWords[j >>> 2];
                }
            }
            this.sigBytes += thatSigBytes;

            // Chainable
            return this;
        },

        /**
         * Removes insignificant bits.
         *
         * @example
         *
         *     wordArray.clamp();
         */
        clamp: function () {
            // Shortcuts
            var words = this.words;
            var sigBytes = this.sigBytes;

            // Clamp
            words[sigBytes >>> 2] &= 0xffffffff << (32 - (sigBytes % 4) * 8);
            words.length = Math.ceil(sigBytes / 4);
        },

        /**
         * Creates a copy of this word array.
         *
         * @return {WordArray} The clone.
         *
         * @example
         *
         *     var clone = wordArray.clone();
         */
        clone: function () {
            var clone = Base.clone.call(this);
            clone.words = this.words.slice(0);

            return clone;
        },

        /**
         * Creates a word array filled with random bytes.
         *
         * @param {number} nBytes The number of random bytes to generate.
         *
         * @return {WordArray} The random word array.
         *
         * @static
         *
         * @example
         *
         *     var wordArray = CryptoJS.lib.WordArray.random(16);
         */
        random: function (nBytes) {
            var words = [];

            for (var i = 0; i < nBytes; i += 4) {
                words.push(cryptoSecureRandomInt());
            }

            return new WordArray.init(words, nBytes);
        }
    });

    /**
     * Encoder namespace.
     */
    var C_enc = C.enc = {};

    /**
     * Hex encoding strategy.
     */
    var Hex = C_enc.Hex = {
        /**
         * Converts a word array to a hex string.
         *
         * @param {WordArray} wordArray The word array.
         *
         * @return {string} The hex string.
         *
         * @static
         *
         * @example
         *
         *     var hexString = CryptoJS.enc.Hex.stringify(wordArray);
         */
        stringify: function (wordArray) {
            // Shortcuts
            var words = wordArray.words;
            var sigBytes = wordArray.sigBytes;

            // Convert
            var hexChars = [];
            for (var i = 0; i < sigBytes; i++) {
                var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
                hexChars.push((bite >>> 4).toString(16));
                hexChars.push((bite & 0x0f).toString(16));
            }

            return hexChars.join('');
        },

        /**
         * Converts a hex string to a word array.
         *
         * @param {string} hexStr The hex string.
         *
         * @return {WordArray} The word array.
         *
         * @static
         *
         * @example
         *
         *     var wordArray = CryptoJS.enc.Hex.parse(hexString);
         */
        parse: function (hexStr) {
            // Shortcut
            var hexStrLength = hexStr.length;

            // Convert
            var words = [];
            for (var i = 0; i < hexStrLength; i += 2) {
                words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << (24 - (i % 8) * 4);
            }

            return new WordArray.init(words, hexStrLength / 2);
        }
    };

    /**
     * Latin1 encoding strategy.
     */
    var Latin1 = C_enc.Latin1 = {
        /**
         * Converts a word array to a Latin1 string.
         *
         * @param {WordArray} wordArray The word array.
         *
         * @return {string} The Latin1 string.
         *
         * @static
         *
         * @example
         *
         *     var latin1String = CryptoJS.enc.Latin1.stringify(wordArray);
         */
        stringify: function (wordArray) {
            // Shortcuts
            var words = wordArray.words;
            var sigBytes = wordArray.sigBytes;

            // Convert
            var latin1Chars = [];
            for (var i = 0; i < sigBytes; i++) {
                var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
                latin1Chars.push(String.fromCharCode(bite));
            }

            return latin1Chars.join('');
        },

        /**
         * Converts a Latin1 string to a word array.
         *
         * @param {string} latin1Str The Latin1 string.
         *
         * @return {WordArray} The word array.
         *
         * @static
         *
         * @example
         *
         *     var wordArray = CryptoJS.enc.Latin1.parse(latin1String);
         */
        parse: function (latin1Str) {
            // Shortcut
            var latin1StrLength = latin1Str.length;

            // Convert
            var words = [];
            for (var i = 0; i < latin1StrLength; i++) {
                words[i >>> 2] |= (latin1Str.charCodeAt(i) & 0xff) << (24 - (i % 4) * 8);
            }

            return new WordArray.init(words, latin1StrLength);
        }
    };

    /**
     * UTF-8 encoding strategy.
     */
    var Utf8 = C_enc.Utf8 = {
        /**
         * Converts a word array to a UTF-8 string.
         *
         * @param {WordArray} wordArray The word array.
         *
         * @return {string} The UTF-8 string.
         *
         * @static
         *
         * @example
         *
         *     var utf8String = CryptoJS.enc.Utf8.stringify(wordArray);
         */
        stringify: function (wordArray) {
            try {
                return decodeURIComponent(escape(Latin1.stringify(wordArray)));
            } catch (e) {
                throw new Error('Malformed UTF-8 data');
            }
        },

        /**
         * Converts a UTF-8 string to a word array.
         *
         * @param {string} utf8Str The UTF-8 string.
         *
         * @return {WordArray} The word array.
         *
         * @static
         *
         * @example
         *
         *     var wordArray = CryptoJS.enc.Utf8.parse(utf8String);
         */
        parse: function (utf8Str) {
            return Latin1.parse(unescape(encodeURIComponent(utf8Str)));
        }
    };

    /**
     * Abstract buffered block algorithm template.
     *
     * The property blockSize must be implemented in a concrete subtype.
     *
     * @property {number} _minBufferSize The number of blocks that should be kept unprocessed in the buffer. Default: 0
     */
    var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({
        /**
         * Resets this block algorithm's data buffer to its initial state.
         *
         * @example
         *
         *     bufferedBlockAlgorithm.reset();
         */
        reset: function () {
            // Initial values
            this._data = new WordArray.init();
            this._nDataBytes = 0;
        },

        /**
         * Adds new data to this block algorithm's buffer.
         *
         * @param {WordArray|string} data The data to append. Strings are converted to a WordArray using UTF-8.
         *
         * @example
         *
         *     bufferedBlockAlgorithm._append('data');
         *     bufferedBlockAlgorithm._append(wordArray);
         */
        _append: function (data) {
            // Convert string to WordArray, else assume WordArray already
            if (typeof data == 'string') {
                data = Utf8.parse(data);
            }

            // Append
            this._data.concat(data);
            this._nDataBytes += data.sigBytes;
        },

        /**
         * Processes available data blocks.
         *
         * This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype.
         *
         * @param {boolean} doFlush Whether all blocks and partial blocks should be processed.
         *
         * @return {WordArray} The processed data.
         *
         * @example
         *
         *     var processedData = bufferedBlockAlgorithm._process();
         *     var processedData = bufferedBlockAlgorithm._process(!!'flush');
         */
        _process: function (doFlush) {
            var processedWords;

            // Shortcuts
            var data = this._data;
            var dataWords = data.words;
            var dataSigBytes = data.sigBytes;
            var blockSize = this.blockSize;
            var blockSizeBytes = blockSize * 4;

            // Count blocks ready
            var nBlocksReady = dataSigBytes / blockSizeBytes;
            if (doFlush) {
                // Round up to include partial blocks
                nBlocksReady = Math.ceil(nBlocksReady);
            } else {
                // Round down to include only full blocks,
                // less the number of blocks that must remain in the buffer
                nBlocksReady = Math.max((nBlocksReady | 0) - this._minBufferSize, 0);
            }

            // Count words ready
            var nWordsReady = nBlocksReady * blockSize;

            // Count bytes ready
            var nBytesReady = Math.min(nWordsReady * 4, dataSigBytes);

            // Process blocks
            if (nWordsReady) {
                for (var offset = 0; offset < nWordsReady; offset += blockSize) {
                    // Perform concrete-algorithm logic
                    this._doProcessBlock(dataWords, offset);
                }

                // Remove processed words
                processedWords = dataWords.splice(0, nWordsReady);
                data.sigBytes -= nBytesReady;
            }

            // Return processed words
            return new WordArray.init(processedWords, nBytesReady);
        },

        /**
         * Creates a copy of this object.
         *
         * @return {Object} The clone.
         *
         * @example
         *
         *     var clone = bufferedBlockAlgorithm.clone();
         */
        clone: function () {
            var clone = Base.clone.call(this);
            clone._data = this._data.clone();

            return clone;
        },

        _minBufferSize: 0
    });

    /**
     * Abstract hasher template.
     *
     * @property {number} blockSize The number of 32-bit words this hasher operates on. Default: 16 (512 bits)
     */
    var Hasher = C_lib.Hasher = BufferedBlockAlgorithm.extend({
        /**
         * Configuration options.
         */
        cfg: Base.extend(),

        /**
         * Initializes a newly created hasher.
         *
         * @param {Object} cfg (Optional) The configuration options to use for this hash computation.
         *
         * @example
         *
         *     var hasher = CryptoJS.algo.SHA256.create();
         */
        init: function (cfg) {
            // Apply config defaults
            this.cfg = this.cfg.extend(cfg);

            // Set initial values
            this.reset();
        },

        /**
         * Resets this hasher to its initial state.
         *
         * @example
         *
         *     hasher.reset();
         */
        reset: function () {
            // Reset data buffer
            BufferedBlockAlgorithm.reset.call(this);

            // Perform concrete-hasher logic
            this._doReset();
        },

        /**
         * Updates this hasher with a message.
         *
         * @param {WordArray|string} messageUpdate The message to append.
         *
         * @return {Hasher} This hasher.
         *
         * @example
         *
         *     hasher.update('message');
         *     hasher.update(wordArray);
         */
        update: function (messageUpdate) {
            // Append
            this._append(messageUpdate);

            // Update the hash
            this._process();

            // Chainable
            return this;
        },

        /**
         * Finalizes the hash computation.
         * Note that the finalize operation is effectively a destructive, read-once operation.
         *
         * @param {WordArray|string} messageUpdate (Optional) A final message update.
         *
         * @return {WordArray} The hash.
         *
         * @example
         *
         *     var hash = hasher.finalize();
         *     var hash = hasher.finalize('message');
         *     var hash = hasher.finalize(wordArray);
         */
        finalize: function (messageUpdate) {
            // Final message update
            if (messageUpdate) {
                this._append(messageUpdate);
            }

            // Perform concrete-hasher logic
            var hash = this._doFinalize();

            return hash;
        },

        blockSize: 512/32,

        /**
         * Creates a shortcut function to a hasher's object interface.
         *
         * @param {Hasher} hasher The hasher to create a helper for.
         *
         * @return {Function} The shortcut function.
         *
         * @static
         *
         * @example
         *
         *     var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256);
         */
        _createHelper: function (hasher) {
            return function (message, cfg) {
                return new hasher.init(cfg).finalize(message);
            };
        },

        /**
         * Creates a shortcut function to the HMAC's object interface.
         *
         * @param {Hasher} hasher The hasher to use in this HMAC helper.
         *
         * @return {Function} The shortcut function.
         *
         * @static
         *
         * @example
         *
         *     var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256);
         */
        _createHmacHelper: function (hasher) {
            return function (message, key) {
                return new C_algo.HMAC.init(hasher, key).finalize(message);
            };
        }
    });

    /**
     * Algorithm namespace.
     */
    var C_algo = C.algo = {};

    return C;
}(Math));
(function () {
    // Shortcuts
    var C = CryptoJS;
    var C_lib = C.lib;
    var WordArray = C_lib.WordArray;
    var C_enc = C.enc;

    /**
     * Base64 encoding strategy.
     */
    var Base64 = C_enc.Base64 = {
        /**
         * Converts a word array to a Base64 string.
         *
         * @param {WordArray} wordArray The word array.
         *
         * @return {string} The Base64 string.
         *
         * @static
         *
         * @example
         *
         *     var base64String = CryptoJS.enc.Base64.stringify(wordArray);
         */
        stringify: function (wordArray) {
            // Shortcuts
            var words = wordArray.words;
            var sigBytes = wordArray.sigBytes;
            var map = this._map;

            // Clamp excess bits
            wordArray.clamp();

            // Convert
            var base64Chars = [];
            for (var i = 0; i < sigBytes; i += 3) {
                var byte1 = (words[i >>> 2]       >>> (24 - (i % 4) * 8))       & 0xff;
                var byte2 = (words[(i + 1) >>> 2] >>> (24 - ((i + 1) % 4) * 8)) & 0xff;
                var byte3 = (words[(i + 2) >>> 2] >>> (24 - ((i + 2) % 4) * 8)) & 0xff;

                var triplet = (byte1 << 16) | (byte2 << 8) | byte3;

                for (var j = 0; (j < 4) && (i + j * 0.75 < sigBytes); j++) {
                    base64Chars.push(map.charAt((triplet >>> (6 * (3 - j))) & 0x3f));
                }
            }

            // Add padding
            var paddingChar = map.charAt(64);
            if (paddingChar) {
                while (base64Chars.length % 4) {
                    base64Chars.push(paddingChar);
                }
            }

            return base64Chars.join('');
        },

        /**
         * Converts a Base64 string to a word array.
         *
         * @param {string} base64Str The Base64 string.
         *
         * @return {WordArray} The word array.
         *
         * @static
         *
         * @example
         *
         *     var wordArray = CryptoJS.enc.Base64.parse(base64String);
         */
        parse: function (base64Str) {
            // Shortcuts
            var base64StrLength = base64Str.length;
            var map = this._map;
            var reverseMap = this._reverseMap;

            if (!reverseMap) {
                    reverseMap = this._reverseMap = [];
                    for (var j = 0; j < map.length; j++) {
                        reverseMap[map.charCodeAt(j)] = j;
                    }
            }

            // Ignore padding
            var paddingChar = map.charAt(64);
            if (paddingChar) {
                var paddingIndex = base64Str.indexOf(paddingChar);
                if (paddingIndex !== -1) {
                    base64StrLength = paddingIndex;
                }
            }

            // Convert
            return parseLoop(base64Str, base64StrLength, reverseMap);

        },

        _map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='
    };

    function parseLoop(base64Str, base64StrLength, reverseMap) {
      var words = [];
      var nBytes = 0;
      for (var i = 0; i < base64StrLength; i++) {
          if (i % 4) {
              var bits1 = reverseMap[base64Str.charCodeAt(i - 1)] << ((i % 4) * 2);
              var bits2 = reverseMap[base64Str.charCodeAt(i)] >>> (6 - (i % 4) * 2);
              var bitsCombined = bits1 | bits2;
              words[nBytes >>> 2] |= bitsCombined << (24 - (nBytes % 4) * 8);
              nBytes++;
          }
      }
      return WordArray.create(words, nBytes);
    }
}());
(function () {
    // Shortcuts
    var C = CryptoJS;
    var C_lib = C.lib;
    var WordArray = C_lib.WordArray;
    var C_enc = C.enc;

    /**
     * Base64url encoding strategy.
     */
    var Base64url = C_enc.Base64url = {
        /**
         * Converts a word array to a Base64url string.
         *
         * @param {WordArray} wordArray The word array.
         *
         * @param {boolean} urlSafe Whether to use url safe
         *
         * @return {string} The Base64url string.
         *
         * @static
         *
         * @example
         *
         *     var base64String = CryptoJS.enc.Base64url.stringify(wordArray);
         */
        stringify: function (wordArray, urlSafe) {
            if (urlSafe === undefined) {
                urlSafe = true
            }
            // Shortcuts
            var words = wordArray.words;
            var sigBytes = wordArray.sigBytes;
            var map = urlSafe ? this._safe_map : this._map;

            // Clamp excess bits
            wordArray.clamp();

            // Convert
            var base64Chars = [];
            for (var i = 0; i < sigBytes; i += 3) {
                var byte1 = (words[i >>> 2]       >>> (24 - (i % 4) * 8))       & 0xff;
                var byte2 = (words[(i + 1) >>> 2] >>> (24 - ((i + 1) % 4) * 8)) & 0xff;
                var byte3 = (words[(i + 2) >>> 2] >>> (24 - ((i + 2) % 4) * 8)) & 0xff;

                var triplet = (byte1 << 16) | (byte2 << 8) | byte3;

                for (var j = 0; (j < 4) && (i + j * 0.75 < sigBytes); j++) {
                    base64Chars.push(map.charAt((triplet >>> (6 * (3 - j))) & 0x3f));
                }
            }

            // Add padding
            var paddingChar = map.charAt(64);
            if (paddingChar) {
                while (base64Chars.length % 4) {
                    base64Chars.push(paddingChar);
                }
            }

            return base64Chars.join('');
        },

        /**
         * Converts a Base64url string to a word array.
         *
         * @param {string} base64Str The Base64url string.
         *
         * @param {boolean} urlSafe Whether to use url safe
         *
         * @return {WordArray} The word array.
         *
         * @static
         *
         * @example
         *
         *     var wordArray = CryptoJS.enc.Base64url.parse(base64String);
         */
        parse: function (base64Str, urlSafe) {
            if (urlSafe === undefined) {
                urlSafe = true
            }

            // Shortcuts
            var base64StrLength = base64Str.length;
            var map = urlSafe ? this._safe_map : this._map;
            var reverseMap = this._reverseMap;

            if (!reverseMap) {
                reverseMap = this._reverseMap = [];
                for (var j = 0; j < map.length; j++) {
                    reverseMap[map.charCodeAt(j)] = j;
                }
            }

            // Ignore padding
            var paddingChar = map.charAt(64);
            if (paddingChar) {
                var paddingIndex = base64Str.indexOf(paddingChar);
                if (paddingIndex !== -1) {
                    base64StrLength = paddingIndex;
                }
            }

            // Convert
            return parseLoop(base64Str, base64StrLength, reverseMap);

        },

        _map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=',
        _safe_map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_',
    };

    function parseLoop(base64Str, base64StrLength, reverseMap) {
        var words = [];
        var nBytes = 0;
        for (var i = 0; i < base64StrLength; i++) {
            if (i % 4) {
                var bits1 = reverseMap[base64Str.charCodeAt(i - 1)] << ((i % 4) * 2);
                var bits2 = reverseMap[base64Str.charCodeAt(i)] >>> (6 - (i % 4) * 2);
                var bitsCombined = bits1 | bits2;
                words[nBytes >>> 2] |= bitsCombined << (24 - (nBytes % 4) * 8);
                nBytes++;
            }
        }
        return WordArray.create(words, nBytes);
    }
}());
(function () {
    // Shortcuts
    var C = CryptoJS;
    var C_lib = C.lib;
    var WordArray = C_lib.WordArray;
    var C_enc = C.enc;

    /**
     * UTF-16 BE encoding strategy.
     */
    var Utf16BE = C_enc.Utf16 = C_enc.Utf16BE = {
        /**
         * Converts a word array to a UTF-16 BE string.
         *
         * @param {WordArray} wordArray The word array.
         *
         * @return {string} The UTF-16 BE string.
         *
         * @static
         *
         * @example
         *
         *     var utf16String = CryptoJS.enc.Utf16.stringify(wordArray);
         */
        stringify: function (wordArray) {
            // Shortcuts
            var words = wordArray.words;
            var sigBytes = wordArray.sigBytes;

            // Convert
            var utf16Chars = [];
            for (var i = 0; i < sigBytes; i += 2) {
                var codePoint = (words[i >>> 2] >>> (16 - (i % 4) * 8)) & 0xffff;
                utf16Chars.push(String.fromCharCode(codePoint));
            }

            return utf16Chars.join('');
        },

        /**
         * Converts a UTF-16 BE string to a word array.
         *
         * @param {string} utf16Str The UTF-16 BE string.
         *
         * @return {WordArray} The word array.
         *
         * @static
         *
         * @example
         *
         *     var wordArray = CryptoJS.enc.Utf16.parse(utf16String);
         */
        parse: function (utf16Str) {
            // Shortcut
            var utf16StrLength = utf16Str.length;

            // Convert
            var words = [];
            for (var i = 0; i < utf16StrLength; i++) {
                words[i >>> 1] |= utf16Str.charCodeAt(i) << (16 - (i % 2) * 16);
            }

            return WordArray.create(words, utf16StrLength * 2);
        }
    };

    /**
     * UTF-16 LE encoding strategy.
     */
    C_enc.Utf16LE = {
        /**
         * Converts a word array to a UTF-16 LE string.
         *
         * @param {WordArray} wordArray The word array.
         *
         * @return {string} The UTF-16 LE string.
         *
         * @static
         *
         * @example
         *
         *     var utf16Str = CryptoJS.enc.Utf16LE.stringify(wordArray);
         */
        stringify: function (wordArray) {
            // Shortcuts
            var words = wordArray.words;
            var sigBytes = wordArray.sigBytes;

            // Convert
            var utf16Chars = [];
            for (var i = 0; i < sigBytes; i += 2) {
                var codePoint = swapEndian((words[i >>> 2] >>> (16 - (i % 4) * 8)) & 0xffff);
                utf16Chars.push(String.fromCharCode(codePoint));
            }

            return utf16Chars.join('');
        },

        /**
         * Converts a UTF-16 LE string to a word array.
         *
         * @param {string} utf16Str The UTF-16 LE string.
         *
         * @return {WordArray} The word array.
         *
         * @static
         *
         * @example
         *
         *     var wordArray = CryptoJS.enc.Utf16LE.parse(utf16Str);
         */
        parse: function (utf16Str) {
            // Shortcut
            var utf16StrLength = utf16Str.length;

            // Convert
            var words = [];
            for (var i = 0; i < utf16StrLength; i++) {
                words[i >>> 1] |= swapEndian(utf16Str.charCodeAt(i) << (16 - (i % 2) * 16));
            }

            return WordArray.create(words, utf16StrLength * 2);
        }
    };

    function swapEndian(word) {
        return ((word << 8) & 0xff00ff00) | ((word >>> 8) & 0x00ff00ff);
    }
}());
(function () {
    // Shortcuts
    var C = CryptoJS;
    var C_lib = C.lib;
    var Base = C_lib.Base;
    var WordArray = C_lib.WordArray;
    var C_algo = C.algo;
    var MD5 = C_algo.MD5;

    /**
     * This key derivation function is meant to conform with EVP_BytesToKey.
     * www.openssl.org/docs/crypto/EVP_BytesToKey.html
     */
    var EvpKDF = C_algo.EvpKDF = Base.extend({
        /**
         * Configuration options.
         *
         * @property {number} keySize The key size in words to generate. Default: 4 (128 bits)
         * @property {Hasher} hasher The hash algorithm to use. Default: MD5
         * @property {number} iterations The number of iterations to perform. Default: 1
         */
        cfg: Base.extend({
            keySize: 128/32,
            hasher: MD5,
            iterations: 1
        }),

        /**
         * Initializes a newly created key derivation function.
         *
         * @param {Object} cfg (Optional) The configuration options to use for the derivation.
         *
         * @example
         *
         *     var kdf = CryptoJS.algo.EvpKDF.create();
         *     var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8 });
         *     var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8, iterations: 1000 });
         */
        init: function (cfg) {
            this.cfg = this.cfg.extend(cfg);
        },

        /**
         * Derives a key from a password.
         *
         * @param {WordArray|string} password The password.
         * @param {WordArray|string} salt A salt.
         *
         * @return {WordArray} The derived key.
         *
         * @example
         *
         *     var key = kdf.compute(password, salt);
         */
        compute: function (password, salt) {
            var block;

            // Shortcut
            var cfg = this.cfg;

            // Init hasher
            var hasher = cfg.hasher.create();

            // Initial values
            var derivedKey = WordArray.create();

            // Shortcuts
            var derivedKeyWords = derivedKey.words;
            var keySize = cfg.keySize;
            var iterations = cfg.iterations;

            // Generate key
            while (derivedKeyWords.length < keySize) {
                if (block) {
                    hasher.update(block);
                }
                block = hasher.update(password).finalize(salt);
                hasher.reset();

                // Iterations
                for (var i = 1; i < iterations; i++) {
                    block = hasher.finalize(block);
                    hasher.reset();
                }

                derivedKey.concat(block);
            }
            derivedKey.sigBytes = keySize * 4;

            return derivedKey;
        }
    });

    /**
     * Derives a key from a password.
     *
     * @param {WordArray|string} password The password.
     * @param {WordArray|string} salt A salt.
     * @param {Object} cfg (Optional) The configuration options to use for this computation.
     *
     * @return {WordArray} The derived key.
     *
     * @static
     *
     * @example
     *
     *     var key = CryptoJS.EvpKDF(password, salt);
     *     var key = CryptoJS.EvpKDF(password, salt, { keySize: 8 });
     *     var key = CryptoJS.EvpKDF(password, salt, { keySize: 8, iterations: 1000 });
     */
    C.EvpKDF = function (password, salt, cfg) {
        return EvpKDF.create(cfg).compute(password, salt);
    };
}());
(function (undefined) {
    // Shortcuts
    var C = CryptoJS;
    var C_lib = C.lib;
    var CipherParams = C_lib.CipherParams;
    var C_enc = C.enc;
    var Hex = C_enc.Hex;
    var C_format = C.format;

    var HexFormatter = C_format.Hex = {
        /**
         * Converts the ciphertext of a cipher params object to a hexadecimally encoded string.
         *
         * @param {CipherParams} cipherParams The cipher params object.
         *
         * @return {string} The hexadecimally encoded string.
         *
         * @static
         *
         * @example
         *
         *     var hexString = CryptoJS.format.Hex.stringify(cipherParams);
         */
        stringify: function (cipherParams) {
            return cipherParams.ciphertext.toString(Hex);
        },

        /**
         * Converts a hexadecimally encoded ciphertext string to a cipher params object.
         *
         * @param {string} input The hexadecimally encoded string.
         *
         * @return {CipherParams} The cipher params object.
         *
         * @static
         *
         * @example
         *
         *     var cipherParams = CryptoJS.format.Hex.parse(hexString);
         */
        parse: function (input) {
            var ciphertext = Hex.parse(input);
            return CipherParams.create({ ciphertext: ciphertext });
        }
    };
}());
(function () {
    // Shortcuts
    var C = CryptoJS;
    var C_lib = C.lib;
    var Base = C_lib.Base;
    var C_enc = C.enc;
    var Utf8 = C_enc.Utf8;
    var C_algo = C.algo;

    /**
     * HMAC algorithm.
     */
    var HMAC = C_algo.HMAC = Base.extend({
        /**
         * Initializes a newly created HMAC.
         *
         * @param {Hasher} hasher The hash algorithm to use.
         * @param {WordArray|string} key The secret key.
         *
         * @example
         *
         *     var hmacHasher = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA256, key);
         */
        init: function (hasher, key) {
            // Init hasher
            hasher = this._hasher = new hasher.init();

            // Convert string to WordArray, else assume WordArray already
            if (typeof key == 'string') {
                key = Utf8.parse(key);
            }

            // Shortcuts
            var hasherBlockSize = hasher.blockSize;
            var hasherBlockSizeBytes = hasherBlockSize * 4;

            // Allow arbitrary length keys
            if (key.sigBytes > hasherBlockSizeBytes) {
                key = hasher.finalize(key);
            }

            // Clamp excess bits
            key.clamp();

            // Clone key for inner and outer pads
            var oKey = this._oKey = key.clone();
            var iKey = this._iKey = key.clone();

            // Shortcuts
            var oKeyWords = oKey.words;
            var iKeyWords = iKey.words;

            // XOR keys with pad constants
            for (var i = 0; i < hasherBlockSize; i++) {
                oKeyWords[i] ^= 0x5c5c5c5c;
                iKeyWords[i] ^= 0x36363636;
            }
            oKey.sigBytes = iKey.sigBytes = hasherBlockSizeBytes;

            // Set initial values
            this.reset();
        },

        /**
         * Resets this HMAC to its initial state.
         *
         * @example
         *
         *     hmacHasher.reset();
         */
        reset: function () {
            // Shortcut
            var hasher = this._hasher;

            // Reset
            hasher.reset();
            hasher.update(this._iKey);
        },

        /**
         * Updates this HMAC with a message.
         *
         * @param {WordArray|string} messageUpdate The message to append.
         *
         * @return {HMAC} This HMAC instance.
         *
         * @example
         *
         *     hmacHasher.update('message');
         *     hmacHasher.update(wordArray);
         */
        update: function (messageUpdate) {
            this._hasher.update(messageUpdate);

            // Chainable
            return this;
        },

        /**
         * Finalizes the HMAC computation.
         * Note that the finalize operation is effectively a destructive, read-once operation.
         *
         * @param {WordArray|string} messageUpdate (Optional) A final message update.
         *
         * @return {WordArray} The HMAC.
         *
         * @example
         *
         *     var hmac = hmacHasher.finalize();
         *     var hmac = hmacHasher.finalize('message');
         *     var hmac = hmacHasher.finalize(wordArray);
         */
        finalize: function (messageUpdate) {
            // Shortcut
            var hasher = this._hasher;

            // Compute HMAC
            var innerHash = hasher.finalize(messageUpdate);
            hasher.reset();
            var hmac = hasher.finalize(this._oKey.clone().concat(innerHash));

            return hmac;
        }
    });
}());
(function () {
    // Check if typed arrays are supported
    if (typeof ArrayBuffer != 'function') {
        return;
    }

    // Shortcuts
    var C = CryptoJS;
    var C_lib = C.lib;
    var WordArray = C_lib.WordArray;

    // Reference original init
    var superInit = WordArray.init;

    // Augment WordArray.init to handle typed arrays
    var subInit = WordArray.init = function (typedArray) {
        // Convert buffers to uint8
        if (typedArray instanceof ArrayBuffer) {
            typedArray = new Uint8Array(typedArray);
        }

        // Convert other array views to uint8
        if (
            typedArray instanceof Int8Array ||
            (typeof Uint8ClampedArray !== "undefined" && typedArray instanceof Uint8ClampedArray) ||
            typedArray instanceof Int16Array ||
            typedArray instanceof Uint16Array ||
            typedArray instanceof Int32Array ||
            typedArray instanceof Uint32Array ||
            typedArray instanceof Float32Array ||
            typedArray instanceof Float64Array
        ) {
            typedArray = new Uint8Array(typedArray.buffer, typedArray.byteOffset, typedArray.byteLength);
        }

        // Handle Uint8Array
        if (typedArray instanceof Uint8Array) {
            // Shortcut
            var typedArrayByteLength = typedArray.byteLength;

            // Extract bytes
            var words = [];
            for (var i = 0; i < typedArrayByteLength; i++) {
                words[i >>> 2] |= typedArray[i] << (24 - (i % 4) * 8);
            }

            // Initialize this word array
            superInit.call(this, words, typedArrayByteLength);
        } else {
            // Else call normal init
            superInit.apply(this, arguments);
        }
    };

    subInit.prototype = WordArray;
}());
(function (Math) {
    // Shortcuts
    var C = CryptoJS;
    var C_lib = C.lib;
    var WordArray = C_lib.WordArray;
    var Hasher = C_lib.Hasher;
    var C_algo = C.algo;

    // Constants table
    var T = [];

    // Compute constants
    (function () {
        for (var i = 0; i < 64; i++) {
            T[i] = (Math.abs(Math.sin(i + 1)) * 0x100000000) | 0;
        }
    }());

    /**
     * MD5 hash algorithm.
     */
    var MD5 = C_algo.MD5 = Hasher.extend({
        _doReset: function () {
            this._hash = new WordArray.init([
                0x67452301, 0xefcdab89,
                0x98badcfe, 0x10325476
            ]);
        },

        _doProcessBlock: function (M, offset) {
            // Swap endian
            for (var i = 0; i < 16; i++) {
                // Shortcuts
                var offset_i = offset + i;
                var M_offset_i = M[offset_i];

                M[offset_i] = (
                    (((M_offset_i << 8)  | (M_offset_i >>> 24)) & 0x00ff00ff) |
                    (((M_offset_i << 24) | (M_offset_i >>> 8))  & 0xff00ff00)
                );
            }

            // Shortcuts
            var H = this._hash.words;

            var M_offset_0  = M[offset + 0];
            var M_offset_1  = M[offset + 1];
            var M_offset_2  = M[offset + 2];
            var M_offset_3  = M[offset + 3];
            var M_offset_4  = M[offset + 4];
            var M_offset_5  = M[offset + 5];
            var M_offset_6  = M[offset + 6];
            var M_offset_7  = M[offset + 7];
            var M_offset_8  = M[offset + 8];
            var M_offset_9  = M[offset + 9];
            var M_offset_10 = M[offset + 10];
            var M_offset_11 = M[offset + 11];
            var M_offset_12 = M[offset + 12];
            var M_offset_13 = M[offset + 13];
            var M_offset_14 = M[offset + 14];
            var M_offset_15 = M[offset + 15];

            // Working variables
            var a = H[0];
            var b = H[1];
            var c = H[2];
            var d = H[3];

            // Computation
            a = FF(a, b, c, d, M_offset_0,  7,  T[0]);
            d = FF(d, a, b, c, M_offset_1,  12, T[1]);
            c = FF(c, d, a, b, M_offset_2,  17, T[2]);
            b = FF(b, c, d, a, M_offset_3,  22, T[3]);
            a = FF(a, b, c, d, M_offset_4,  7,  T[4]);
            d = FF(d, a, b, c, M_offset_5,  12, T[5]);
            c = FF(c, d, a, b, M_offset_6,  17, T[6]);
            b = FF(b, c, d, a, M_offset_7,  22, T[7]);
            a = FF(a, b, c, d, M_offset_8,  7,  T[8]);
            d = FF(d, a, b, c, M_offset_9,  12, T[9]);
            c = FF(c, d, a, b, M_offset_10, 17, T[10]);
            b = FF(b, c, d, a, M_offset_11, 22, T[11]);
            a = FF(a, b, c, d, M_offset_12, 7,  T[12]);
            d = FF(d, a, b, c, M_offset_13, 12, T[13]);
            c = FF(c, d, a, b, M_offset_14, 17, T[14]);
            b = FF(b, c, d, a, M_offset_15, 22, T[15]);

            a = GG(a, b, c, d, M_offset_1,  5,  T[16]);
            d = GG(d, a, b, c, M_offset_6,  9,  T[17]);
            c = GG(c, d, a, b, M_offset_11, 14, T[18]);
            b = GG(b, c, d, a, M_offset_0,  20, T[19]);
            a = GG(a, b, c, d, M_offset_5,  5,  T[20]);
            d = GG(d, a, b, c, M_offset_10, 9,  T[21]);
            c = GG(c, d, a, b, M_offset_15, 14, T[22]);
            b = GG(b, c, d, a, M_offset_4,  20, T[23]);
            a = GG(a, b, c, d, M_offset_9,  5,  T[24]);
            d = GG(d, a, b, c, M_offset_14, 9,  T[25]);
            c = GG(c, d, a, b, M_offset_3,  14, T[26]);
            b = GG(b, c, d, a, M_offset_8,  20, T[27]);
            a = GG(a, b, c, d, M_offset_13, 5,  T[28]);
            d = GG(d, a, b, c, M_offset_2,  9,  T[29]);
            c = GG(c, d, a, b, M_offset_7,  14, T[30]);
            b = GG(b, c, d, a, M_offset_12, 20, T[31]);

            a = HH(a, b, c, d, M_offset_5,  4,  T[32]);
            d = HH(d, a, b, c, M_offset_8,  11, T[33]);
            c = HH(c, d, a, b, M_offset_11, 16, T[34]);
            b = HH(b, c, d, a, M_offset_14, 23, T[35]);
            a = HH(a, b, c, d, M_offset_1,  4,  T[36]);
            d = HH(d, a, b, c, M_offset_4,  11, T[37]);
            c = HH(c, d, a, b, M_offset_7,  16, T[38]);
            b = HH(b, c, d, a, M_offset_10, 23, T[39]);
            a = HH(a, b, c, d, M_offset_13, 4,  T[40]);
            d = HH(d, a, b, c, M_offset_0,  11, T[41]);
            c = HH(c, d, a, b, M_offset_3,  16, T[42]);
            b = HH(b, c, d, a, M_offset_6,  23, T[43]);
            a = HH(a, b, c, d, M_offset_9,  4,  T[44]);
            d = HH(d, a, b, c, M_offset_12, 11, T[45]);
            c = HH(c, d, a, b, M_offset_15, 16, T[46]);
            b = HH(b, c, d, a, M_offset_2,  23, T[47]);

            a = II(a, b, c, d, M_offset_0,  6,  T[48]);
            d = II(d, a, b, c, M_offset_7,  10, T[49]);
            c = II(c, d, a, b, M_offset_14, 15, T[50]);
            b = II(b, c, d, a, M_offset_5,  21, T[51]);
            a = II(a, b, c, d, M_offset_12, 6,  T[52]);
            d = II(d, a, b, c, M_offset_3,  10, T[53]);
            c = II(c, d, a, b, M_offset_10, 15, T[54]);
            b = II(b, c, d, a, M_offset_1,  21, T[55]);
            a = II(a, b, c, d, M_offset_8,  6,  T[56]);
            d = II(d, a, b, c, M_offset_15, 10, T[57]);
            c = II(c, d, a, b, M_offset_6,  15, T[58]);
            b = II(b, c, d, a, M_offset_13, 21, T[59]);
            a = II(a, b, c, d, M_offset_4,  6,  T[60]);
            d = II(d, a, b, c, M_offset_11, 10, T[61]);
            c = II(c, d, a, b, M_offset_2,  15, T[62]);
            b = II(b, c, d, a, M_offset_9,  21, T[63]);

            // Intermediate hash value
            H[0] = (H[0] + a) | 0;
            H[1] = (H[1] + b) | 0;
            H[2] = (H[2] + c) | 0;
            H[3] = (H[3] + d) | 0;
        },

        _doFinalize: function () {
            // Shortcuts
            var data = this._data;
            var dataWords = data.words;

            var nBitsTotal = this._nDataBytes * 8;
            var nBitsLeft = data.sigBytes * 8;

            // Add padding
            dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);

            var nBitsTotalH = Math.floor(nBitsTotal / 0x100000000);
            var nBitsTotalL = nBitsTotal;
            dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = (
                (((nBitsTotalH << 8)  | (nBitsTotalH >>> 24)) & 0x00ff00ff) |
                (((nBitsTotalH << 24) | (nBitsTotalH >>> 8))  & 0xff00ff00)
            );
            dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = (
                (((nBitsTotalL << 8)  | (nBitsTotalL >>> 24)) & 0x00ff00ff) |
                (((nBitsTotalL << 24) | (nBitsTotalL >>> 8))  & 0xff00ff00)
            );

            data.sigBytes = (dataWords.length + 1) * 4;

            // Hash final blocks
            this._process();

            // Shortcuts
            var hash = this._hash;
            var H = hash.words;

            // Swap endian
            for (var i = 0; i < 4; i++) {
                // Shortcut
                var H_i = H[i];

                H[i] = (((H_i << 8)  | (H_i >>> 24)) & 0x00ff00ff) |
                       (((H_i << 24) | (H_i >>> 8))  & 0xff00ff00);
            }

            // Return final computed hash
            return hash;
        },

        clone: function () {
            var clone = Hasher.clone.call(this);
            clone._hash = this._hash.clone();

            return clone;
        }
    });

    function FF(a, b, c, d, x, s, t) {
        var n = a + ((b & c) | (~b & d)) + x + t;
        return ((n << s) | (n >>> (32 - s))) + b;
    }

    function GG(a, b, c, d, x, s, t) {
        var n = a + ((b & d) | (c & ~d)) + x + t;
        return ((n << s) | (n >>> (32 - s))) + b;
    }

    function HH(a, b, c, d, x, s, t) {
        var n = a + (b ^ c ^ d) + x + t;
        return ((n << s) | (n >>> (32 - s))) + b;
    }

    function II(a, b, c, d, x, s, t) {
        var n = a + (c ^ (b | ~d)) + x + t;
        return ((n << s) | (n >>> (32 - s))) + b;
    }

    /**
     * Shortcut function to the hasher's object interface.
     *
     * @param {WordArray|string} message The message to hash.
     *
     * @return {WordArray} The hash.
     *
     * @static
     *
     * @example
     *
     *     var hash = CryptoJS.MD5('message');
     *     var hash = CryptoJS.MD5(wordArray);
     */
    C.MD5 = Hasher._createHelper(MD5);

    /**
     * Shortcut function to the HMAC's object interface.
     *
     * @param {WordArray|string} message The message to hash.
     * @param {WordArray|string} key The secret key.
     *
     * @return {WordArray} The HMAC.
     *
     * @static
     *
     * @example
     *
     *     var hmac = CryptoJS.HmacMD5(message, key);
     */
    C.HmacMD5 = Hasher._createHmacHelper(MD5);
}(Math));
/**
 * Cipher Feedback block mode.
 */
CryptoJS.mode.CFB = (function () {
    var CFB = CryptoJS.lib.BlockCipherMode.extend();

    CFB.Encryptor = CFB.extend({
        processBlock: function (words, offset) {
            // Shortcuts
            var cipher = this._cipher;
            var blockSize = cipher.blockSize;

            generateKeystreamAndEncrypt.call(this, words, offset, blockSize, cipher);

            // Remember this block to use with next block
            this._prevBlock = words.slice(offset, offset + blockSize);
        }
    });

    CFB.Decryptor = CFB.extend({
        processBlock: function (words, offset) {
            // Shortcuts
            var cipher = this._cipher;
            var blockSize = cipher.blockSize;

            // Remember this block to use with next block
            var thisBlock = words.slice(offset, offset + blockSize);

            generateKeystreamAndEncrypt.call(this, words, offset, blockSize, cipher);

            // This block becomes the previous block
            this._prevBlock = thisBlock;
        }
    });

    function generateKeystreamAndEncrypt(words, offset, blockSize, cipher) {
        var keystream;

        // Shortcut
        var iv = this._iv;

        // Generate keystream
        if (iv) {
            keystream = iv.slice(0);

            // Remove IV for subsequent blocks
            this._iv = undefined;
        } else {
            keystream = this._prevBlock;
        }
        cipher.encryptBlock(keystream, 0);

        // Encrypt
        for (var i = 0; i < blockSize; i++) {
            words[offset + i] ^= keystream[i];
        }
    }

    return CFB;
}());
/** @preserve
 * Counter block mode compatible with  Dr Brian Gladman fileenc.c
 * derived from CryptoJS.mode.CTR 
 * Jan Hruby jhruby.web@gmail.com
 */
CryptoJS.mode.CTRGladman = (function () {
    var CTRGladman = CryptoJS.lib.BlockCipherMode.extend();

	function incWord(word)
	{	
		if (((word >> 24) & 0xff) === 0xff) { //overflow
		var b1 = (word >> 16)&0xff;
		var b2 = (word >> 8)&0xff;
		var b3 = word & 0xff;

		if (b1 === 0xff) // overflow b1
		{		 
		b1 = 0;
		if (b2 === 0xff)
		{
			b2 = 0;
			if (b3 === 0xff)
			{
				b3 = 0;
			}
			else
			{
				++b3;
			}
		}
		else
		{
			++b2;
		}
		}
		else
		{
		++b1;
		}

		word = 0;	  	  
		word += (b1 << 16);
		word += (b2 << 8);
		word += b3;	  
		}
		else
		{
		word += (0x01 << 24);
		}
		return word;
	}

	function incCounter(counter)
	{
		if ((counter[0] = incWord(counter[0])) === 0)
		{
			// encr_data in fileenc.c from  Dr Brian Gladman's counts only with DWORD j < 8
			counter[1] = incWord(counter[1]);
		}
		return counter;
	}
	
    var Encryptor = CTRGladman.Encryptor = CTRGladman.extend({
        processBlock: function (words, offset) {
            // Shortcuts
            var cipher = this._cipher
            var blockSize = cipher.blockSize;
            var iv = this._iv;
            var counter = this._counter;

            // Generate keystream
            if (iv) {
                counter = this._counter = iv.slice(0);

                // Remove IV for subsequent blocks
                this._iv = undefined;
            }
            
			incCounter(counter);
			
			var keystream = counter.slice(0);
            cipher.encryptBlock(keystream, 0);

            // Encrypt
            for (var i = 0; i < blockSize; i++) {
                words[offset + i] ^= keystream[i];
            }
        }
    });

    CTRGladman.Decryptor = Encryptor;

    return CTRGladman;
}());


/**
 * Counter block mode.
 */
CryptoJS.mode.CTR = (function () {
    var CTR = CryptoJS.lib.BlockCipherMode.extend();

    var Encryptor = CTR.Encryptor = CTR.extend({
        processBlock: function (words, offset) {
            // Shortcuts
            var cipher = this._cipher
            var blockSize = cipher.blockSize;
            var iv = this._iv;
            var counter = this._counter;

            // Generate keystream
            if (iv) {
                counter = this._counter = iv.slice(0);

                // Remove IV for subsequent blocks
                this._iv = undefined;
            }
            var keystream = counter.slice(0);
            cipher.encryptBlock(keystream, 0);

            // Increment counter
            counter[blockSize - 1] = (counter[blockSize - 1] + 1) | 0

            // Encrypt
            for (var i = 0; i < blockSize; i++) {
                words[offset + i] ^= keystream[i];
            }
        }
    });

    CTR.Decryptor = Encryptor;

    return CTR;
}());
/**
 * Electronic Codebook block mode.
 */
CryptoJS.mode.ECB = (function () {
    var ECB = CryptoJS.lib.BlockCipherMode.extend();

    ECB.Encryptor = ECB.extend({
        processBlock: function (words, offset) {
            this._cipher.encryptBlock(words, offset);
        }
    });

    ECB.Decryptor = ECB.extend({
        processBlock: function (words, offset) {
            this._cipher.decryptBlock(words, offset);
        }
    });

    return ECB;
}());
/**
 * Output Feedback block mode.
 */
CryptoJS.mode.OFB = (function () {
    var OFB = CryptoJS.lib.BlockCipherMode.extend();

    var Encryptor = OFB.Encryptor = OFB.extend({
        processBlock: function (words, offset) {
            // Shortcuts
            var cipher = this._cipher
            var blockSize = cipher.blockSize;
            var iv = this._iv;
            var keystream = this._keystream;

            // Generate keystream
            if (iv) {
                keystream = this._keystream = iv.slice(0);

                // Remove IV for subsequent blocks
                this._iv = undefined;
            }
            cipher.encryptBlock(keystream, 0);

            // Encrypt
            for (var i = 0; i < blockSize; i++) {
                words[offset + i] ^= keystream[i];
            }
        }
    });

    OFB.Decryptor = Encryptor;

    return OFB;
}());
/**
 * ANSI X.923 padding strategy.
 */
CryptoJS.pad.AnsiX923 = {
    pad: function (data, blockSize) {
        // Shortcuts
        var dataSigBytes = data.sigBytes;
        var blockSizeBytes = blockSize * 4;

        // Count padding bytes
        var nPaddingBytes = blockSizeBytes - dataSigBytes % blockSizeBytes;

        // Compute last byte position
        var lastBytePos = dataSigBytes + nPaddingBytes - 1;

        // Pad
        data.clamp();
        data.words[lastBytePos >>> 2] |= nPaddingBytes << (24 - (lastBytePos % 4) * 8);
        data.sigBytes += nPaddingBytes;
    },

    unpad: function (data) {
        // Get number of padding bytes from last byte
        var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;

        // Remove padding
        data.sigBytes -= nPaddingBytes;
    }
};
/**
 * ISO 10126 padding strategy.
 */
CryptoJS.pad.Iso10126 = {
    pad: function (data, blockSize) {
        // Shortcut
        var blockSizeBytes = blockSize * 4;

        // Count padding bytes
        var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes;

        // Pad
        data.concat(CryptoJS.lib.WordArray.random(nPaddingBytes - 1)).
             concat(CryptoJS.lib.WordArray.create([nPaddingBytes << 24], 1));
    },

    unpad: function (data) {
        // Get number of padding bytes from last byte
        var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;

        // Remove padding
        data.sigBytes -= nPaddingBytes;
    }
};
/**
 * ISO/IEC 9797-1 Padding Method 2.
 */
CryptoJS.pad.Iso97971 = {
    pad: function (data, blockSize) {
        // Add 0x80 byte
        data.concat(CryptoJS.lib.WordArray.create([0x80000000], 1));

        // Zero pad the rest
        CryptoJS.pad.ZeroPadding.pad(data, blockSize);
    },

    unpad: function (data) {
        // Remove zero padding
        CryptoJS.pad.ZeroPadding.unpad(data);

        // Remove one more byte -- the 0x80 byte
        data.sigBytes--;
    }
};
/**
 * A noop padding strategy.
 */
CryptoJS.pad.NoPadding = {
    pad: function () {
    },

    unpad: function () {
    }
};
/**
 * Zero padding strategy.
 */
CryptoJS.pad.ZeroPadding = {
    pad: function (data, blockSize) {
        // Shortcut
        var blockSizeBytes = blockSize * 4;

        // Pad
        data.clamp();
        data.sigBytes += blockSizeBytes - ((data.sigBytes % blockSizeBytes) || blockSizeBytes);
    },

    unpad: function (data) {
        // Shortcut
        var dataWords = data.words;

        // Unpad
        var i = data.sigBytes - 1;
        for (var i = data.sigBytes - 1; i >= 0; i--) {
            if (((dataWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff)) {
                data.sigBytes = i + 1;
                break;
            }
        }
    }
};
(function () {
    // Shortcuts
    var C = CryptoJS;
    var C_lib = C.lib;
    var Base = C_lib.Base;
    var WordArray = C_lib.WordArray;
    var C_algo = C.algo;
    var SHA256 = C_algo.SHA256;
    var HMAC = C_algo.HMAC;

    /**
     * Password-Based Key Derivation Function 2 algorithm.
     */
    var PBKDF2 = C_algo.PBKDF2 = Base.extend({
        /**
         * Configuration options.
         *
         * @property {number} keySize The key size in words to generate. Default: 4 (128 bits)
         * @property {Hasher} hasher The hasher to use. Default: SHA256
         * @property {number} iterations The number of iterations to perform. Default: 250000
         */
        cfg: Base.extend({
            keySize: 128/32,
            hasher: SHA256,
            iterations: 250000
        }),

        /**
         * Initializes a newly created key derivation function.
         *
         * @param {Object} cfg (Optional) The configuration options to use for the derivation.
         *
         * @example
         *
         *     var kdf = CryptoJS.algo.PBKDF2.create();
         *     var kdf = CryptoJS.algo.PBKDF2.create({ keySize: 8 });
         *     var kdf = CryptoJS.algo.PBKDF2.create({ keySize: 8, iterations: 1000 });
         */
        init: function (cfg) {
            this.cfg = this.cfg.extend(cfg);
        },

        /**
         * Computes the Password-Based Key Derivation Function 2.
         *
         * @param {WordArray|string} password The password.
         * @param {WordArray|string} salt A salt.
         *
         * @return {WordArray} The derived key.
         *
         * @example
         *
         *     var key = kdf.compute(password, salt);
         */
        compute: function (password, salt) {
            // Shortcut
            var cfg = this.cfg;

            // Init HMAC
            var hmac = HMAC.create(cfg.hasher, password);

            // Initial values
            var derivedKey = WordArray.create();
            var blockIndex = WordArray.create([0x00000001]);

            // Shortcuts
            var derivedKeyWords = derivedKey.words;
            var blockIndexWords = blockIndex.words;
            var keySize = cfg.keySize;
            var iterations = cfg.iterations;

            // Generate key
            while (derivedKeyWords.length < keySize) {
                var block = hmac.update(salt).finalize(blockIndex);
                hmac.reset();

                // Shortcuts
                var blockWords = block.words;
                var blockWordsLength = blockWords.length;

                // Iterations
                var intermediate = block;
                for (var i = 1; i < iterations; i++) {
                    intermediate = hmac.finalize(intermediate);
                    hmac.reset();

                    // Shortcut
                    var intermediateWords = intermediate.words;

                    // XOR intermediate with block
                    for (var j = 0; j < blockWordsLength; j++) {
                        blockWords[j] ^= intermediateWords[j];
                    }
                }

                derivedKey.concat(block);
                blockIndexWords[0]++;
            }
            derivedKey.sigBytes = keySize * 4;

            return derivedKey;
        }
    });

    /**
     * Computes the Password-Based Key Derivation Function 2.
     *
     * @param {WordArray|string} password The password.
     * @param {WordArray|string} salt A salt.
     * @param {Object} cfg (Optional) The configuration options to use for this computation.
     *
     * @return {WordArray} The derived key.
     *
     * @static
     *
     * @example
     *
     *     var key = CryptoJS.PBKDF2(password, salt);
     *     var key = CryptoJS.PBKDF2(password, salt, { keySize: 8 });
     *     var key = CryptoJS.PBKDF2(password, salt, { keySize: 8, iterations: 1000 });
     */
    C.PBKDF2 = function (password, salt, cfg) {
        return PBKDF2.create(cfg).compute(password, salt);
    };
}());
(function () {
    // Shortcuts
    var C = CryptoJS;
    var C_lib = C.lib;
    var StreamCipher = C_lib.StreamCipher;
    var C_algo = C.algo;

    // Reusable objects
    var S  = [];
    var C_ = [];
    var G  = [];

    /**
     * Rabbit stream cipher algorithm.
     *
     * This is a legacy version that neglected to convert the key to little-endian.
     * This error doesn't affect the cipher's security,
     * but it does affect its compatibility with other implementations.
     */
    var RabbitLegacy = C_algo.RabbitLegacy = StreamCipher.extend({
        _doReset: function () {
            // Shortcuts
            var K = this._key.words;
            var iv = this.cfg.iv;

            // Generate initial state values
            var X = this._X = [
                K[0], (K[3] << 16) | (K[2] >>> 16),
                K[1], (K[0] << 16) | (K[3] >>> 16),
                K[2], (K[1] << 16) | (K[0] >>> 16),
                K[3], (K[2] << 16) | (K[1] >>> 16)
            ];

            // Generate initial counter values
            var C = this._C = [
                (K[2] << 16) | (K[2] >>> 16), (K[0] & 0xffff0000) | (K[1] & 0x0000ffff),
                (K[3] << 16) | (K[3] >>> 16), (K[1] & 0xffff0000) | (K[2] & 0x0000ffff),
                (K[0] << 16) | (K[0] >>> 16), (K[2] & 0xffff0000) | (K[3] & 0x0000ffff),
                (K[1] << 16) | (K[1] >>> 16), (K[3] & 0xffff0000) | (K[0] & 0x0000ffff)
            ];

            // Carry bit
            this._b = 0;

            // Iterate the system four times
            for (var i = 0; i < 4; i++) {
                nextState.call(this);
            }

            // Modify the counters
            for (var i = 0; i < 8; i++) {
                C[i] ^= X[(i + 4) & 7];
            }

            // IV setup
            if (iv) {
                // Shortcuts
                var IV = iv.words;
                var IV_0 = IV[0];
                var IV_1 = IV[1];

                // Generate four subvectors
                var i0 = (((IV_0 << 8) | (IV_0 >>> 24)) & 0x00ff00ff) | (((IV_0 << 24) | (IV_0 >>> 8)) & 0xff00ff00);
                var i2 = (((IV_1 << 8) | (IV_1 >>> 24)) & 0x00ff00ff) | (((IV_1 << 24) | (IV_1 >>> 8)) & 0xff00ff00);
                var i1 = (i0 >>> 16) | (i2 & 0xffff0000);
                var i3 = (i2 << 16)  | (i0 & 0x0000ffff);

                // Modify counter values
                C[0] ^= i0;
                C[1] ^= i1;
                C[2] ^= i2;
                C[3] ^= i3;
                C[4] ^= i0;
                C[5] ^= i1;
                C[6] ^= i2;
                C[7] ^= i3;

                // Iterate the system four times
                for (var i = 0; i < 4; i++) {
                    nextState.call(this);
                }
            }
        },

        _doProcessBlock: function (M, offset) {
            // Shortcut
            var X = this._X;

            // Iterate the system
            nextState.call(this);

            // Generate four keystream words
            S[0] = X[0] ^ (X[5] >>> 16) ^ (X[3] << 16);
            S[1] = X[2] ^ (X[7] >>> 16) ^ (X[5] << 16);
            S[2] = X[4] ^ (X[1] >>> 16) ^ (X[7] << 16);
            S[3] = X[6] ^ (X[3] >>> 16) ^ (X[1] << 16);

            for (var i = 0; i < 4; i++) {
                // Swap endian
                S[i] = (((S[i] << 8)  | (S[i] >>> 24)) & 0x00ff00ff) |
                       (((S[i] << 24) | (S[i] >>> 8))  & 0xff00ff00);

                // Encrypt
                M[offset + i] ^= S[i];
            }
        },

        blockSize: 128/32,

        ivSize: 64/32
    });

    function nextState() {
        // Shortcuts
        var X = this._X;
        var C = this._C;

        // Save old counter values
        for (var i = 0; i < 8; i++) {
            C_[i] = C[i];
        }

        // Calculate new counter values
        C[0] = (C[0] + 0x4d34d34d + this._b) | 0;
        C[1] = (C[1] + 0xd34d34d3 + ((C[0] >>> 0) < (C_[0] >>> 0) ? 1 : 0)) | 0;
        C[2] = (C[2] + 0x34d34d34 + ((C[1] >>> 0) < (C_[1] >>> 0) ? 1 : 0)) | 0;
        C[3] = (C[3] + 0x4d34d34d + ((C[2] >>> 0) < (C_[2] >>> 0) ? 1 : 0)) | 0;
        C[4] = (C[4] + 0xd34d34d3 + ((C[3] >>> 0) < (C_[3] >>> 0) ? 1 : 0)) | 0;
        C[5] = (C[5] + 0x34d34d34 + ((C[4] >>> 0) < (C_[4] >>> 0) ? 1 : 0)) | 0;
        C[6] = (C[6] + 0x4d34d34d + ((C[5] >>> 0) < (C_[5] >>> 0) ? 1 : 0)) | 0;
        C[7] = (C[7] + 0xd34d34d3 + ((C[6] >>> 0) < (C_[6] >>> 0) ? 1 : 0)) | 0;
        this._b = (C[7] >>> 0) < (C_[7] >>> 0) ? 1 : 0;

        // Calculate the g-values
        for (var i = 0; i < 8; i++) {
            var gx = X[i] + C[i];

            // Construct high and low argument for squaring
            var ga = gx & 0xffff;
            var gb = gx >>> 16;

            // Calculate high and low result of squaring
            var gh = ((((ga * ga) >>> 17) + ga * gb) >>> 15) + gb * gb;
            var gl = (((gx & 0xffff0000) * gx) | 0) + (((gx & 0x0000ffff) * gx) | 0);

            // High XOR low
            G[i] = gh ^ gl;
        }

        // Calculate new state values
        X[0] = (G[0] + ((G[7] << 16) | (G[7] >>> 16)) + ((G[6] << 16) | (G[6] >>> 16))) | 0;
        X[1] = (G[1] + ((G[0] << 8)  | (G[0] >>> 24)) + G[7]) | 0;
        X[2] = (G[2] + ((G[1] << 16) | (G[1] >>> 16)) + ((G[0] << 16) | (G[0] >>> 16))) | 0;
        X[3] = (G[3] + ((G[2] << 8)  | (G[2] >>> 24)) + G[1]) | 0;
        X[4] = (G[4] + ((G[3] << 16) | (G[3] >>> 16)) + ((G[2] << 16) | (G[2] >>> 16))) | 0;
        X[5] = (G[5] + ((G[4] << 8)  | (G[4] >>> 24)) + G[3]) | 0;
        X[6] = (G[6] + ((G[5] << 16) | (G[5] >>> 16)) + ((G[4] << 16) | (G[4] >>> 16))) | 0;
        X[7] = (G[7] + ((G[6] << 8)  | (G[6] >>> 24)) + G[5]) | 0;
    }

    /**
     * Shortcut functions to the cipher's object interface.
     *
     * @example
     *
     *     var ciphertext = CryptoJS.RabbitLegacy.encrypt(message, key, cfg);
     *     var plaintext  = CryptoJS.RabbitLegacy.decrypt(ciphertext, key, cfg);
     */
    C.RabbitLegacy = StreamCipher._createHelper(RabbitLegacy);
}());
(function () {
    // Shortcuts
    var C = CryptoJS;
    var C_lib = C.lib;
    var StreamCipher = C_lib.StreamCipher;
    var C_algo = C.algo;

    // Reusable objects
    var S  = [];
    var C_ = [];
    var G  = [];

    /**
     * Rabbit stream cipher algorithm
     */
    var Rabbit = C_algo.Rabbit = StreamCipher.extend({
        _doReset: function () {
            // Shortcuts
            var K = this._key.words;
            var iv = this.cfg.iv;

            // Swap endian
            for (var i = 0; i < 4; i++) {
                K[i] = (((K[i] << 8)  | (K[i] >>> 24)) & 0x00ff00ff) |
                       (((K[i] << 24) | (K[i] >>> 8))  & 0xff00ff00);
            }

            // Generate initial state values
            var X = this._X = [
                K[0], (K[3] << 16) | (K[2] >>> 16),
                K[1], (K[0] << 16) | (K[3] >>> 16),
                K[2], (K[1] << 16) | (K[0] >>> 16),
                K[3], (K[2] << 16) | (K[1] >>> 16)
            ];

            // Generate initial counter values
            var C = this._C = [
                (K[2] << 16) | (K[2] >>> 16), (K[0] & 0xffff0000) | (K[1] & 0x0000ffff),
                (K[3] << 16) | (K[3] >>> 16), (K[1] & 0xffff0000) | (K[2] & 0x0000ffff),
                (K[0] << 16) | (K[0] >>> 16), (K[2] & 0xffff0000) | (K[3] & 0x0000ffff),
                (K[1] << 16) | (K[1] >>> 16), (K[3] & 0xffff0000) | (K[0] & 0x0000ffff)
            ];

            // Carry bit
            this._b = 0;

            // Iterate the system four times
            for (var i = 0; i < 4; i++) {
                nextState.call(this);
            }

            // Modify the counters
            for (var i = 0; i < 8; i++) {
                C[i] ^= X[(i + 4) & 7];
            }

            // IV setup
            if (iv) {
                // Shortcuts
                var IV = iv.words;
                var IV_0 = IV[0];
                var IV_1 = IV[1];

                // Generate four subvectors
                var i0 = (((IV_0 << 8) | (IV_0 >>> 24)) & 0x00ff00ff) | (((IV_0 << 24) | (IV_0 >>> 8)) & 0xff00ff00);
                var i2 = (((IV_1 << 8) | (IV_1 >>> 24)) & 0x00ff00ff) | (((IV_1 << 24) | (IV_1 >>> 8)) & 0xff00ff00);
                var i1 = (i0 >>> 16) | (i2 & 0xffff0000);
                var i3 = (i2 << 16)  | (i0 & 0x0000ffff);

                // Modify counter values
                C[0] ^= i0;
                C[1] ^= i1;
                C[2] ^= i2;
                C[3] ^= i3;
                C[4] ^= i0;
                C[5] ^= i1;
                C[6] ^= i2;
                C[7] ^= i3;

                // Iterate the system four times
                for (var i = 0; i < 4; i++) {
                    nextState.call(this);
                }
            }
        },

        _doProcessBlock: function (M, offset) {
            // Shortcut
            var X = this._X;

            // Iterate the system
            nextState.call(this);

            // Generate four keystream words
            S[0] = X[0] ^ (X[5] >>> 16) ^ (X[3] << 16);
            S[1] = X[2] ^ (X[7] >>> 16) ^ (X[5] << 16);
            S[2] = X[4] ^ (X[1] >>> 16) ^ (X[7] << 16);
            S[3] = X[6] ^ (X[3] >>> 16) ^ (X[1] << 16);

            for (var i = 0; i < 4; i++) {
                // Swap endian
                S[i] = (((S[i] << 8)  | (S[i] >>> 24)) & 0x00ff00ff) |
                       (((S[i] << 24) | (S[i] >>> 8))  & 0xff00ff00);

                // Encrypt
                M[offset + i] ^= S[i];
            }
        },

        blockSize: 128/32,

        ivSize: 64/32
    });

    function nextState() {
        // Shortcuts
        var X = this._X;
        var C = this._C;

        // Save old counter values
        for (var i = 0; i < 8; i++) {
            C_[i] = C[i];
        }

        // Calculate new counter values
        C[0] = (C[0] + 0x4d34d34d + this._b) | 0;
        C[1] = (C[1] + 0xd34d34d3 + ((C[0] >>> 0) < (C_[0] >>> 0) ? 1 : 0)) | 0;
        C[2] = (C[2] + 0x34d34d34 + ((C[1] >>> 0) < (C_[1] >>> 0) ? 1 : 0)) | 0;
        C[3] = (C[3] + 0x4d34d34d + ((C[2] >>> 0) < (C_[2] >>> 0) ? 1 : 0)) | 0;
        C[4] = (C[4] + 0xd34d34d3 + ((C[3] >>> 0) < (C_[3] >>> 0) ? 1 : 0)) | 0;
        C[5] = (C[5] + 0x34d34d34 + ((C[4] >>> 0) < (C_[4] >>> 0) ? 1 : 0)) | 0;
        C[6] = (C[6] + 0x4d34d34d + ((C[5] >>> 0) < (C_[5] >>> 0) ? 1 : 0)) | 0;
        C[7] = (C[7] + 0xd34d34d3 + ((C[6] >>> 0) < (C_[6] >>> 0) ? 1 : 0)) | 0;
        this._b = (C[7] >>> 0) < (C_[7] >>> 0) ? 1 : 0;

        // Calculate the g-values
        for (var i = 0; i < 8; i++) {
            var gx = X[i] + C[i];

            // Construct high and low argument for squaring
            var ga = gx & 0xffff;
            var gb = gx >>> 16;

            // Calculate high and low result of squaring
            var gh = ((((ga * ga) >>> 17) + ga * gb) >>> 15) + gb * gb;
            var gl = (((gx & 0xffff0000) * gx) | 0) + (((gx & 0x0000ffff) * gx) | 0);

            // High XOR low
            G[i] = gh ^ gl;
        }

        // Calculate new state values
        X[0] = (G[0] + ((G[7] << 16) | (G[7] >>> 16)) + ((G[6] << 16) | (G[6] >>> 16))) | 0;
        X[1] = (G[1] + ((G[0] << 8)  | (G[0] >>> 24)) + G[7]) | 0;
        X[2] = (G[2] + ((G[1] << 16) | (G[1] >>> 16)) + ((G[0] << 16) | (G[0] >>> 16))) | 0;
        X[3] = (G[3] + ((G[2] << 8)  | (G[2] >>> 24)) + G[1]) | 0;
        X[4] = (G[4] + ((G[3] << 16) | (G[3] >>> 16)) + ((G[2] << 16) | (G[2] >>> 16))) | 0;
        X[5] = (G[5] + ((G[4] << 8)  | (G[4] >>> 24)) + G[3]) | 0;
        X[6] = (G[6] + ((G[5] << 16) | (G[5] >>> 16)) + ((G[4] << 16) | (G[4] >>> 16))) | 0;
        X[7] = (G[7] + ((G[6] << 8)  | (G[6] >>> 24)) + G[5]) | 0;
    }

    /**
     * Shortcut functions to the cipher's object interface.
     *
     * @example
     *
     *     var ciphertext = CryptoJS.Rabbit.encrypt(message, key, cfg);
     *     var plaintext  = CryptoJS.Rabbit.decrypt(ciphertext, key, cfg);
     */
    C.Rabbit = StreamCipher._createHelper(Rabbit);
}());
(function () {
    // Shortcuts
    var C = CryptoJS;
    var C_lib = C.lib;
    var StreamCipher = C_lib.StreamCipher;
    var C_algo = C.algo;

    /**
     * RC4 stream cipher algorithm.
     */
    var RC4 = C_algo.RC4 = StreamCipher.extend({
        _doReset: function () {
            // Shortcuts
            var key = this._key;
            var keyWords = key.words;
            var keySigBytes = key.sigBytes;

            // Init sbox
            var S = this._S = [];
            for (var i = 0; i < 256; i++) {
                S[i] = i;
            }

            // Key setup
            for (var i = 0, j = 0; i < 256; i++) {
                var keyByteIndex = i % keySigBytes;
                var keyByte = (keyWords[keyByteIndex >>> 2] >>> (24 - (keyByteIndex % 4) * 8)) & 0xff;

                j = (j + S[i] + keyByte) % 256;

                // Swap
                var t = S[i];
                S[i] = S[j];
                S[j] = t;
            }

            // Counters
            this._i = this._j = 0;
        },

        _doProcessBlock: function (M, offset) {
            M[offset] ^= generateKeystreamWord.call(this);
        },

        keySize: 256/32,

        ivSize: 0
    });

    function generateKeystreamWord() {
        // Shortcuts
        var S = this._S;
        var i = this._i;
        var j = this._j;

        // Generate keystream word
        var keystreamWord = 0;
        for (var n = 0; n < 4; n++) {
            i = (i + 1) % 256;
            j = (j + S[i]) % 256;

            // Swap
            var t = S[i];
            S[i] = S[j];
            S[j] = t;

            keystreamWord |= S[(S[i] + S[j]) % 256] << (24 - n * 8);
        }

        // Update counters
        this._i = i;
        this._j = j;

        return keystreamWord;
    }

    /**
     * Shortcut functions to the cipher's object interface.
     *
     * @example
     *
     *     var ciphertext = CryptoJS.RC4.encrypt(message, key, cfg);
     *     var plaintext  = CryptoJS.RC4.decrypt(ciphertext, key, cfg);
     */
    C.RC4 = StreamCipher._createHelper(RC4);

    /**
     * Modified RC4 stream cipher algorithm.
     */
    var RC4Drop = C_algo.RC4Drop = RC4.extend({
        /**
         * Configuration options.
         *
         * @property {number} drop The number of keystream words to drop. Default 192
         */
        cfg: RC4.cfg.extend({
            drop: 192
        }),

        _doReset: function () {
            RC4._doReset.call(this);

            // Drop
            for (var i = this.cfg.drop; i > 0; i--) {
                generateKeystreamWord.call(this);
            }
        }
    });

    /**
     * Shortcut functions to the cipher's object interface.
     *
     * @example
     *
     *     var ciphertext = CryptoJS.RC4Drop.encrypt(message, key, cfg);
     *     var plaintext  = CryptoJS.RC4Drop.decrypt(ciphertext, key, cfg);
     */
    C.RC4Drop = StreamCipher._createHelper(RC4Drop);
}());
/** @preserve
(c) 2012 by Cédric Mesnil. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

    - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
    - 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.

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.
*/

(function (Math) {
    // Shortcuts
    var C = CryptoJS;
    var C_lib = C.lib;
    var WordArray = C_lib.WordArray;
    var Hasher = C_lib.Hasher;
    var C_algo = C.algo;

    // Constants table
    var _zl = WordArray.create([
        0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15,
        7,  4, 13,  1, 10,  6, 15,  3, 12,  0,  9,  5,  2, 14, 11,  8,
        3, 10, 14,  4,  9, 15,  8,  1,  2,  7,  0,  6, 13, 11,  5, 12,
        1,  9, 11, 10,  0,  8, 12,  4, 13,  3,  7, 15, 14,  5,  6,  2,
        4,  0,  5,  9,  7, 12,  2, 10, 14,  1,  3,  8, 11,  6, 15, 13]);
    var _zr = WordArray.create([
        5, 14,  7,  0,  9,  2, 11,  4, 13,  6, 15,  8,  1, 10,  3, 12,
        6, 11,  3,  7,  0, 13,  5, 10, 14, 15,  8, 12,  4,  9,  1,  2,
        15,  5,  1,  3,  7, 14,  6,  9, 11,  8, 12,  2, 10,  0,  4, 13,
        8,  6,  4,  1,  3, 11, 15,  0,  5, 12,  2, 13,  9,  7, 10, 14,
        12, 15, 10,  4,  1,  5,  8,  7,  6,  2, 13, 14,  0,  3,  9, 11]);
    var _sl = WordArray.create([
         11, 14, 15, 12,  5,  8,  7,  9, 11, 13, 14, 15,  6,  7,  9,  8,
        7, 6,   8, 13, 11,  9,  7, 15,  7, 12, 15,  9, 11,  7, 13, 12,
        11, 13,  6,  7, 14,  9, 13, 15, 14,  8, 13,  6,  5, 12,  7,  5,
          11, 12, 14, 15, 14, 15,  9,  8,  9, 14,  5,  6,  8,  6,  5, 12,
        9, 15,  5, 11,  6,  8, 13, 12,  5, 12, 13, 14, 11,  8,  5,  6 ]);
    var _sr = WordArray.create([
        8,  9,  9, 11, 13, 15, 15,  5,  7,  7,  8, 11, 14, 14, 12,  6,
        9, 13, 15,  7, 12,  8,  9, 11,  7,  7, 12,  7,  6, 15, 13, 11,
        9,  7, 15, 11,  8,  6,  6, 14, 12, 13,  5, 14, 13, 13,  7,  5,
        15,  5,  8, 11, 14, 14,  6, 14,  6,  9, 12,  9, 12,  5, 15,  8,
        8,  5, 12,  9, 12,  5, 14,  6,  8, 13,  6,  5, 15, 13, 11, 11 ]);

    var _hl =  WordArray.create([ 0x00000000, 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xA953FD4E]);
    var _hr =  WordArray.create([ 0x50A28BE6, 0x5C4DD124, 0x6D703EF3, 0x7A6D76E9, 0x00000000]);

    /**
     * RIPEMD160 hash algorithm.
     */
    var RIPEMD160 = C_algo.RIPEMD160 = Hasher.extend({
        _doReset: function () {
            this._hash  = WordArray.create([0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0]);
        },

        _doProcessBlock: function (M, offset) {

            // Swap endian
            for (var i = 0; i < 16; i++) {
                // Shortcuts
                var offset_i = offset + i;
                var M_offset_i = M[offset_i];

                // Swap
                M[offset_i] = (
                    (((M_offset_i << 8)  | (M_offset_i >>> 24)) & 0x00ff00ff) |
                    (((M_offset_i << 24) | (M_offset_i >>> 8))  & 0xff00ff00)
                );
            }
            // Shortcut
            var H  = this._hash.words;
            var hl = _hl.words;
            var hr = _hr.words;
            var zl = _zl.words;
            var zr = _zr.words;
            var sl = _sl.words;
            var sr = _sr.words;

            // Working variables
            var al, bl, cl, dl, el;
            var ar, br, cr, dr, er;

            ar = al = H[0];
            br = bl = H[1];
            cr = cl = H[2];
            dr = dl = H[3];
            er = el = H[4];
            // Computation
            var t;
            for (var i = 0; i < 80; i += 1) {
                t = (al +  M[offset+zl[i]])|0;
                if (i<16){
	            t +=  f1(bl,cl,dl) + hl[0];
                } else if (i<32) {
	            t +=  f2(bl,cl,dl) + hl[1];
                } else if (i<48) {
	            t +=  f3(bl,cl,dl) + hl[2];
                } else if (i<64) {
	            t +=  f4(bl,cl,dl) + hl[3];
                } else {// if (i<80) {
	            t +=  f5(bl,cl,dl) + hl[4];
                }
                t = t|0;
                t =  rotl(t,sl[i]);
                t = (t+el)|0;
                al = el;
                el = dl;
                dl = rotl(cl, 10);
                cl = bl;
                bl = t;

                t = (ar + M[offset+zr[i]])|0;
                if (i<16){
	            t +=  f5(br,cr,dr) + hr[0];
                } else if (i<32) {
	            t +=  f4(br,cr,dr) + hr[1];
                } else if (i<48) {
	            t +=  f3(br,cr,dr) + hr[2];
                } else if (i<64) {
	            t +=  f2(br,cr,dr) + hr[3];
                } else {// if (i<80) {
	            t +=  f1(br,cr,dr) + hr[4];
                }
                t = t|0;
                t =  rotl(t,sr[i]) ;
                t = (t+er)|0;
                ar = er;
                er = dr;
                dr = rotl(cr, 10);
                cr = br;
                br = t;
            }
            // Intermediate hash value
            t    = (H[1] + cl + dr)|0;
            H[1] = (H[2] + dl + er)|0;
            H[2] = (H[3] + el + ar)|0;
            H[3] = (H[4] + al + br)|0;
            H[4] = (H[0] + bl + cr)|0;
            H[0] =  t;
        },

        _doFinalize: function () {
            // Shortcuts
            var data = this._data;
            var dataWords = data.words;

            var nBitsTotal = this._nDataBytes * 8;
            var nBitsLeft = data.sigBytes * 8;

            // Add padding
            dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
            dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = (
                (((nBitsTotal << 8)  | (nBitsTotal >>> 24)) & 0x00ff00ff) |
                (((nBitsTotal << 24) | (nBitsTotal >>> 8))  & 0xff00ff00)
            );
            data.sigBytes = (dataWords.length + 1) * 4;

            // Hash final blocks
            this._process();

            // Shortcuts
            var hash = this._hash;
            var H = hash.words;

            // Swap endian
            for (var i = 0; i < 5; i++) {
                // Shortcut
                var H_i = H[i];

                // Swap
                H[i] = (((H_i << 8)  | (H_i >>> 24)) & 0x00ff00ff) |
                       (((H_i << 24) | (H_i >>> 8))  & 0xff00ff00);
            }

            // Return final computed hash
            return hash;
        },

        clone: function () {
            var clone = Hasher.clone.call(this);
            clone._hash = this._hash.clone();

            return clone;
        }
    });


    function f1(x, y, z) {
        return ((x) ^ (y) ^ (z));

    }

    function f2(x, y, z) {
        return (((x)&(y)) | ((~x)&(z)));
    }

    function f3(x, y, z) {
        return (((x) | (~(y))) ^ (z));
    }

    function f4(x, y, z) {
        return (((x) & (z)) | ((y)&(~(z))));
    }

    function f5(x, y, z) {
        return ((x) ^ ((y) |(~(z))));

    }

    function rotl(x,n) {
        return (x<<n) | (x>>>(32-n));
    }


    /**
     * Shortcut function to the hasher's object interface.
     *
     * @param {WordArray|string} message The message to hash.
     *
     * @return {WordArray} The hash.
     *
     * @static
     *
     * @example
     *
     *     var hash = CryptoJS.RIPEMD160('message');
     *     var hash = CryptoJS.RIPEMD160(wordArray);
     */
    C.RIPEMD160 = Hasher._createHelper(RIPEMD160);

    /**
     * Shortcut function to the HMAC's object interface.
     *
     * @param {WordArray|string} message The message to hash.
     * @param {WordArray|string} key The secret key.
     *
     * @return {WordArray} The HMAC.
     *
     * @static
     *
     * @example
     *
     *     var hmac = CryptoJS.HmacRIPEMD160(message, key);
     */
    C.HmacRIPEMD160 = Hasher._createHmacHelper(RIPEMD160);
}(Math));
(function () {
    // Shortcuts
    var C = CryptoJS;
    var C_lib = C.lib;
    var WordArray = C_lib.WordArray;
    var Hasher = C_lib.Hasher;
    var C_algo = C.algo;

    // Reusable object
    var W = [];

    /**
     * SHA-1 hash algorithm.
     */
    var SHA1 = C_algo.SHA1 = Hasher.extend({
        _doReset: function () {
            this._hash = new WordArray.init([
                0x67452301, 0xefcdab89,
                0x98badcfe, 0x10325476,
                0xc3d2e1f0
            ]);
        },

        _doProcessBlock: function (M, offset) {
            // Shortcut
            var H = this._hash.words;

            // Working variables
            var a = H[0];
            var b = H[1];
            var c = H[2];
            var d = H[3];
            var e = H[4];

            // Computation
            for (var i = 0; i < 80; i++) {
                if (i < 16) {
                    W[i] = M[offset + i] | 0;
                } else {
                    var n = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16];
                    W[i] = (n << 1) | (n >>> 31);
                }

                var t = ((a << 5) | (a >>> 27)) + e + W[i];
                if (i < 20) {
                    t += ((b & c) | (~b & d)) + 0x5a827999;
                } else if (i < 40) {
                    t += (b ^ c ^ d) + 0x6ed9eba1;
                } else if (i < 60) {
                    t += ((b & c) | (b & d) | (c & d)) - 0x70e44324;
                } else /* if (i < 80) */ {
                    t += (b ^ c ^ d) - 0x359d3e2a;
                }

                e = d;
                d = c;
                c = (b << 30) | (b >>> 2);
                b = a;
                a = t;
            }

            // Intermediate hash value
            H[0] = (H[0] + a) | 0;
            H[1] = (H[1] + b) | 0;
            H[2] = (H[2] + c) | 0;
            H[3] = (H[3] + d) | 0;
            H[4] = (H[4] + e) | 0;
        },

        _doFinalize: function () {
            // Shortcuts
            var data = this._data;
            var dataWords = data.words;

            var nBitsTotal = this._nDataBytes * 8;
            var nBitsLeft = data.sigBytes * 8;

            // Add padding
            dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
            dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000);
            dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal;
            data.sigBytes = dataWords.length * 4;

            // Hash final blocks
            this._process();

            // Return final computed hash
            return this._hash;
        },

        clone: function () {
            var clone = Hasher.clone.call(this);
            clone._hash = this._hash.clone();

            return clone;
        }
    });

    /**
     * Shortcut function to the hasher's object interface.
     *
     * @param {WordArray|string} message The message to hash.
     *
     * @return {WordArray} The hash.
     *
     * @static
     *
     * @example
     *
     *     var hash = CryptoJS.SHA1('message');
     *     var hash = CryptoJS.SHA1(wordArray);
     */
    C.SHA1 = Hasher._createHelper(SHA1);

    /**
     * Shortcut function to the HMAC's object interface.
     *
     * @param {WordArray|string} message The message to hash.
     * @param {WordArray|string} key The secret key.
     *
     * @return {WordArray} The HMAC.
     *
     * @static
     *
     * @example
     *
     *     var hmac = CryptoJS.HmacSHA1(message, key);
     */
    C.HmacSHA1 = Hasher._createHmacHelper(SHA1);
}());
(function () {
    // Shortcuts
    var C = CryptoJS;
    var C_lib = C.lib;
    var WordArray = C_lib.WordArray;
    var C_algo = C.algo;
    var SHA256 = C_algo.SHA256;

    /**
     * SHA-224 hash algorithm.
     */
    var SHA224 = C_algo.SHA224 = SHA256.extend({
        _doReset: function () {
            this._hash = new WordArray.init([
                0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939,
                0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4
            ]);
        },

        _doFinalize: function () {
            var hash = SHA256._doFinalize.call(this);

            hash.sigBytes -= 4;

            return hash;
        }
    });

    /**
     * Shortcut function to the hasher's object interface.
     *
     * @param {WordArray|string} message The message to hash.
     *
     * @return {WordArray} The hash.
     *
     * @static
     *
     * @example
     *
     *     var hash = CryptoJS.SHA224('message');
     *     var hash = CryptoJS.SHA224(wordArray);
     */
    C.SHA224 = SHA256._createHelper(SHA224);

    /**
     * Shortcut function to the HMAC's object interface.
     *
     * @param {WordArray|string} message The message to hash.
     * @param {WordArray|string} key The secret key.
     *
     * @return {WordArray} The HMAC.
     *
     * @static
     *
     * @example
     *
     *     var hmac = CryptoJS.HmacSHA224(message, key);
     */
    C.HmacSHA224 = SHA256._createHmacHelper(SHA224);
}());
(function (Math) {
    // Shortcuts
    var C = CryptoJS;
    var C_lib = C.lib;
    var WordArray = C_lib.WordArray;
    var Hasher = C_lib.Hasher;
    var C_algo = C.algo;

    // Initialization and round constants tables
    var H = [];
    var K = [];

    // Compute constants
    (function () {
        function isPrime(n) {
            var sqrtN = Math.sqrt(n);
            for (var factor = 2; factor <= sqrtN; factor++) {
                if (!(n % factor)) {
                    return false;
                }
            }

            return true;
        }

        function getFractionalBits(n) {
            return ((n - (n | 0)) * 0x100000000) | 0;
        }

        var n = 2;
        var nPrime = 0;
        while (nPrime < 64) {
            if (isPrime(n)) {
                if (nPrime < 8) {
                    H[nPrime] = getFractionalBits(Math.pow(n, 1 / 2));
                }
                K[nPrime] = getFractionalBits(Math.pow(n, 1 / 3));

                nPrime++;
            }

            n++;
        }
    }());

    // Reusable object
    var W = [];

    /**
     * SHA-256 hash algorithm.
     */
    var SHA256 = C_algo.SHA256 = Hasher.extend({
        _doReset: function () {
            this._hash = new WordArray.init(H.slice(0));
        },

        _doProcessBlock: function (M, offset) {
            // Shortcut
            var H = this._hash.words;

            // Working variables
            var a = H[0];
            var b = H[1];
            var c = H[2];
            var d = H[3];
            var e = H[4];
            var f = H[5];
            var g = H[6];
            var h = H[7];

            // Computation
            for (var i = 0; i < 64; i++) {
                if (i < 16) {
                    W[i] = M[offset + i] | 0;
                } else {
                    var gamma0x = W[i - 15];
                    var gamma0  = ((gamma0x << 25) | (gamma0x >>> 7))  ^
                                  ((gamma0x << 14) | (gamma0x >>> 18)) ^
                                   (gamma0x >>> 3);

                    var gamma1x = W[i - 2];
                    var gamma1  = ((gamma1x << 15) | (gamma1x >>> 17)) ^
                                  ((gamma1x << 13) | (gamma1x >>> 19)) ^
                                   (gamma1x >>> 10);

                    W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16];
                }

                var ch  = (e & f) ^ (~e & g);
                var maj = (a & b) ^ (a & c) ^ (b & c);

                var sigma0 = ((a << 30) | (a >>> 2)) ^ ((a << 19) | (a >>> 13)) ^ ((a << 10) | (a >>> 22));
                var sigma1 = ((e << 26) | (e >>> 6)) ^ ((e << 21) | (e >>> 11)) ^ ((e << 7)  | (e >>> 25));

                var t1 = h + sigma1 + ch + K[i] + W[i];
                var t2 = sigma0 + maj;

                h = g;
                g = f;
                f = e;
                e = (d + t1) | 0;
                d = c;
                c = b;
                b = a;
                a = (t1 + t2) | 0;
            }

            // Intermediate hash value
            H[0] = (H[0] + a) | 0;
            H[1] = (H[1] + b) | 0;
            H[2] = (H[2] + c) | 0;
            H[3] = (H[3] + d) | 0;
            H[4] = (H[4] + e) | 0;
            H[5] = (H[5] + f) | 0;
            H[6] = (H[6] + g) | 0;
            H[7] = (H[7] + h) | 0;
        },

        _doFinalize: function () {
            // Shortcuts
            var data = this._data;
            var dataWords = data.words;

            var nBitsTotal = this._nDataBytes * 8;
            var nBitsLeft = data.sigBytes * 8;

            // Add padding
            dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
            dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000);
            dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal;
            data.sigBytes = dataWords.length * 4;

            // Hash final blocks
            this._process();

            // Return final computed hash
            return this._hash;
        },

        clone: function () {
            var clone = Hasher.clone.call(this);
            clone._hash = this._hash.clone();

            return clone;
        }
    });

    /**
     * Shortcut function to the hasher's object interface.
     *
     * @param {WordArray|string} message The message to hash.
     *
     * @return {WordArray} The hash.
     *
     * @static
     *
     * @example
     *
     *     var hash = CryptoJS.SHA256('message');
     *     var hash = CryptoJS.SHA256(wordArray);
     */
    C.SHA256 = Hasher._createHelper(SHA256);

    /**
     * Shortcut function to the HMAC's object interface.
     *
     * @param {WordArray|string} message The message to hash.
     * @param {WordArray|string} key The secret key.
     *
     * @return {WordArray} The HMAC.
     *
     * @static
     *
     * @example
     *
     *     var hmac = CryptoJS.HmacSHA256(message, key);
     */
    C.HmacSHA256 = Hasher._createHmacHelper(SHA256);
}(Math));
(function (Math) {
    // Shortcuts
    var C = CryptoJS;
    var C_lib = C.lib;
    var WordArray = C_lib.WordArray;
    var Hasher = C_lib.Hasher;
    var C_x64 = C.x64;
    var X64Word = C_x64.Word;
    var C_algo = C.algo;

    // Constants tables
    var RHO_OFFSETS = [];
    var PI_INDEXES  = [];
    var ROUND_CONSTANTS = [];

    // Compute Constants
    (function () {
        // Compute rho offset constants
        var x = 1, y = 0;
        for (var t = 0; t < 24; t++) {
            RHO_OFFSETS[x + 5 * y] = ((t + 1) * (t + 2) / 2) % 64;

            var newX = y % 5;
            var newY = (2 * x + 3 * y) % 5;
            x = newX;
            y = newY;
        }

        // Compute pi index constants
        for (var x = 0; x < 5; x++) {
            for (var y = 0; y < 5; y++) {
                PI_INDEXES[x + 5 * y] = y + ((2 * x + 3 * y) % 5) * 5;
            }
        }

        // Compute round constants
        var LFSR = 0x01;
        for (var i = 0; i < 24; i++) {
            var roundConstantMsw = 0;
            var roundConstantLsw = 0;

            for (var j = 0; j < 7; j++) {
                if (LFSR & 0x01) {
                    var bitPosition = (1 << j) - 1;
                    if (bitPosition < 32) {
                        roundConstantLsw ^= 1 << bitPosition;
                    } else /* if (bitPosition >= 32) */ {
                        roundConstantMsw ^= 1 << (bitPosition - 32);
                    }
                }

                // Compute next LFSR
                if (LFSR & 0x80) {
                    // Primitive polynomial over GF(2): x^8 + x^6 + x^5 + x^4 + 1
                    LFSR = (LFSR << 1) ^ 0x71;
                } else {
                    LFSR <<= 1;
                }
            }

            ROUND_CONSTANTS[i] = X64Word.create(roundConstantMsw, roundConstantLsw);
        }
    }());

    // Reusable objects for temporary values
    var T = [];
    (function () {
        for (var i = 0; i < 25; i++) {
            T[i] = X64Word.create();
        }
    }());

    /**
     * SHA-3 hash algorithm.
     */
    var SHA3 = C_algo.SHA3 = Hasher.extend({
        /**
         * Configuration options.
         *
         * @property {number} outputLength
         *   The desired number of bits in the output hash.
         *   Only values permitted are: 224, 256, 384, 512.
         *   Default: 512
         */
        cfg: Hasher.cfg.extend({
            outputLength: 512
        }),

        _doReset: function () {
            var state = this._state = []
            for (var i = 0; i < 25; i++) {
                state[i] = new X64Word.init();
            }

            this.blockSize = (1600 - 2 * this.cfg.outputLength) / 32;
        },

        _doProcessBlock: function (M, offset) {
            // Shortcuts
            var state = this._state;
            var nBlockSizeLanes = this.blockSize / 2;

            // Absorb
            for (var i = 0; i < nBlockSizeLanes; i++) {
                // Shortcuts
                var M2i  = M[offset + 2 * i];
                var M2i1 = M[offset + 2 * i + 1];

                // Swap endian
                M2i = (
                    (((M2i << 8)  | (M2i >>> 24)) & 0x00ff00ff) |
                    (((M2i << 24) | (M2i >>> 8))  & 0xff00ff00)
                );
                M2i1 = (
                    (((M2i1 << 8)  | (M2i1 >>> 24)) & 0x00ff00ff) |
                    (((M2i1 << 24) | (M2i1 >>> 8))  & 0xff00ff00)
                );

                // Absorb message into state
                var lane = state[i];
                lane.high ^= M2i1;
                lane.low  ^= M2i;
            }

            // Rounds
            for (var round = 0; round < 24; round++) {
                // Theta
                for (var x = 0; x < 5; x++) {
                    // Mix column lanes
                    var tMsw = 0, tLsw = 0;
                    for (var y = 0; y < 5; y++) {
                        var lane = state[x + 5 * y];
                        tMsw ^= lane.high;
                        tLsw ^= lane.low;
                    }

                    // Temporary values
                    var Tx = T[x];
                    Tx.high = tMsw;
                    Tx.low  = tLsw;
                }
                for (var x = 0; x < 5; x++) {
                    // Shortcuts
                    var Tx4 = T[(x + 4) % 5];
                    var Tx1 = T[(x + 1) % 5];
                    var Tx1Msw = Tx1.high;
                    var Tx1Lsw = Tx1.low;

                    // Mix surrounding columns
                    var tMsw = Tx4.high ^ ((Tx1Msw << 1) | (Tx1Lsw >>> 31));
                    var tLsw = Tx4.low  ^ ((Tx1Lsw << 1) | (Tx1Msw >>> 31));
                    for (var y = 0; y < 5; y++) {
                        var lane = state[x + 5 * y];
                        lane.high ^= tMsw;
                        lane.low  ^= tLsw;
                    }
                }

                // Rho Pi
                for (var laneIndex = 1; laneIndex < 25; laneIndex++) {
                    var tMsw;
                    var tLsw;

                    // Shortcuts
                    var lane = state[laneIndex];
                    var laneMsw = lane.high;
                    var laneLsw = lane.low;
                    var rhoOffset = RHO_OFFSETS[laneIndex];

                    // Rotate lanes
                    if (rhoOffset < 32) {
                        tMsw = (laneMsw << rhoOffset) | (laneLsw >>> (32 - rhoOffset));
                        tLsw = (laneLsw << rhoOffset) | (laneMsw >>> (32 - rhoOffset));
                    } else /* if (rhoOffset >= 32) */ {
                        tMsw = (laneLsw << (rhoOffset - 32)) | (laneMsw >>> (64 - rhoOffset));
                        tLsw = (laneMsw << (rhoOffset - 32)) | (laneLsw >>> (64 - rhoOffset));
                    }

                    // Transpose lanes
                    var TPiLane = T[PI_INDEXES[laneIndex]];
                    TPiLane.high = tMsw;
                    TPiLane.low  = tLsw;
                }

                // Rho pi at x = y = 0
                var T0 = T[0];
                var state0 = state[0];
                T0.high = state0.high;
                T0.low  = state0.low;

                // Chi
                for (var x = 0; x < 5; x++) {
                    for (var y = 0; y < 5; y++) {
                        // Shortcuts
                        var laneIndex = x + 5 * y;
                        var lane = state[laneIndex];
                        var TLane = T[laneIndex];
                        var Tx1Lane = T[((x + 1) % 5) + 5 * y];
                        var Tx2Lane = T[((x + 2) % 5) + 5 * y];

                        // Mix rows
                        lane.high = TLane.high ^ (~Tx1Lane.high & Tx2Lane.high);
                        lane.low  = TLane.low  ^ (~Tx1Lane.low  & Tx2Lane.low);
                    }
                }

                // Iota
                var lane = state[0];
                var roundConstant = ROUND_CONSTANTS[round];
                lane.high ^= roundConstant.high;
                lane.low  ^= roundConstant.low;
            }
        },

        _doFinalize: function () {
            // Shortcuts
            var data = this._data;
            var dataWords = data.words;
            var nBitsTotal = this._nDataBytes * 8;
            var nBitsLeft = data.sigBytes * 8;
            var blockSizeBits = this.blockSize * 32;

            // Add padding
            dataWords[nBitsLeft >>> 5] |= 0x1 << (24 - nBitsLeft % 32);
            dataWords[((Math.ceil((nBitsLeft + 1) / blockSizeBits) * blockSizeBits) >>> 5) - 1] |= 0x80;
            data.sigBytes = dataWords.length * 4;

            // Hash final blocks
            this._process();

            // Shortcuts
            var state = this._state;
            var outputLengthBytes = this.cfg.outputLength / 8;
            var outputLengthLanes = outputLengthBytes / 8;

            // Squeeze
            var hashWords = [];
            for (var i = 0; i < outputLengthLanes; i++) {
                // Shortcuts
                var lane = state[i];
                var laneMsw = lane.high;
                var laneLsw = lane.low;

                // Swap endian
                laneMsw = (
                    (((laneMsw << 8)  | (laneMsw >>> 24)) & 0x00ff00ff) |
                    (((laneMsw << 24) | (laneMsw >>> 8))  & 0xff00ff00)
                );
                laneLsw = (
                    (((laneLsw << 8)  | (laneLsw >>> 24)) & 0x00ff00ff) |
                    (((laneLsw << 24) | (laneLsw >>> 8))  & 0xff00ff00)
                );

                // Squeeze state to retrieve hash
                hashWords.push(laneLsw);
                hashWords.push(laneMsw);
            }

            // Return final computed hash
            return new WordArray.init(hashWords, outputLengthBytes);
        },

        clone: function () {
            var clone = Hasher.clone.call(this);

            var state = clone._state = this._state.slice(0);
            for (var i = 0; i < 25; i++) {
                state[i] = state[i].clone();
            }

            return clone;
        }
    });

    /**
     * Shortcut function to the hasher's object interface.
     *
     * @param {WordArray|string} message The message to hash.
     *
     * @return {WordArray} The hash.
     *
     * @static
     *
     * @example
     *
     *     var hash = CryptoJS.SHA3('message');
     *     var hash = CryptoJS.SHA3(wordArray);
     */
    C.SHA3 = Hasher._createHelper(SHA3);

    /**
     * Shortcut function to the HMAC's object interface.
     *
     * @param {WordArray|string} message The message to hash.
     * @param {WordArray|string} key The secret key.
     *
     * @return {WordArray} The HMAC.
     *
     * @static
     *
     * @example
     *
     *     var hmac = CryptoJS.HmacSHA3(message, key);
     */
    C.HmacSHA3 = Hasher._createHmacHelper(SHA3);
}(Math));
(function () {
    // Shortcuts
    var C = CryptoJS;
    var C_x64 = C.x64;
    var X64Word = C_x64.Word;
    var X64WordArray = C_x64.WordArray;
    var C_algo = C.algo;
    var SHA512 = C_algo.SHA512;

    /**
     * SHA-384 hash algorithm.
     */
    var SHA384 = C_algo.SHA384 = SHA512.extend({
        _doReset: function () {
            this._hash = new X64WordArray.init([
                new X64Word.init(0xcbbb9d5d, 0xc1059ed8), new X64Word.init(0x629a292a, 0x367cd507),
                new X64Word.init(0x9159015a, 0x3070dd17), new X64Word.init(0x152fecd8, 0xf70e5939),
                new X64Word.init(0x67332667, 0xffc00b31), new X64Word.init(0x8eb44a87, 0x68581511),
                new X64Word.init(0xdb0c2e0d, 0x64f98fa7), new X64Word.init(0x47b5481d, 0xbefa4fa4)
            ]);
        },

        _doFinalize: function () {
            var hash = SHA512._doFinalize.call(this);

            hash.sigBytes -= 16;

            return hash;
        }
    });

    /**
     * Shortcut function to the hasher's object interface.
     *
     * @param {WordArray|string} message The message to hash.
     *
     * @return {WordArray} The hash.
     *
     * @static
     *
     * @example
     *
     *     var hash = CryptoJS.SHA384('message');
     *     var hash = CryptoJS.SHA384(wordArray);
     */
    C.SHA384 = SHA512._createHelper(SHA384);

    /**
     * Shortcut function to the HMAC's object interface.
     *
     * @param {WordArray|string} message The message to hash.
     * @param {WordArray|string} key The secret key.
     *
     * @return {WordArray} The HMAC.
     *
     * @static
     *
     * @example
     *
     *     var hmac = CryptoJS.HmacSHA384(message, key);
     */
    C.HmacSHA384 = SHA512._createHmacHelper(SHA384);
}());
(function () {
    // Shortcuts
    var C = CryptoJS;
    var C_lib = C.lib;
    var Hasher = C_lib.Hasher;
    var C_x64 = C.x64;
    var X64Word = C_x64.Word;
    var X64WordArray = C_x64.WordArray;
    var C_algo = C.algo;

    function X64Word_create() {
        return X64Word.create.apply(X64Word, arguments);
    }

    // Constants
    var K = [
        X64Word_create(0x428a2f98, 0xd728ae22), X64Word_create(0x71374491, 0x23ef65cd),
        X64Word_create(0xb5c0fbcf, 0xec4d3b2f), X64Word_create(0xe9b5dba5, 0x8189dbbc),
        X64Word_create(0x3956c25b, 0xf348b538), X64Word_create(0x59f111f1, 0xb605d019),
        X64Word_create(0x923f82a4, 0xaf194f9b), X64Word_create(0xab1c5ed5, 0xda6d8118),
        X64Word_create(0xd807aa98, 0xa3030242), X64Word_create(0x12835b01, 0x45706fbe),
        X64Word_create(0x243185be, 0x4ee4b28c), X64Word_create(0x550c7dc3, 0xd5ffb4e2),
        X64Word_create(0x72be5d74, 0xf27b896f), X64Word_create(0x80deb1fe, 0x3b1696b1),
        X64Word_create(0x9bdc06a7, 0x25c71235), X64Word_create(0xc19bf174, 0xcf692694),
        X64Word_create(0xe49b69c1, 0x9ef14ad2), X64Word_create(0xefbe4786, 0x384f25e3),
        X64Word_create(0x0fc19dc6, 0x8b8cd5b5), X64Word_create(0x240ca1cc, 0x77ac9c65),
        X64Word_create(0x2de92c6f, 0x592b0275), X64Word_create(0x4a7484aa, 0x6ea6e483),
        X64Word_create(0x5cb0a9dc, 0xbd41fbd4), X64Word_create(0x76f988da, 0x831153b5),
        X64Word_create(0x983e5152, 0xee66dfab), X64Word_create(0xa831c66d, 0x2db43210),
        X64Word_create(0xb00327c8, 0x98fb213f), X64Word_create(0xbf597fc7, 0xbeef0ee4),
        X64Word_create(0xc6e00bf3, 0x3da88fc2), X64Word_create(0xd5a79147, 0x930aa725),
        X64Word_create(0x06ca6351, 0xe003826f), X64Word_create(0x14292967, 0x0a0e6e70),
        X64Word_create(0x27b70a85, 0x46d22ffc), X64Word_create(0x2e1b2138, 0x5c26c926),
        X64Word_create(0x4d2c6dfc, 0x5ac42aed), X64Word_create(0x53380d13, 0x9d95b3df),
        X64Word_create(0x650a7354, 0x8baf63de), X64Word_create(0x766a0abb, 0x3c77b2a8),
        X64Word_create(0x81c2c92e, 0x47edaee6), X64Word_create(0x92722c85, 0x1482353b),
        X64Word_create(0xa2bfe8a1, 0x4cf10364), X64Word_create(0xa81a664b, 0xbc423001),
        X64Word_create(0xc24b8b70, 0xd0f89791), X64Word_create(0xc76c51a3, 0x0654be30),
        X64Word_create(0xd192e819, 0xd6ef5218), X64Word_create(0xd6990624, 0x5565a910),
        X64Word_create(0xf40e3585, 0x5771202a), X64Word_create(0x106aa070, 0x32bbd1b8),
        X64Word_create(0x19a4c116, 0xb8d2d0c8), X64Word_create(0x1e376c08, 0x5141ab53),
        X64Word_create(0x2748774c, 0xdf8eeb99), X64Word_create(0x34b0bcb5, 0xe19b48a8),
        X64Word_create(0x391c0cb3, 0xc5c95a63), X64Word_create(0x4ed8aa4a, 0xe3418acb),
        X64Word_create(0x5b9cca4f, 0x7763e373), X64Word_create(0x682e6ff3, 0xd6b2b8a3),
        X64Word_create(0x748f82ee, 0x5defb2fc), X64Word_create(0x78a5636f, 0x43172f60),
        X64Word_create(0x84c87814, 0xa1f0ab72), X64Word_create(0x8cc70208, 0x1a6439ec),
        X64Word_create(0x90befffa, 0x23631e28), X64Word_create(0xa4506ceb, 0xde82bde9),
        X64Word_create(0xbef9a3f7, 0xb2c67915), X64Word_create(0xc67178f2, 0xe372532b),
        X64Word_create(0xca273ece, 0xea26619c), X64Word_create(0xd186b8c7, 0x21c0c207),
        X64Word_create(0xeada7dd6, 0xcde0eb1e), X64Word_create(0xf57d4f7f, 0xee6ed178),
        X64Word_create(0x06f067aa, 0x72176fba), X64Word_create(0x0a637dc5, 0xa2c898a6),
        X64Word_create(0x113f9804, 0xbef90dae), X64Word_create(0x1b710b35, 0x131c471b),
        X64Word_create(0x28db77f5, 0x23047d84), X64Word_create(0x32caab7b, 0x40c72493),
        X64Word_create(0x3c9ebe0a, 0x15c9bebc), X64Word_create(0x431d67c4, 0x9c100d4c),
        X64Word_create(0x4cc5d4be, 0xcb3e42b6), X64Word_create(0x597f299c, 0xfc657e2a),
        X64Word_create(0x5fcb6fab, 0x3ad6faec), X64Word_create(0x6c44198c, 0x4a475817)
    ];

    // Reusable objects
    var W = [];
    (function () {
        for (var i = 0; i < 80; i++) {
            W[i] = X64Word_create();
        }
    }());

    /**
     * SHA-512 hash algorithm.
     */
    var SHA512 = C_algo.SHA512 = Hasher.extend({
        _doReset: function () {
            this._hash = new X64WordArray.init([
                new X64Word.init(0x6a09e667, 0xf3bcc908), new X64Word.init(0xbb67ae85, 0x84caa73b),
                new X64Word.init(0x3c6ef372, 0xfe94f82b), new X64Word.init(0xa54ff53a, 0x5f1d36f1),
                new X64Word.init(0x510e527f, 0xade682d1), new X64Word.init(0x9b05688c, 0x2b3e6c1f),
                new X64Word.init(0x1f83d9ab, 0xfb41bd6b), new X64Word.init(0x5be0cd19, 0x137e2179)
            ]);
        },

        _doProcessBlock: function (M, offset) {
            // Shortcuts
            var H = this._hash.words;

            var H0 = H[0];
            var H1 = H[1];
            var H2 = H[2];
            var H3 = H[3];
            var H4 = H[4];
            var H5 = H[5];
            var H6 = H[6];
            var H7 = H[7];

            var H0h = H0.high;
            var H0l = H0.low;
            var H1h = H1.high;
            var H1l = H1.low;
            var H2h = H2.high;
            var H2l = H2.low;
            var H3h = H3.high;
            var H3l = H3.low;
            var H4h = H4.high;
            var H4l = H4.low;
            var H5h = H5.high;
            var H5l = H5.low;
            var H6h = H6.high;
            var H6l = H6.low;
            var H7h = H7.high;
            var H7l = H7.low;

            // Working variables
            var ah = H0h;
            var al = H0l;
            var bh = H1h;
            var bl = H1l;
            var ch = H2h;
            var cl = H2l;
            var dh = H3h;
            var dl = H3l;
            var eh = H4h;
            var el = H4l;
            var fh = H5h;
            var fl = H5l;
            var gh = H6h;
            var gl = H6l;
            var hh = H7h;
            var hl = H7l;

            // Rounds
            for (var i = 0; i < 80; i++) {
                var Wil;
                var Wih;

                // Shortcut
                var Wi = W[i];

                // Extend message
                if (i < 16) {
                    Wih = Wi.high = M[offset + i * 2]     | 0;
                    Wil = Wi.low  = M[offset + i * 2 + 1] | 0;
                } else {
                    // Gamma0
                    var gamma0x  = W[i - 15];
                    var gamma0xh = gamma0x.high;
                    var gamma0xl = gamma0x.low;
                    var gamma0h  = ((gamma0xh >>> 1) | (gamma0xl << 31)) ^ ((gamma0xh >>> 8) | (gamma0xl << 24)) ^ (gamma0xh >>> 7);
                    var gamma0l  = ((gamma0xl >>> 1) | (gamma0xh << 31)) ^ ((gamma0xl >>> 8) | (gamma0xh << 24)) ^ ((gamma0xl >>> 7) | (gamma0xh << 25));

                    // Gamma1
                    var gamma1x  = W[i - 2];
                    var gamma1xh = gamma1x.high;
                    var gamma1xl = gamma1x.low;
                    var gamma1h  = ((gamma1xh >>> 19) | (gamma1xl << 13)) ^ ((gamma1xh << 3) | (gamma1xl >>> 29)) ^ (gamma1xh >>> 6);
                    var gamma1l  = ((gamma1xl >>> 19) | (gamma1xh << 13)) ^ ((gamma1xl << 3) | (gamma1xh >>> 29)) ^ ((gamma1xl >>> 6) | (gamma1xh << 26));

                    // W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16]
                    var Wi7  = W[i - 7];
                    var Wi7h = Wi7.high;
                    var Wi7l = Wi7.low;

                    var Wi16  = W[i - 16];
                    var Wi16h = Wi16.high;
                    var Wi16l = Wi16.low;

                    Wil = gamma0l + Wi7l;
                    Wih = gamma0h + Wi7h + ((Wil >>> 0) < (gamma0l >>> 0) ? 1 : 0);
                    Wil = Wil + gamma1l;
                    Wih = Wih + gamma1h + ((Wil >>> 0) < (gamma1l >>> 0) ? 1 : 0);
                    Wil = Wil + Wi16l;
                    Wih = Wih + Wi16h + ((Wil >>> 0) < (Wi16l >>> 0) ? 1 : 0);

                    Wi.high = Wih;
                    Wi.low  = Wil;
                }

                var chh  = (eh & fh) ^ (~eh & gh);
                var chl  = (el & fl) ^ (~el & gl);
                var majh = (ah & bh) ^ (ah & ch) ^ (bh & ch);
                var majl = (al & bl) ^ (al & cl) ^ (bl & cl);

                var sigma0h = ((ah >>> 28) | (al << 4))  ^ ((ah << 30)  | (al >>> 2)) ^ ((ah << 25) | (al >>> 7));
                var sigma0l = ((al >>> 28) | (ah << 4))  ^ ((al << 30)  | (ah >>> 2)) ^ ((al << 25) | (ah >>> 7));
                var sigma1h = ((eh >>> 14) | (el << 18)) ^ ((eh >>> 18) | (el << 14)) ^ ((eh << 23) | (el >>> 9));
                var sigma1l = ((el >>> 14) | (eh << 18)) ^ ((el >>> 18) | (eh << 14)) ^ ((el << 23) | (eh >>> 9));

                // t1 = h + sigma1 + ch + K[i] + W[i]
                var Ki  = K[i];
                var Kih = Ki.high;
                var Kil = Ki.low;

                var t1l = hl + sigma1l;
                var t1h = hh + sigma1h + ((t1l >>> 0) < (hl >>> 0) ? 1 : 0);
                var t1l = t1l + chl;
                var t1h = t1h + chh + ((t1l >>> 0) < (chl >>> 0) ? 1 : 0);
                var t1l = t1l + Kil;
                var t1h = t1h + Kih + ((t1l >>> 0) < (Kil >>> 0) ? 1 : 0);
                var t1l = t1l + Wil;
                var t1h = t1h + Wih + ((t1l >>> 0) < (Wil >>> 0) ? 1 : 0);

                // t2 = sigma0 + maj
                var t2l = sigma0l + majl;
                var t2h = sigma0h + majh + ((t2l >>> 0) < (sigma0l >>> 0) ? 1 : 0);

                // Update working variables
                hh = gh;
                hl = gl;
                gh = fh;
                gl = fl;
                fh = eh;
                fl = el;
                el = (dl + t1l) | 0;
                eh = (dh + t1h + ((el >>> 0) < (dl >>> 0) ? 1 : 0)) | 0;
                dh = ch;
                dl = cl;
                ch = bh;
                cl = bl;
                bh = ah;
                bl = al;
                al = (t1l + t2l) | 0;
                ah = (t1h + t2h + ((al >>> 0) < (t1l >>> 0) ? 1 : 0)) | 0;
            }

            // Intermediate hash value
            H0l = H0.low  = (H0l + al);
            H0.high = (H0h + ah + ((H0l >>> 0) < (al >>> 0) ? 1 : 0));
            H1l = H1.low  = (H1l + bl);
            H1.high = (H1h + bh + ((H1l >>> 0) < (bl >>> 0) ? 1 : 0));
            H2l = H2.low  = (H2l + cl);
            H2.high = (H2h + ch + ((H2l >>> 0) < (cl >>> 0) ? 1 : 0));
            H3l = H3.low  = (H3l + dl);
            H3.high = (H3h + dh + ((H3l >>> 0) < (dl >>> 0) ? 1 : 0));
            H4l = H4.low  = (H4l + el);
            H4.high = (H4h + eh + ((H4l >>> 0) < (el >>> 0) ? 1 : 0));
            H5l = H5.low  = (H5l + fl);
            H5.high = (H5h + fh + ((H5l >>> 0) < (fl >>> 0) ? 1 : 0));
            H6l = H6.low  = (H6l + gl);
            H6.high = (H6h + gh + ((H6l >>> 0) < (gl >>> 0) ? 1 : 0));
            H7l = H7.low  = (H7l + hl);
            H7.high = (H7h + hh + ((H7l >>> 0) < (hl >>> 0) ? 1 : 0));
        },

        _doFinalize: function () {
            // Shortcuts
            var data = this._data;
            var dataWords = data.words;

            var nBitsTotal = this._nDataBytes * 8;
            var nBitsLeft = data.sigBytes * 8;

            // Add padding
            dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
            dataWords[(((nBitsLeft + 128) >>> 10) << 5) + 30] = Math.floor(nBitsTotal / 0x100000000);
            dataWords[(((nBitsLeft + 128) >>> 10) << 5) + 31] = nBitsTotal;
            data.sigBytes = dataWords.length * 4;

            // Hash final blocks
            this._process();

            // Convert hash to 32-bit word array before returning
            var hash = this._hash.toX32();

            // Return final computed hash
            return hash;
        },

        clone: function () {
            var clone = Hasher.clone.call(this);
            clone._hash = this._hash.clone();

            return clone;
        },

        blockSize: 1024/32
    });

    /**
     * Shortcut function to the hasher's object interface.
     *
     * @param {WordArray|string} message The message to hash.
     *
     * @return {WordArray} The hash.
     *
     * @static
     *
     * @example
     *
     *     var hash = CryptoJS.SHA512('message');
     *     var hash = CryptoJS.SHA512(wordArray);
     */
    C.SHA512 = Hasher._createHelper(SHA512);

    /**
     * Shortcut function to the HMAC's object interface.
     *
     * @param {WordArray|string} message The message to hash.
     * @param {WordArray|string} key The secret key.
     *
     * @return {WordArray} The HMAC.
     *
     * @static
     *
     * @example
     *
     *     var hmac = CryptoJS.HmacSHA512(message, key);
     */
    C.HmacSHA512 = Hasher._createHmacHelper(SHA512);
}());
(function () {
    // Shortcuts
    var C = CryptoJS;
    var C_lib = C.lib;
    var WordArray = C_lib.WordArray;
    var BlockCipher = C_lib.BlockCipher;
    var C_algo = C.algo;

    // Permuted Choice 1 constants
    var PC1 = [
        57, 49, 41, 33, 25, 17, 9,  1,
        58, 50, 42, 34, 26, 18, 10, 2,
        59, 51, 43, 35, 27, 19, 11, 3,
        60, 52, 44, 36, 63, 55, 47, 39,
        31, 23, 15, 7,  62, 54, 46, 38,
        30, 22, 14, 6,  61, 53, 45, 37,
        29, 21, 13, 5,  28, 20, 12, 4
    ];

    // Permuted Choice 2 constants
    var PC2 = [
        14, 17, 11, 24, 1,  5,
        3,  28, 15, 6,  21, 10,
        23, 19, 12, 4,  26, 8,
        16, 7,  27, 20, 13, 2,
        41, 52, 31, 37, 47, 55,
        30, 40, 51, 45, 33, 48,
        44, 49, 39, 56, 34, 53,
        46, 42, 50, 36, 29, 32
    ];

    // Cumulative bit shift constants
    var BIT_SHIFTS = [1,  2,  4,  6,  8,  10, 12, 14, 15, 17, 19, 21, 23, 25, 27, 28];

    // SBOXes and round permutation constants
    var SBOX_P = [
        {
            0x0: 0x808200,
            0x10000000: 0x8000,
            0x20000000: 0x808002,
            0x30000000: 0x2,
            0x40000000: 0x200,
            0x50000000: 0x808202,
            0x60000000: 0x800202,
            0x70000000: 0x800000,
            0x80000000: 0x202,
            0x90000000: 0x800200,
            0xa0000000: 0x8200,
            0xb0000000: 0x808000,
            0xc0000000: 0x8002,
            0xd0000000: 0x800002,
            0xe0000000: 0x0,
            0xf0000000: 0x8202,
            0x8000000: 0x0,
            0x18000000: 0x808202,
            0x28000000: 0x8202,
            0x38000000: 0x8000,
            0x48000000: 0x808200,
            0x58000000: 0x200,
            0x68000000: 0x808002,
            0x78000000: 0x2,
            0x88000000: 0x800200,
            0x98000000: 0x8200,
            0xa8000000: 0x808000,
            0xb8000000: 0x800202,
            0xc8000000: 0x800002,
            0xd8000000: 0x8002,
            0xe8000000: 0x202,
            0xf8000000: 0x800000,
            0x1: 0x8000,
            0x10000001: 0x2,
            0x20000001: 0x808200,
            0x30000001: 0x800000,
            0x40000001: 0x808002,
            0x50000001: 0x8200,
            0x60000001: 0x200,
            0x70000001: 0x800202,
            0x80000001: 0x808202,
            0x90000001: 0x808000,
            0xa0000001: 0x800002,
            0xb0000001: 0x8202,
            0xc0000001: 0x202,
            0xd0000001: 0x800200,
            0xe0000001: 0x8002,
            0xf0000001: 0x0,
            0x8000001: 0x808202,
            0x18000001: 0x808000,
            0x28000001: 0x800000,
            0x38000001: 0x200,
            0x48000001: 0x8000,
            0x58000001: 0x800002,
            0x68000001: 0x2,
            0x78000001: 0x8202,
            0x88000001: 0x8002,
            0x98000001: 0x800202,
            0xa8000001: 0x202,
            0xb8000001: 0x808200,
            0xc8000001: 0x800200,
            0xd8000001: 0x0,
            0xe8000001: 0x8200,
            0xf8000001: 0x808002
        },
        {
            0x0: 0x40084010,
            0x1000000: 0x4000,
            0x2000000: 0x80000,
            0x3000000: 0x40080010,
            0x4000000: 0x40000010,
            0x5000000: 0x40084000,
            0x6000000: 0x40004000,
            0x7000000: 0x10,
            0x8000000: 0x84000,
            0x9000000: 0x40004010,
            0xa000000: 0x40000000,
            0xb000000: 0x84010,
            0xc000000: 0x80010,
            0xd000000: 0x0,
            0xe000000: 0x4010,
            0xf000000: 0x40080000,
            0x800000: 0x40004000,
            0x1800000: 0x84010,
            0x2800000: 0x10,
            0x3800000: 0x40004010,
            0x4800000: 0x40084010,
            0x5800000: 0x40000000,
            0x6800000: 0x80000,
            0x7800000: 0x40080010,
            0x8800000: 0x80010,
            0x9800000: 0x0,
            0xa800000: 0x4000,
            0xb800000: 0x40080000,
            0xc800000: 0x40000010,
            0xd800000: 0x84000,
            0xe800000: 0x40084000,
            0xf800000: 0x4010,
            0x10000000: 0x0,
            0x11000000: 0x40080010,
            0x12000000: 0x40004010,
            0x13000000: 0x40084000,
            0x14000000: 0x40080000,
            0x15000000: 0x10,
            0x16000000: 0x84010,
            0x17000000: 0x4000,
            0x18000000: 0x4010,
            0x19000000: 0x80000,
            0x1a000000: 0x80010,
            0x1b000000: 0x40000010,
            0x1c000000: 0x84000,
            0x1d000000: 0x40004000,
            0x1e000000: 0x40000000,
            0x1f000000: 0x40084010,
            0x10800000: 0x84010,
            0x11800000: 0x80000,
            0x12800000: 0x40080000,
            0x13800000: 0x4000,
            0x14800000: 0x40004000,
            0x15800000: 0x40084010,
            0x16800000: 0x10,
            0x17800000: 0x40000000,
            0x18800000: 0x40084000,
            0x19800000: 0x40000010,
            0x1a800000: 0x40004010,
            0x1b800000: 0x80010,
            0x1c800000: 0x0,
            0x1d800000: 0x4010,
            0x1e800000: 0x40080010,
            0x1f800000: 0x84000
        },
        {
            0x0: 0x104,
            0x100000: 0x0,
            0x200000: 0x4000100,
            0x300000: 0x10104,
            0x400000: 0x10004,
            0x500000: 0x4000004,
            0x600000: 0x4010104,
            0x700000: 0x4010000,
            0x800000: 0x4000000,
            0x900000: 0x4010100,
            0xa00000: 0x10100,
            0xb00000: 0x4010004,
            0xc00000: 0x4000104,
            0xd00000: 0x10000,
            0xe00000: 0x4,
            0xf00000: 0x100,
            0x80000: 0x4010100,
            0x180000: 0x4010004,
            0x280000: 0x0,
            0x380000: 0x4000100,
            0x480000: 0x4000004,
            0x580000: 0x10000,
            0x680000: 0x10004,
            0x780000: 0x104,
            0x880000: 0x4,
            0x980000: 0x100,
            0xa80000: 0x4010000,
            0xb80000: 0x10104,
            0xc80000: 0x10100,
            0xd80000: 0x4000104,
            0xe80000: 0x4010104,
            0xf80000: 0x4000000,
            0x1000000: 0x4010100,
            0x1100000: 0x10004,
            0x1200000: 0x10000,
            0x1300000: 0x4000100,
            0x1400000: 0x100,
            0x1500000: 0x4010104,
            0x1600000: 0x4000004,
            0x1700000: 0x0,
            0x1800000: 0x4000104,
            0x1900000: 0x4000000,
            0x1a00000: 0x4,
            0x1b00000: 0x10100,
            0x1c00000: 0x4010000,
            0x1d00000: 0x104,
            0x1e00000: 0x10104,
            0x1f00000: 0x4010004,
            0x1080000: 0x4000000,
            0x1180000: 0x104,
            0x1280000: 0x4010100,
            0x1380000: 0x0,
            0x1480000: 0x10004,
            0x1580000: 0x4000100,
            0x1680000: 0x100,
            0x1780000: 0x4010004,
            0x1880000: 0x10000,
            0x1980000: 0x4010104,
            0x1a80000: 0x10104,
            0x1b80000: 0x4000004,
            0x1c80000: 0x4000104,
            0x1d80000: 0x4010000,
            0x1e80000: 0x4,
            0x1f80000: 0x10100
        },
        {
            0x0: 0x80401000,
            0x10000: 0x80001040,
            0x20000: 0x401040,
            0x30000: 0x80400000,
            0x40000: 0x0,
            0x50000: 0x401000,
            0x60000: 0x80000040,
            0x70000: 0x400040,
            0x80000: 0x80000000,
            0x90000: 0x400000,
            0xa0000: 0x40,
            0xb0000: 0x80001000,
            0xc0000: 0x80400040,
            0xd0000: 0x1040,
            0xe0000: 0x1000,
            0xf0000: 0x80401040,
            0x8000: 0x80001040,
            0x18000: 0x40,
            0x28000: 0x80400040,
            0x38000: 0x80001000,
            0x48000: 0x401000,
            0x58000: 0x80401040,
            0x68000: 0x0,
            0x78000: 0x80400000,
            0x88000: 0x1000,
            0x98000: 0x80401000,
            0xa8000: 0x400000,
            0xb8000: 0x1040,
            0xc8000: 0x80000000,
            0xd8000: 0x400040,
            0xe8000: 0x401040,
            0xf8000: 0x80000040,
            0x100000: 0x400040,
            0x110000: 0x401000,
            0x120000: 0x80000040,
            0x130000: 0x0,
            0x140000: 0x1040,
            0x150000: 0x80400040,
            0x160000: 0x80401000,
            0x170000: 0x80001040,
            0x180000: 0x80401040,
            0x190000: 0x80000000,
            0x1a0000: 0x80400000,
            0x1b0000: 0x401040,
            0x1c0000: 0x80001000,
            0x1d0000: 0x400000,
            0x1e0000: 0x40,
            0x1f0000: 0x1000,
            0x108000: 0x80400000,
            0x118000: 0x80401040,
            0x128000: 0x0,
            0x138000: 0x401000,
            0x148000: 0x400040,
            0x158000: 0x80000000,
            0x168000: 0x80001040,
            0x178000: 0x40,
            0x188000: 0x80000040,
            0x198000: 0x1000,
            0x1a8000: 0x80001000,
            0x1b8000: 0x80400040,
            0x1c8000: 0x1040,
            0x1d8000: 0x80401000,
            0x1e8000: 0x400000,
            0x1f8000: 0x401040
        },
        {
            0x0: 0x80,
            0x1000: 0x1040000,
            0x2000: 0x40000,
            0x3000: 0x20000000,
            0x4000: 0x20040080,
            0x5000: 0x1000080,
            0x6000: 0x21000080,
            0x7000: 0x40080,
            0x8000: 0x1000000,
            0x9000: 0x20040000,
            0xa000: 0x20000080,
            0xb000: 0x21040080,
            0xc000: 0x21040000,
            0xd000: 0x0,
            0xe000: 0x1040080,
            0xf000: 0x21000000,
            0x800: 0x1040080,
            0x1800: 0x21000080,
            0x2800: 0x80,
            0x3800: 0x1040000,
            0x4800: 0x40000,
            0x5800: 0x20040080,
            0x6800: 0x21040000,
            0x7800: 0x20000000,
            0x8800: 0x20040000,
            0x9800: 0x0,
            0xa800: 0x21040080,
            0xb800: 0x1000080,
            0xc800: 0x20000080,
            0xd800: 0x21000000,
            0xe800: 0x1000000,
            0xf800: 0x40080,
            0x10000: 0x40000,
            0x11000: 0x80,
            0x12000: 0x20000000,
            0x13000: 0x21000080,
            0x14000: 0x1000080,
            0x15000: 0x21040000,
            0x16000: 0x20040080,
            0x17000: 0x1000000,
            0x18000: 0x21040080,
            0x19000: 0x21000000,
            0x1a000: 0x1040000,
            0x1b000: 0x20040000,
            0x1c000: 0x40080,
            0x1d000: 0x20000080,
            0x1e000: 0x0,
            0x1f000: 0x1040080,
            0x10800: 0x21000080,
            0x11800: 0x1000000,
            0x12800: 0x1040000,
            0x13800: 0x20040080,
            0x14800: 0x20000000,
            0x15800: 0x1040080,
            0x16800: 0x80,
            0x17800: 0x21040000,
            0x18800: 0x40080,
            0x19800: 0x21040080,
            0x1a800: 0x0,
            0x1b800: 0x21000000,
            0x1c800: 0x1000080,
            0x1d800: 0x40000,
            0x1e800: 0x20040000,
            0x1f800: 0x20000080
        },
        {
            0x0: 0x10000008,
            0x100: 0x2000,
            0x200: 0x10200000,
            0x300: 0x10202008,
            0x400: 0x10002000,
            0x500: 0x200000,
            0x600: 0x200008,
            0x700: 0x10000000,
            0x800: 0x0,
            0x900: 0x10002008,
            0xa00: 0x202000,
            0xb00: 0x8,
            0xc00: 0x10200008,
            0xd00: 0x202008,
            0xe00: 0x2008,
            0xf00: 0x10202000,
            0x80: 0x10200000,
            0x180: 0x10202008,
            0x280: 0x8,
            0x380: 0x200000,
            0x480: 0x202008,
            0x580: 0x10000008,
            0x680: 0x10002000,
            0x780: 0x2008,
            0x880: 0x200008,
            0x980: 0x2000,
            0xa80: 0x10002008,
            0xb80: 0x10200008,
            0xc80: 0x0,
            0xd80: 0x10202000,
            0xe80: 0x202000,
            0xf80: 0x10000000,
            0x1000: 0x10002000,
            0x1100: 0x10200008,
            0x1200: 0x10202008,
            0x1300: 0x2008,
            0x1400: 0x200000,
            0x1500: 0x10000000,
            0x1600: 0x10000008,
            0x1700: 0x202000,
            0x1800: 0x202008,
            0x1900: 0x0,
            0x1a00: 0x8,
            0x1b00: 0x10200000,
            0x1c00: 0x2000,
            0x1d00: 0x10002008,
            0x1e00: 0x10202000,
            0x1f00: 0x200008,
            0x1080: 0x8,
            0x1180: 0x202000,
            0x1280: 0x200000,
            0x1380: 0x10000008,
            0x1480: 0x10002000,
            0x1580: 0x2008,
            0x1680: 0x10202008,
            0x1780: 0x10200000,
            0x1880: 0x10202000,
            0x1980: 0x10200008,
            0x1a80: 0x2000,
            0x1b80: 0x202008,
            0x1c80: 0x200008,
            0x1d80: 0x0,
            0x1e80: 0x10000000,
            0x1f80: 0x10002008
        },
        {
            0x0: 0x100000,
            0x10: 0x2000401,
            0x20: 0x400,
            0x30: 0x100401,
            0x40: 0x2100401,
            0x50: 0x0,
            0x60: 0x1,
            0x70: 0x2100001,
            0x80: 0x2000400,
            0x90: 0x100001,
            0xa0: 0x2000001,
            0xb0: 0x2100400,
            0xc0: 0x2100000,
            0xd0: 0x401,
            0xe0: 0x100400,
            0xf0: 0x2000000,
            0x8: 0x2100001,
            0x18: 0x0,
            0x28: 0x2000401,
            0x38: 0x2100400,
            0x48: 0x100000,
            0x58: 0x2000001,
            0x68: 0x2000000,
            0x78: 0x401,
            0x88: 0x100401,
            0x98: 0x2000400,
            0xa8: 0x2100000,
            0xb8: 0x100001,
            0xc8: 0x400,
            0xd8: 0x2100401,
            0xe8: 0x1,
            0xf8: 0x100400,
            0x100: 0x2000000,
            0x110: 0x100000,
            0x120: 0x2000401,
            0x130: 0x2100001,
            0x140: 0x100001,
            0x150: 0x2000400,
            0x160: 0x2100400,
            0x170: 0x100401,
            0x180: 0x401,
            0x190: 0x2100401,
            0x1a0: 0x100400,
            0x1b0: 0x1,
            0x1c0: 0x0,
            0x1d0: 0x2100000,
            0x1e0: 0x2000001,
            0x1f0: 0x400,
            0x108: 0x100400,
            0x118: 0x2000401,
            0x128: 0x2100001,
            0x138: 0x1,
            0x148: 0x2000000,
            0x158: 0x100000,
            0x168: 0x401,
            0x178: 0x2100400,
            0x188: 0x2000001,
            0x198: 0x2100000,
            0x1a8: 0x0,
            0x1b8: 0x2100401,
            0x1c8: 0x100401,
            0x1d8: 0x400,
            0x1e8: 0x2000400,
            0x1f8: 0x100001
        },
        {
            0x0: 0x8000820,
            0x1: 0x20000,
            0x2: 0x8000000,
            0x3: 0x20,
            0x4: 0x20020,
            0x5: 0x8020820,
            0x6: 0x8020800,
            0x7: 0x800,
            0x8: 0x8020000,
            0x9: 0x8000800,
            0xa: 0x20800,
            0xb: 0x8020020,
            0xc: 0x820,
            0xd: 0x0,
            0xe: 0x8000020,
            0xf: 0x20820,
            0x80000000: 0x800,
            0x80000001: 0x8020820,
            0x80000002: 0x8000820,
            0x80000003: 0x8000000,
            0x80000004: 0x8020000,
            0x80000005: 0x20800,
            0x80000006: 0x20820,
            0x80000007: 0x20,
            0x80000008: 0x8000020,
            0x80000009: 0x820,
            0x8000000a: 0x20020,
            0x8000000b: 0x8020800,
            0x8000000c: 0x0,
            0x8000000d: 0x8020020,
            0x8000000e: 0x8000800,
            0x8000000f: 0x20000,
            0x10: 0x20820,
            0x11: 0x8020800,
            0x12: 0x20,
            0x13: 0x800,
            0x14: 0x8000800,
            0x15: 0x8000020,
            0x16: 0x8020020,
            0x17: 0x20000,
            0x18: 0x0,
            0x19: 0x20020,
            0x1a: 0x8020000,
            0x1b: 0x8000820,
            0x1c: 0x8020820,
            0x1d: 0x20800,
            0x1e: 0x820,
            0x1f: 0x8000000,
            0x80000010: 0x20000,
            0x80000011: 0x800,
            0x80000012: 0x8020020,
            0x80000013: 0x20820,
            0x80000014: 0x20,
            0x80000015: 0x8020000,
            0x80000016: 0x8000000,
            0x80000017: 0x8000820,
            0x80000018: 0x8020820,
            0x80000019: 0x8000020,
            0x8000001a: 0x8000800,
            0x8000001b: 0x0,
            0x8000001c: 0x20800,
            0x8000001d: 0x820,
            0x8000001e: 0x20020,
            0x8000001f: 0x8020800
        }
    ];

    // Masks that select the SBOX input
    var SBOX_MASK = [
        0xf8000001, 0x1f800000, 0x01f80000, 0x001f8000,
        0x0001f800, 0x00001f80, 0x000001f8, 0x8000001f
    ];

    /**
     * DES block cipher algorithm.
     */
    var DES = C_algo.DES = BlockCipher.extend({
        _doReset: function () {
            // Shortcuts
            var key = this._key;
            var keyWords = key.words;

            // Select 56 bits according to PC1
            var keyBits = [];
            for (var i = 0; i < 56; i++) {
                var keyBitPos = PC1[i] - 1;
                keyBits[i] = (keyWords[keyBitPos >>> 5] >>> (31 - keyBitPos % 32)) & 1;
            }

            // Assemble 16 subkeys
            var subKeys = this._subKeys = [];
            for (var nSubKey = 0; nSubKey < 16; nSubKey++) {
                // Create subkey
                var subKey = subKeys[nSubKey] = [];

                // Shortcut
                var bitShift = BIT_SHIFTS[nSubKey];

                // Select 48 bits according to PC2
                for (var i = 0; i < 24; i++) {
                    // Select from the left 28 key bits
                    subKey[(i / 6) | 0] |= keyBits[((PC2[i] - 1) + bitShift) % 28] << (31 - i % 6);

                    // Select from the right 28 key bits
                    subKey[4 + ((i / 6) | 0)] |= keyBits[28 + (((PC2[i + 24] - 1) + bitShift) % 28)] << (31 - i % 6);
                }

                // Since each subkey is applied to an expanded 32-bit input,
                // the subkey can be broken into 8 values scaled to 32-bits,
                // which allows the key to be used without expansion
                subKey[0] = (subKey[0] << 1) | (subKey[0] >>> 31);
                for (var i = 1; i < 7; i++) {
                    subKey[i] = subKey[i] >>> ((i - 1) * 4 + 3);
                }
                subKey[7] = (subKey[7] << 5) | (subKey[7] >>> 27);
            }

            // Compute inverse subkeys
            var invSubKeys = this._invSubKeys = [];
            for (var i = 0; i < 16; i++) {
                invSubKeys[i] = subKeys[15 - i];
            }
        },

        encryptBlock: function (M, offset) {
            this._doCryptBlock(M, offset, this._subKeys);
        },

        decryptBlock: function (M, offset) {
            this._doCryptBlock(M, offset, this._invSubKeys);
        },

        _doCryptBlock: function (M, offset, subKeys) {
            // Get input
            this._lBlock = M[offset];
            this._rBlock = M[offset + 1];

            // Initial permutation
            exchangeLR.call(this, 4,  0x0f0f0f0f);
            exchangeLR.call(this, 16, 0x0000ffff);
            exchangeRL.call(this, 2,  0x33333333);
            exchangeRL.call(this, 8,  0x00ff00ff);
            exchangeLR.call(this, 1,  0x55555555);

            // Rounds
            for (var round = 0; round < 16; round++) {
                // Shortcuts
                var subKey = subKeys[round];
                var lBlock = this._lBlock;
                var rBlock = this._rBlock;

                // Feistel function
                var f = 0;
                for (var i = 0; i < 8; i++) {
                    f |= SBOX_P[i][((rBlock ^ subKey[i]) & SBOX_MASK[i]) >>> 0];
                }
                this._lBlock = rBlock;
                this._rBlock = lBlock ^ f;
            }

            // Undo swap from last round
            var t = this._lBlock;
            this._lBlock = this._rBlock;
            this._rBlock = t;

            // Final permutation
            exchangeLR.call(this, 1,  0x55555555);
            exchangeRL.call(this, 8,  0x00ff00ff);
            exchangeRL.call(this, 2,  0x33333333);
            exchangeLR.call(this, 16, 0x0000ffff);
            exchangeLR.call(this, 4,  0x0f0f0f0f);

            // Set output
            M[offset] = this._lBlock;
            M[offset + 1] = this._rBlock;
        },

        keySize: 64/32,

        ivSize: 64/32,

        blockSize: 64/32
    });

    // Swap bits across the left and right words
    function exchangeLR(offset, mask) {
        var t = ((this._lBlock >>> offset) ^ this._rBlock) & mask;
        this._rBlock ^= t;
        this._lBlock ^= t << offset;
    }

    function exchangeRL(offset, mask) {
        var t = ((this._rBlock >>> offset) ^ this._lBlock) & mask;
        this._lBlock ^= t;
        this._rBlock ^= t << offset;
    }

    /**
     * Shortcut functions to the cipher's object interface.
     *
     * @example
     *
     *     var ciphertext = CryptoJS.DES.encrypt(message, key, cfg);
     *     var plaintext  = CryptoJS.DES.decrypt(ciphertext, key, cfg);
     */
    C.DES = BlockCipher._createHelper(DES);

    /**
     * Triple-DES block cipher algorithm.
     */
    var TripleDES = C_algo.TripleDES = BlockCipher.extend({
        _doReset: function () {
            // Shortcuts
            var key = this._key;
            var keyWords = key.words;
            // Make sure the key length is valid (64, 128 or >= 192 bit)
            if (keyWords.length !== 2 && keyWords.length !== 4 && keyWords.length < 6) {
                throw new Error('Invalid key length - 3DES requires the key length to be 64, 128, 192 or >192.');
            }

            // Extend the key according to the keying options defined in 3DES standard
            var key1 = keyWords.slice(0, 2);
            var key2 = keyWords.length < 4 ? keyWords.slice(0, 2) : keyWords.slice(2, 4);
            var key3 = keyWords.length < 6 ? keyWords.slice(0, 2) : keyWords.slice(4, 6);

            // Create DES instances
            this._des1 = DES.createEncryptor(WordArray.create(key1));
            this._des2 = DES.createEncryptor(WordArray.create(key2));
            this._des3 = DES.createEncryptor(WordArray.create(key3));
        },

        encryptBlock: function (M, offset) {
            this._des1.encryptBlock(M, offset);
            this._des2.decryptBlock(M, offset);
            this._des3.encryptBlock(M, offset);
        },

        decryptBlock: function (M, offset) {
            this._des3.decryptBlock(M, offset);
            this._des2.encryptBlock(M, offset);
            this._des1.decryptBlock(M, offset);
        },

        keySize: 192/32,

        ivSize: 64/32,

        blockSize: 64/32
    });

    /**
     * Shortcut functions to the cipher's object interface.
     *
     * @example
     *
     *     var ciphertext = CryptoJS.TripleDES.encrypt(message, key, cfg);
     *     var plaintext  = CryptoJS.TripleDES.decrypt(ciphertext, key, cfg);
     */
    C.TripleDES = BlockCipher._createHelper(TripleDES);
}());
(function (undefined) {
    // Shortcuts
    var C = CryptoJS;
    var C_lib = C.lib;
    var Base = C_lib.Base;
    var X32WordArray = C_lib.WordArray;

    /**
     * x64 namespace.
     */
    var C_x64 = C.x64 = {};

    /**
     * A 64-bit word.
     */
    var X64Word = C_x64.Word = Base.extend({
        /**
         * Initializes a newly created 64-bit word.
         *
         * @param {number} high The high 32 bits.
         * @param {number} low The low 32 bits.
         *
         * @example
         *
         *     var x64Word = CryptoJS.x64.Word.create(0x00010203, 0x04050607);
         */
        init: function (high, low) {
            this.high = high;
            this.low = low;
        }

        /**
         * Bitwise NOTs this word.
         *
         * @return {X64Word} A new x64-Word object after negating.
         *
         * @example
         *
         *     var negated = x64Word.not();
         */
        // not: function () {
            // var high = ~this.high;
            // var low = ~this.low;

            // return X64Word.create(high, low);
        // },

        /**
         * Bitwise ANDs this word with the passed word.
         *
         * @param {X64Word} word The x64-Word to AND with this word.
         *
         * @return {X64Word} A new x64-Word object after ANDing.
         *
         * @example
         *
         *     var anded = x64Word.and(anotherX64Word);
         */
        // and: function (word) {
            // var high = this.high & word.high;
            // var low = this.low & word.low;

            // return X64Word.create(high, low);
        // },

        /**
         * Bitwise ORs this word with the passed word.
         *
         * @param {X64Word} word The x64-Word to OR with this word.
         *
         * @return {X64Word} A new x64-Word object after ORing.
         *
         * @example
         *
         *     var ored = x64Word.or(anotherX64Word);
         */
        // or: function (word) {
            // var high = this.high | word.high;
            // var low = this.low | word.low;

            // return X64Word.create(high, low);
        // },

        /**
         * Bitwise XORs this word with the passed word.
         *
         * @param {X64Word} word The x64-Word to XOR with this word.
         *
         * @return {X64Word} A new x64-Word object after XORing.
         *
         * @example
         *
         *     var xored = x64Word.xor(anotherX64Word);
         */
        // xor: function (word) {
            // var high = this.high ^ word.high;
            // var low = this.low ^ word.low;

            // return X64Word.create(high, low);
        // },

        /**
         * Shifts this word n bits to the left.
         *
         * @param {number} n The number of bits to shift.
         *
         * @return {X64Word} A new x64-Word object after shifting.
         *
         * @example
         *
         *     var shifted = x64Word.shiftL(25);
         */
        // shiftL: function (n) {
            // if (n < 32) {
                // var high = (this.high << n) | (this.low >>> (32 - n));
                // var low = this.low << n;
            // } else {
                // var high = this.low << (n - 32);
                // var low = 0;
            // }

            // return X64Word.create(high, low);
        // },

        /**
         * Shifts this word n bits to the right.
         *
         * @param {number} n The number of bits to shift.
         *
         * @return {X64Word} A new x64-Word object after shifting.
         *
         * @example
         *
         *     var shifted = x64Word.shiftR(7);
         */
        // shiftR: function (n) {
            // if (n < 32) {
                // var low = (this.low >>> n) | (this.high << (32 - n));
                // var high = this.high >>> n;
            // } else {
                // var low = this.high >>> (n - 32);
                // var high = 0;
            // }

            // return X64Word.create(high, low);
        // },

        /**
         * Rotates this word n bits to the left.
         *
         * @param {number} n The number of bits to rotate.
         *
         * @return {X64Word} A new x64-Word object after rotating.
         *
         * @example
         *
         *     var rotated = x64Word.rotL(25);
         */
        // rotL: function (n) {
            // return this.shiftL(n).or(this.shiftR(64 - n));
        // },

        /**
         * Rotates this word n bits to the right.
         *
         * @param {number} n The number of bits to rotate.
         *
         * @return {X64Word} A new x64-Word object after rotating.
         *
         * @example
         *
         *     var rotated = x64Word.rotR(7);
         */
        // rotR: function (n) {
            // return this.shiftR(n).or(this.shiftL(64 - n));
        // },

        /**
         * Adds this word with the passed word.
         *
         * @param {X64Word} word The x64-Word to add with this word.
         *
         * @return {X64Word} A new x64-Word object after adding.
         *
         * @example
         *
         *     var added = x64Word.add(anotherX64Word);
         */
        // add: function (word) {
            // var low = (this.low + word.low) | 0;
            // var carry = (low >>> 0) < (this.low >>> 0) ? 1 : 0;
            // var high = (this.high + word.high + carry) | 0;

            // return X64Word.create(high, low);
        // }
    });

    /**
     * An array of 64-bit words.
     *
     * @property {Array} words The array of CryptoJS.x64.Word objects.
     * @property {number} sigBytes The number of significant bytes in this word array.
     */
    var X64WordArray = C_x64.WordArray = Base.extend({
        /**
         * Initializes a newly created word array.
         *
         * @param {Array} words (Optional) An array of CryptoJS.x64.Word objects.
         * @param {number} sigBytes (Optional) The number of significant bytes in the words.
         *
         * @example
         *
         *     var wordArray = CryptoJS.x64.WordArray.create();
         *
         *     var wordArray = CryptoJS.x64.WordArray.create([
         *         CryptoJS.x64.Word.create(0x00010203, 0x04050607),
         *         CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f)
         *     ]);
         *
         *     var wordArray = CryptoJS.x64.WordArray.create([
         *         CryptoJS.x64.Word.create(0x00010203, 0x04050607),
         *         CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f)
         *     ], 10);
         */
        init: function (words, sigBytes) {
            words = this.words = words || [];

            if (sigBytes != undefined) {
                this.sigBytes = sigBytes;
            } else {
                this.sigBytes = words.length * 8;
            }
        },

        /**
         * Converts this 64-bit word array to a 32-bit word array.
         *
         * @return {CryptoJS.lib.WordArray} This word array's data as a 32-bit word array.
         *
         * @example
         *
         *     var x32WordArray = x64WordArray.toX32();
         */
        toX32: function () {
            // Shortcuts
            var x64Words = this.words;
            var x64WordsLength = x64Words.length;

            // Convert
            var x32Words = [];
            for (var i = 0; i < x64WordsLength; i++) {
                var x64Word = x64Words[i];
                x32Words.push(x64Word.high);
                x32Words.push(x64Word.low);
            }

            return X32WordArray.create(x32Words, this.sigBytes);
        },

        /**
         * Creates a copy of this word array.
         *
         * @return {X64WordArray} The clone.
         *
         * @example
         *
         *     var clone = x64WordArray.clone();
         */
        clone: function () {
            var clone = Base.clone.call(this);

            // Clone "words" array
            var words = clone.words = this.words.slice(0);

            // Clone each X64Word object
            var wordsLength = words.length;
            for (var i = 0; i < wordsLength; i++) {
                words[i] = words[i].clone();
            }

            return clone;
        }
    });
}());
YUI.add('algo-aes-profile', function (Y) {
    var C = CryptoJS;

    Y.Profiler.add({
        name: 'AES',

        setUp: function () {
            this.data = {
                key: C.enc.Hex.parse('000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f'),
                iv: C.enc.Hex.parse('000102030405060708090a0b0c0d0e0f')
            };
        },

        profileSinglePartMessage: function () {
            var singlePartMessage = '';
            for (var i = 0; i < 500; i++) {
                singlePartMessage += '12345678901234567890123456789012345678901234567890';
            }

            C.algo.AES.createEncryptor(this.data.key, { iv: this.data.iv }).finalize(singlePartMessage) + '';
        },

        profileMultiPartMessage: function () {
            var aes = C.algo.AES.createEncryptor(this.data.key, { iv: this.data.iv });
            for (var i = 0; i < 500; i++) {
                aes.process('12345678901234567890123456789012345678901234567890') + '';
            }
            aes.finalize() + '';
        }
    });
}, '$Rev$');
YUI.add('algo-aes-test', function (Y) {
    var C = CryptoJS;

    Y.Test.Runner.add(new Y.Test.Case({
        name: 'AES',

        testEncryptKeySize128: function () {
            Y.Assert.areEqual('69c4e0d86a7b0430d8cdb78070b4c55a', C.AES.encrypt(C.enc.Hex.parse('00112233445566778899aabbccddeeff'), C.enc.Hex.parse('000102030405060708090a0b0c0d0e0f'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).ciphertext.toString());
        },

        testEncryptKeySize192: function () {
            Y.Assert.areEqual('dda97ca4864cdfe06eaf70a0ec0d7191', C.AES.encrypt(C.enc.Hex.parse('00112233445566778899aabbccddeeff'), C.enc.Hex.parse('000102030405060708090a0b0c0d0e0f1011121314151617'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).ciphertext.toString());
        },

        testEncryptKeySize256: function () {
            Y.Assert.areEqual('8ea2b7ca516745bfeafc49904b496089', C.AES.encrypt(C.enc.Hex.parse('00112233445566778899aabbccddeeff'), C.enc.Hex.parse('000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).ciphertext.toString());
        },

        testDecryptKeySize128: function () {
            Y.Assert.areEqual('00112233445566778899aabbccddeeff', C.AES.decrypt(C.lib.CipherParams.create({ ciphertext: C.enc.Hex.parse('69c4e0d86a7b0430d8cdb78070b4c55a') }), C.enc.Hex.parse('000102030405060708090a0b0c0d0e0f'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString());
        },

        testDecryptKeySize192: function () {
            Y.Assert.areEqual('00112233445566778899aabbccddeeff', C.AES.decrypt(C.lib.CipherParams.create({ ciphertext: C.enc.Hex.parse('dda97ca4864cdfe06eaf70a0ec0d7191') }), C.enc.Hex.parse('000102030405060708090a0b0c0d0e0f1011121314151617'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString());
        },

        testDecryptKeySize256: function () {
            Y.Assert.areEqual('00112233445566778899aabbccddeeff', C.AES.decrypt(C.lib.CipherParams.create({ ciphertext: C.enc.Hex.parse('8ea2b7ca516745bfeafc49904b496089') }), C.enc.Hex.parse('000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString());
        },

        testMultiPart: function () {
            var aes = C.algo.AES.createEncryptor(C.enc.Hex.parse('000102030405060708090a0b0c0d0e0f'), { mode: C.mode.ECB, padding: C.pad.NoPadding });
            var ciphertext1 = aes.process(C.enc.Hex.parse('001122334455'));
            var ciphertext2 = aes.process(C.enc.Hex.parse('66778899aa'));
            var ciphertext3 = aes.process(C.enc.Hex.parse('bbccddeeff'));
            var ciphertext4 = aes.finalize();

            Y.Assert.areEqual('69c4e0d86a7b0430d8cdb78070b4c55a', ciphertext1.concat(ciphertext2).concat(ciphertext3).concat(ciphertext4).toString());
        },

        testInputIntegrity: function () {
            var message = C.enc.Hex.parse('00112233445566778899aabbccddeeff');
            var key = C.enc.Hex.parse('000102030405060708090a0b0c0d0e0f');
            var iv = C.enc.Hex.parse('101112131415161718191a1b1c1d1e1f');

            var expectedMessage = message.toString();
            var expectedKey = key.toString();
            var expectedIv = iv.toString();

            C.AES.encrypt(message, key, { iv: iv });

            Y.Assert.areEqual(expectedMessage, message.toString());
            Y.Assert.areEqual(expectedKey, key.toString());
            Y.Assert.areEqual(expectedIv, iv.toString());
        },

        testHelper: function () {
            // Save original random method
            var random = C.lib.WordArray.random;

            // Replace random method with one that returns a predictable value
            C.lib.WordArray.random = function (nBytes) {
                var words = [];
                for (var i = 0; i < nBytes; i += 4) {
                    words.push([0x11223344]);
                }

                return C.lib.WordArray.create(words, nBytes);
            };

            // Test
            Y.Assert.areEqual(C.algo.AES.createEncryptor(C.SHA256('Jefe'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).finalize('Hi There').toString(), C.AES.encrypt('Hi There', C.SHA256('Jefe'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).ciphertext.toString());
            Y.Assert.areEqual(C.lib.SerializableCipher.encrypt(C.algo.AES, 'Hi There', C.SHA256('Jefe'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString(), C.AES.encrypt('Hi There', C.SHA256('Jefe'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString());
            Y.Assert.areEqual(C.lib.PasswordBasedCipher.encrypt(C.algo.AES, 'Hi There', 'Jefe', { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString(), C.AES.encrypt('Hi There', 'Jefe', { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString());

            // Restore random method
            C.lib.WordArray.random = random;
        }
    }));
}, '$Rev$');
YUI.add('algo-aes-test', function (Y) {
    var C = CryptoJS;

    Y.Test.Runner.add(new Y.Test.Case({
        name: 'Blowfish',

        setUp: function () {
            this.data = {
                saltA: CryptoJS.enc.Hex.parse('AA00000000000000')
            };
        },

        testEncrypt: function () {
            let encryptedA = C.Blowfish.encrypt('Test',
            'pass',
            {
                salt: this.data.saltA,
                hasher: CryptoJS.algo.SHA256
            }).toString();
            Y.Assert.areEqual('U2FsdGVkX1+qAAAAAAAAAKTIU8MPrBdH', encryptedA);
        },

        testDecrypt: function () {
            let encryptedA = C.Blowfish.encrypt('Test',
            'pass',
            {
                salt: this.data.saltA,
                hasher: CryptoJS.algo.SHA256
            }).toString();
            Y.Assert.areEqual('Test', C.Blowfish.decrypt(encryptedA, 'pass', {hasher: CryptoJS.algo.SHA256}).toString(C.enc.Utf8));
        }
    }));
}, '$Rev$');
function extendWithCMAC(C) {
    function createExt(C) {
        /*
         * The MIT License (MIT)
         *
         * Copyright (c) 2015 artjomb
         */
        // put on ext property in CryptoJS
        var ext;
        if (!C.hasOwnProperty("ext")) {
            ext = C.ext = {};
        } else {
            ext = C.ext;
        }

        // Shortcuts
        var Base = C.lib.Base;
        var WordArray = C.lib.WordArray;

        // Constants
        ext.const_Zero = new WordArray.init([0x00000000, 0x00000000, 0x00000000, 0x00000000]);
        ext.const_One = new WordArray.init([0x00000000, 0x00000000, 0x00000000, 0x00000001]);
        ext.const_Rb = new WordArray.init([0x00000000, 0x00000000, 0x00000000, 0x00000087]); // 00..0010000111
        ext.const_Rb_Shifted = new WordArray.init([0x80000000, 0x00000000, 0x00000000, 0x00000043]); // 100..001000011
        ext.const_nonMSB = new WordArray.init([0xFFFFFFFF, 0xFFFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF]); // 1^64 || 0^1 || 1^31 || 0^1 || 1^31

        /**
         * Looks into the object to see if it is a WordArray.
         *
         * @param obj Some object
         *
         * @returns {boolean}
         */
        ext.isWordArray = function(obj) {
            return obj && typeof obj.clamp === "function" && typeof obj.concat === "function" && typeof obj.words === "array";
        }

        /**
         * This padding is a 1 bit followed by as many 0 bits as needed to fill
         * up the block. This implementation doesn't work on bits directly,
         * but on bytes. Therefore the granularity is much bigger.
         */
        C.pad.OneZeroPadding = {
            pad: function (data, blocksize) {
                // Shortcut
                var blockSizeBytes = blocksize * 4;

                // Count padding bytes
                var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes;

                // Create padding
                var paddingWords = [];
                for (var i = 0; i < nPaddingBytes; i += 4) {
                    var paddingWord = 0x00000000;
                    if (i === 0) {
                        paddingWord = 0x80000000;
                    }
                    paddingWords.push(paddingWord);
                }
                var padding = new WordArray.init(paddingWords, nPaddingBytes);

                // Add padding
                data.concat(padding);
            },
            unpad: function () {
                // TODO: implement
            }
        };

        /**
         * No padding is applied. This is necessary for streaming cipher modes
         * like CTR.
         */
        C.pad.NoPadding = {
            pad: function () {},
            unpad: function () {}
        };

        /**
         * Returns the n leftmost bytes of the WordArray.
         *
         * @param {WordArray} wordArray WordArray to work on
         * @param {int} n Bytes to retrieve
         *
         * @returns new WordArray
         */
        ext.leftmostBytes = function(wordArray, n){
            var lmArray = wordArray.clone();
            lmArray.sigBytes = n;
            lmArray.clamp();
            return lmArray;
        };

        /**
         * Returns the n rightmost bytes of the WordArray.
         *
         * @param {WordArray} wordArray WordArray to work on
         * @param {int} n Bytes to retrieve (must be positive)
         *
         * @returns new WordArray
         */
        ext.rightmostBytes = function(wordArray, n){
            wordArray.clamp();
            var wordSize = 32;
            var rmArray = wordArray.clone();
            var bitsToShift = (rmArray.sigBytes - n) * 8;
            if (bitsToShift >= wordSize) {
                var popCount = Math.floor(bitsToShift/wordSize);
                bitsToShift -= popCount * wordSize;
                rmArray.words.splice(0, popCount);
                rmArray.sigBytes -= popCount * wordSize / 8;
            }
            if (bitsToShift > 0) {
                ext.bitshift(rmArray, bitsToShift);
                rmArray.sigBytes -= bitsToShift / 8;
            }
            return rmArray;
        };

        /**
         * Returns the n rightmost words of the WordArray. It assumes
         * that the current WordArray has at least n words.
         *
         * @param {WordArray} wordArray WordArray to work on
         * @param {int} n Words to retrieve (must be positive)
         *
         * @returns popped words as new WordArray
         */
        ext.popWords = function(wordArray, n){
            var left = wordArray.words.splice(0, n);
            wordArray.sigBytes -= n * 4;
            return new WordArray.init(left);
        };

        /**
         * Shifts the array to the left and returns the shifted dropped elements
         * as WordArray. The initial WordArray must contain at least n bytes and
         * they have to be significant.
         *
         * @param {WordArray} wordArray WordArray to work on (is modified)
         * @param {int} n Bytes to shift (must be positive, default 16)
         *
         * @returns new WordArray
         */
        ext.shiftBytes = function(wordArray, n){
            n = n || 16;
            var r = n % 4;
            n -= r;

            var shiftedArray = new WordArray.init();
            for(var i = 0; i < n; i += 4) {
                shiftedArray.words.push(wordArray.words.shift());
                wordArray.sigBytes -= 4;
                shiftedArray.sigBytes += 4;
            }
            if (r > 0) {
                shiftedArray.words.push(wordArray.words[0]);
                shiftedArray.sigBytes += r;

                ext.bitshift(wordArray, r * 8);
                wordArray.sigBytes -= r;
            }
            return shiftedArray;
        };

        /**
         * XORs arr2 to the end of arr1 array. This doesn't modify the current
         * array aside from clamping.
         *
         * @param {WordArray} arr1 Bigger array
         * @param {WordArray} arr2 Smaller array to be XORed to the end
         *
         * @returns new WordArray
         */
        ext.xorendBytes = function(arr1, arr2){
            // TODO: more efficient
            return ext.leftmostBytes(arr1, arr1.sigBytes-arr2.sigBytes)
                    .concat(ext.xor(ext.rightmostBytes(arr1, arr2.sigBytes), arr2));
        };

        /**
         * Doubling operation on a 128-bit value. This operation modifies the
         * passed array.
         *
         * @param {WordArray} wordArray WordArray to work on
         *
         * @returns passed WordArray
         */
        ext.dbl = function(wordArray){
            var carry = ext.msb(wordArray);
            ext.bitshift(wordArray, 1);
            ext.xor(wordArray, carry === 1 ? ext.const_Rb : ext.const_Zero);
            return wordArray;
        };

        /**
         * Inverse operation on a 128-bit value. This operation modifies the
         * passed array.
         *
         * @param {WordArray} wordArray WordArray to work on
         *
         * @returns passed WordArray
         */
        ext.inv = function(wordArray){
            var carry = wordArray.words[4] & 1;
            ext.bitshift(wordArray, -1);
            ext.xor(wordArray, carry === 1 ? ext.const_Rb_Shifted : ext.const_Zero);
            return wordArray;
        };

        /**
         * Check whether the word arrays are equal.
         *
         * @param {WordArray} arr1 Array 1
         * @param {WordArray} arr2 Array 2
         *
         * @returns boolean
         */
        ext.equals = function(arr1, arr2){
            if (!arr2 || !arr2.words || arr1.sigBytes !== arr2.sigBytes) {
                return false;
            }
            arr1.clamp();
            arr2.clamp();
            var equal = 0;
            for(var i = 0; i < arr1.words.length; i++) {
                equal |= arr1.words[i] ^ arr2.words[i];
            }
            return equal === 0;
        };

        /**
         * Retrieves the most significant bit of the WordArray as an Integer.
         *
         * @param {WordArray} arr
         *
         * @returns Integer
         */
        ext.msb = function(arr) {
            return arr.words[0] >>> 31;
        }
    }

    function createExtBit(C) {
        /*
         * The MIT License (MIT)
         *
         * Copyright (c) 2015 artjomb
         */
        // put on ext property in CryptoJS
        var ext;
        if (!C.hasOwnProperty("ext")) {
            ext = C.ext = {};
        } else {
            ext = C.ext;
        }

        /**
         * Shifts the array by n bits to the left. Zero bits are added as the
         * least significant bits. This operation modifies the current array.
         *
         * @param {WordArray} wordArray WordArray to work on
         * @param {int} n Bits to shift by
         *
         * @returns the WordArray that was passed in
         */
        ext.bitshift = function(wordArray, n){
            var carry = 0,
                words = wordArray.words,
                wres,
                skipped = 0,
                carryMask;
            if (n > 0) {
                while(n > 31) {
                    // delete first element:
                    words.splice(0, 1);

                    // add `0` word to the back
                    words.push(0);

                    n -= 32;
                    skipped++;
                }
                if (n == 0) {
                    // 1. nothing to shift if the shift amount is on a word boundary
                    // 2. This has to be done, because the following algorithm computes
                    // wrong values only for n==0
                    return carry;
                }
                for(var i = words.length - skipped - 1; i >= 0; i--) {
                    wres = words[i];
                    words[i] <<= n;
                    words[i] |= carry;
                    carry = wres >>> (32 - n);
                }
            } else if (n < 0) {
                while(n < -31) {
                    // insert `0` word to the front:
                    words.splice(0, 0, 0);

                    // remove last element:
                    words.length--;

                    n += 32;
                    skipped++;
                }
                if (n == 0) {
                    // nothing to shift if the shift amount is on a word boundary
                    return carry;
                }
                n = -n;
                carryMask = (1 << n) - 1;
                for(var i = skipped; i < words.length; i++) {
                    wres = words[i] & carryMask;
                    words[i] >>>= n;
                    words[i] |= carry;
                    carry = wres << (32 - n);
                }
            }
            return carry;
        };

        /**
         * Negates all bits in the WordArray. This manipulates the given array.
         *
         * @param {WordArray} wordArray WordArray to work on
         *
         * @returns the WordArray that was passed in
         */
        ext.neg = function(wordArray){
            var words = wordArray.words;
            for(var i = 0; i < words.length; i++) {
                words[i] = ~words[i];
            }
            return wordArray;
        };

        /**
         * Applies XOR on both given word arrays and returns a third resulting
         * WordArray. The initial word arrays must have the same length
         * (significant bytes).
         *
         * @param {WordArray} wordArray1 WordArray
         * @param {WordArray} wordArray2 WordArray
         *
         * @returns first passed WordArray (modified)
         */
        ext.xor = function(wordArray1, wordArray2){
            for(var i = 0; i < wordArray1.words.length; i++) {
                wordArray1.words[i] ^= wordArray2.words[i];
            }
            return wordArray1;
        };

        /**
         * Logical AND between the two passed arrays. Both arrays must have the
         * same length.
         *
         * @param {WordArray} arr1 Array 1
         * @param {WordArray} arr2 Array 2
         *
         * @returns new WordArray
         */
        ext.bitand = function(arr1, arr2){
            var newArr = arr1.clone(),
                tw = newArr.words,
                ow = arr2.words;
            for(var i = 0; i < tw.length; i++) {
                tw[i] &= ow[i];
            }
            return newArr;
        };
    }

    function createCMAC(C) {
        /*
         * The MIT License (MIT)
         *
         * Copyright (c) 2015 artjomb
         */
        // Shortcuts
        var Base = C.lib.Base;
        var WordArray = C.lib.WordArray;
        var AES = C.algo.AES;
        var ext = C.ext;
        var OneZeroPadding = C.pad.OneZeroPadding;

        var CMAC = C.algo.CMAC = Base.extend({
            /**
             * Initializes a newly created CMAC
             *
             * @param {WordArray} key The secret key
             *
             * @example
             *
             *     var cmacer = CryptoJS.algo.CMAC.create(key);
             */
            init: function(key){
                // generate sub keys...
                this._aes = AES.createEncryptor(key, { iv: new WordArray.init(), padding: C.pad.NoPadding });

                // Step 1
                var L = this._aes.finalize(ext.const_Zero);

                // Step 2
                var K1 = L.clone();
                ext.dbl(K1);

                // Step 3
                if (!this._isTwo) {
                    var K2 = K1.clone();
                    ext.dbl(K2);
                } else {
                    var K2 = L.clone();
                    ext.inv(K2);
                }

                this._K1 = K1;
                this._K2 = K2;

                this._const_Bsize = 16;

                this.reset();
            },

            reset: function () {
                this._x = ext.const_Zero.clone();
                this._counter = 0;
                this._buffer = new WordArray.init();
            },

            update: function (messageUpdate) {
                if (!messageUpdate) {
                    return this;
                }

                // Shortcuts
                var buffer = this._buffer;
                var bsize = this._const_Bsize;

                if (typeof messageUpdate === "string") {
                    messageUpdate = C.enc.Utf8.parse(messageUpdate);
                }

                buffer.concat(messageUpdate);

                while(buffer.sigBytes > bsize){
                    var M_i = ext.shiftBytes(buffer, bsize);
                    ext.xor(this._x, M_i);
                    this._x.clamp();
                    this._aes.reset();
                    this._x = this._aes.finalize(this._x);
                    this._counter++;
                }

                // Chainable
                return this;
            },

            finalize: function (messageUpdate) {
                this.update(messageUpdate);

                // Shortcuts
                var buffer = this._buffer;
                var bsize = this._const_Bsize;

                var M_last = buffer.clone();
                if (buffer.sigBytes === bsize) {
                    ext.xor(M_last, this._K1);
                } else {
                    OneZeroPadding.pad(M_last, bsize/4);
                    ext.xor(M_last, this._K2);
                }

                ext.xor(M_last, this._x);

                this.reset(); // Can be used immediately afterwards

                this._aes.reset();
                return this._aes.finalize(M_last);
            },

            _isTwo: false
        });

        /**
         * Directly invokes the CMAC and returns the calculated MAC.
         *
         * @param {WordArray} key The key to be used for CMAC
         * @param {WordArray|string} message The data to be MAC'ed (either WordArray or UTF-8 encoded string)
         *
         * @returns {WordArray} MAC
         */
        C.CMAC = function(key, message){
            return CMAC.create(key).finalize(message);
        };

        C.algo.OMAC1 = CMAC;
        C.algo.OMAC2 = CMAC.extend({
            _isTwo: true
        });
    }

    createExt(C);
    createExtBit(C);
    createCMAC(C);
}

YUI.add('cipher-core-test', function (Y) {
    var C = CryptoJS;

    // Extend with CMAC to test `cipher-core.js` L:457-462
    extendWithCMAC(C);

    Y.Test.Runner.add(new Y.Test.Case({
        name: 'Cipher',

        testCMAC: function () {
            Y.Assert.areEqual('35e1872b95ce5d99bb5dbbbbd79b9b9b', C.CMAC('69c4e0d86a7b0430d8cdb78070b4c55a', 'Test message').toString());
        }
    }));
}, '$Rev$');
YUI.add('config-test', function (Y) {
    var C = CryptoJS;

    Y.Test.Runner.add(new Y.Test.Case({
        name: 'Config',

        setUp: function () {
            this.data = {
                saltA: CryptoJS.enc.Hex.parse('AA00000000000000'),
                saltB: CryptoJS.enc.Hex.parse('BB00000000000000')
            };
        },

        testEncrypt: function () {
            Y.Assert.areEqual(C.AES.encrypt('Test', 'Pass', { salt: this.data.saltA }).toString(), C.AES.encrypt('Test', 'Pass', { salt: this.data.saltA }).toString());
            Y.Assert.areNotEqual(C.AES.encrypt('Test', 'Pass', { salt: this.data.saltA }).toString(), C.AES.encrypt('Test', 'Pass', { salt: this.data.saltB }).toString());
        },

        testDecrypt: function () {
            var encryptedA = C.AES.encrypt('Test', 'Pass', { salt: this.data.saltA });
            var encryptedB = C.AES.encrypt('Test', 'Pass', { salt: this.data.saltB });
            Y.Assert.areEqual('Test', C.AES.decrypt(encryptedA, 'Pass').toString(C.enc.Utf8));
            Y.Assert.areEqual('Test', C.AES.decrypt(encryptedB, 'Pass').toString(C.enc.Utf8));
        },

        testCustomKDFHasher: function () {
            //SHA1
            let encryptedSHA1 = C.AES.encrypt('Test', 'Pass', { salt: this.data.saltA, hasher: C.algo.SHA1}).toString();
            Y.Assert.areEqual('Test', C.AES.decrypt(encryptedSHA1, 'Pass', { hasher: C.algo.SHA1}).toString(C.enc.Utf8));

            //SHA256
            let encryptedSHA256 = C.AES.encrypt('Test', 'Pass', { salt: this.data.saltA, hasher: C.algo.SHA256}).toString();
            Y.Assert.areEqual('Test', C.AES.decrypt(encryptedSHA256, 'Pass', { hasher: C.algo.SHA256}).toString(C.enc.Utf8));

            //SHA512
            let encryptedSHA512 = C.AES.encrypt('Test', 'Pass', { salt: this.data.saltA, hasher: C.algo.SHA512}).toString();
            Y.Assert.areEqual('Test', C.AES.decrypt(encryptedSHA512, 'Pass', { hasher: C.algo.SHA512}).toString(C.enc.Utf8));

            //Default: MD5
            let encryptedDefault = C.AES.encrypt('Test', 'Pass', { salt: this.data.saltA }).toString();
            let encryptedMD5 = C.AES.encrypt('Test', 'Pass', { salt: this.data.saltA, hasher: C.algo.MD5}).toString();
            Y.Assert.areEqual('Test', C.AES.decrypt(encryptedMD5, 'Pass', { hasher: C.algo.MD5}).toString(C.enc.Utf8));
            Y.Assert.areEqual(encryptedDefault, encryptedMD5);

            //Different KDFHasher
            Y.Assert.areNotEqual(encryptedDefault, encryptedSHA1);
            Y.Assert.areNotEqual(encryptedDefault, encryptedSHA256);
            Y.Assert.areNotEqual(encryptedDefault, encryptedSHA512);
        }
    }));
}, '$Rev$');
YUI.add('algo-des-profile', function (Y) {
    var C = CryptoJS;

    Y.Profiler.add({
        name: 'DES',

        setUp: function () {
            this.data = {
                key: C.enc.Hex.parse('0001020304050607'),
                iv: C.enc.Hex.parse('08090a0b0c0d0e0f')
            };
        },

        profileSinglePartMessage: function () {
            var singlePartMessage = '';
            for (var i = 0; i < 100; i++) {
                singlePartMessage += '12345678901234567890123456789012345678901234567890';
            }

            C.algo.DES.createEncryptor(this.data.key, { iv: this.data.iv }).finalize(singlePartMessage) + '';
        },

        profileMultiPartMessage: function () {
            var des = C.algo.DES.createEncryptor(this.data.key, { iv: this.data.iv });
            for (var i = 0; i < 100; i++) {
                des.process('12345678901234567890123456789012345678901234567890') + '';
            }
            des.finalize() + '';
        }
    });
}, '$Rev$');
YUI.add('algo-des-test', function (Y) {
    var C = CryptoJS;

    Y.Test.Runner.add(new Y.Test.Case({
        name: 'DES',

        testEncrypt1: function () {
            Y.Assert.areEqual('95a8d72813daa94d', C.DES.encrypt(C.enc.Hex.parse('0000000000000000'), C.enc.Hex.parse('8000000000000000'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).ciphertext.toString());
        },

        testEncrypt2: function () {
            Y.Assert.areEqual('1de5279dae3bed6f', C.DES.encrypt(C.enc.Hex.parse('0000000000000000'), C.enc.Hex.parse('0000000000002000'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).ciphertext.toString());
        },

        testEncrypt3: function () {
            Y.Assert.areEqual('1d1ca853ae7c0c5f', C.DES.encrypt(C.enc.Hex.parse('0000000000002000'), C.enc.Hex.parse('0000000000000000'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).ciphertext.toString());
        },

        testEncrypt4: function () {
            Y.Assert.areEqual('ac978c247863388f', C.DES.encrypt(C.enc.Hex.parse('3232323232323232'), C.enc.Hex.parse('3232323232323232'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).ciphertext.toString());
        },

        testEncrypt5: function () {
            Y.Assert.areEqual('3af1703d76442789', C.DES.encrypt(C.enc.Hex.parse('6464646464646464'), C.enc.Hex.parse('6464646464646464'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).ciphertext.toString());
        },

        testEncrypt6: function () {
            Y.Assert.areEqual('a020003c5554f34c', C.DES.encrypt(C.enc.Hex.parse('9696969696969696'), C.enc.Hex.parse('9696969696969696'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).ciphertext.toString());
        },

        testDecrypt1: function () {
            Y.Assert.areEqual('0000000000000000', C.DES.decrypt(C.lib.CipherParams.create({ ciphertext: C.enc.Hex.parse('95a8d72813daa94d') }), C.enc.Hex.parse('8000000000000000'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString());
        },

        testDecrypt2: function () {
            Y.Assert.areEqual('0000000000000000', C.DES.decrypt(C.lib.CipherParams.create({ ciphertext: C.enc.Hex.parse('1de5279dae3bed6f') }), C.enc.Hex.parse('0000000000002000'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString());
        },

        testDecrypt3: function () {
            Y.Assert.areEqual('0000000000002000', C.DES.decrypt(C.lib.CipherParams.create({ ciphertext: C.enc.Hex.parse('1d1ca853ae7c0c5f') }), C.enc.Hex.parse('0000000000000000'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString());
        },

        testDecrypt4: function () {
            Y.Assert.areEqual('3232323232323232', C.DES.decrypt(C.lib.CipherParams.create({ ciphertext: C.enc.Hex.parse('ac978c247863388f') }), C.enc.Hex.parse('3232323232323232'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString());
        },

        testDecrypt5: function () {
            Y.Assert.areEqual('6464646464646464', C.DES.decrypt(C.lib.CipherParams.create({ ciphertext: C.enc.Hex.parse('3af1703d76442789') }), C.enc.Hex.parse('6464646464646464'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString());
        },

        testDecrypt6: function () {
            Y.Assert.areEqual('9696969696969696', C.DES.decrypt(C.lib.CipherParams.create({ ciphertext: C.enc.Hex.parse('a020003c5554f34c') }), C.enc.Hex.parse('9696969696969696'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString());
        },

        testMultiPart: function () {
            var des = C.algo.DES.createEncryptor(C.enc.Hex.parse('0123456789abcdef'), { mode: C.mode.ECB, padding: C.pad.NoPadding });
            var ciphertext1 = des.process(C.enc.Hex.parse('001122334455'));
            var ciphertext2 = des.process(C.enc.Hex.parse('66778899aa'));
            var ciphertext3 = des.process(C.enc.Hex.parse('bbccddeeff'));
            var ciphertext4 = des.finalize();

            Y.Assert.areEqual(C.DES.encrypt(C.enc.Hex.parse('00112233445566778899aabbccddeeff'), C.enc.Hex.parse('0123456789abcdef'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).ciphertext.toString(), ciphertext1.concat(ciphertext2).concat(ciphertext3).concat(ciphertext4).toString());
        },

        testInputIntegrity: function () {
            var message = C.enc.Hex.parse('00112233445566778899aabbccddeeff');
            var key = C.enc.Hex.parse('0001020304050607');
            var iv = C.enc.Hex.parse('08090a0b0c0d0e0f');

            var expectedMessage = message.toString();
            var expectedKey = key.toString();
            var expectedIv = iv.toString();

            C.DES.encrypt(message, key, { iv: iv });

            Y.Assert.areEqual(expectedMessage, message.toString());
            Y.Assert.areEqual(expectedKey, key.toString());
            Y.Assert.areEqual(expectedIv, iv.toString());
        },

        testHelper: function () {
            // Save original random method
            var random = C.lib.WordArray.random;

            // Replace random method with one that returns a predictable value
            C.lib.WordArray.random = function (nBytes) {
                var words = [];
                for (var i = 0; i < nBytes; i += 4) {
                    words.push([0x11223344]);
                }

                return C.lib.WordArray.create(words, nBytes);
            };

            // Test
            Y.Assert.areEqual(C.algo.DES.createEncryptor(C.SHA256('Jefe'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).finalize('Hi There').toString(), C.DES.encrypt('Hi There', C.SHA256('Jefe'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).ciphertext.toString());
            Y.Assert.areEqual(C.lib.SerializableCipher.encrypt(C.algo.DES, 'Hi There', C.SHA256('Jefe'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString(), C.DES.encrypt('Hi There', C.SHA256('Jefe'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString());
            Y.Assert.areEqual(C.lib.PasswordBasedCipher.encrypt(C.algo.DES, 'Hi There', 'Jefe', { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString(), C.DES.encrypt('Hi There', 'Jefe', { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString());

            // Restore random method
            C.lib.WordArray.random = random;
        }
    }));
}, '$Rev$');
YUI.add('enc-base64-test', function (Y) {
    var C = CryptoJS;

    Y.Test.Runner.add(new Y.Test.Case({
        name: 'Base64',

        testStringify0: function () {
            Y.Assert.areEqual('', C.enc.Base64.stringify(C.lib.WordArray.create([0x666f6f62, 0x61720000], 0)));
        },

        testStringify1: function () {
            Y.Assert.areEqual('Zg==', C.enc.Base64.stringify(C.lib.WordArray.create([0x666f6f62, 0x61720000], 1)));
        },

        testStringify2: function () {
            Y.Assert.areEqual('Zm8=', C.enc.Base64.stringify(C.lib.WordArray.create([0x666f6f62, 0x61720000], 2)));
        },

        testStringify3: function () {
            Y.Assert.areEqual('Zm9v', C.enc.Base64.stringify(C.lib.WordArray.create([0x666f6f62, 0x61720000], 3)));
        },

        testStringify4: function () {
            Y.Assert.areEqual('Zm9vYg==', C.enc.Base64.stringify(C.lib.WordArray.create([0x666f6f62, 0x61720000], 4)));
        },

        testStringify5: function () {
            Y.Assert.areEqual('Zm9vYmE=', C.enc.Base64.stringify(C.lib.WordArray.create([0x666f6f62, 0x61720000], 5)));
        },

        testStringify6: function () {
            Y.Assert.areEqual('Zm9vYmFy', C.enc.Base64.stringify(C.lib.WordArray.create([0x666f6f62, 0x61720000], 6)));
        },

        testStringify15: function () {
            Y.Assert.areEqual('Pj4+Pz8/Pj4+Pz8/PS8r', C.enc.Base64.stringify(C.lib.WordArray.create([0x3e3e3e3f, 0x3f3f3e3e, 0x3e3f3f3f, 0x3d2f2b00], 15)));
        },

        testParse0: function () {
            Y.Assert.areEqual(C.lib.WordArray.create([0x666f6f62, 0x61720000], 0).toString(), C.enc.Base64.parse('').toString());
        },

        testParse1: function () {
            Y.Assert.areEqual(C.lib.WordArray.create([0x666f6f62, 0x61720000], 1).toString(), C.enc.Base64.parse('Zg==').toString());
        },

        testParse2: function () {
            Y.Assert.areEqual(C.lib.WordArray.create([0x666f6f62, 0x61720000], 2).toString(), C.enc.Base64.parse('Zm8=').toString());
        },

        testParse3: function () {
            Y.Assert.areEqual(C.lib.WordArray.create([0x666f6f62, 0x61720000], 3).toString(), C.enc.Base64.parse('Zm9v').toString());
        },

        testParse4: function () {
            Y.Assert.areEqual(C.lib.WordArray.create([0x666f6f62, 0x61720000], 4).toString(), C.enc.Base64.parse('Zm9vYg==').toString());
        },

        testParse5: function () {
            Y.Assert.areEqual(C.lib.WordArray.create([0x666f6f62, 0x61720000], 5).toString(), C.enc.Base64.parse('Zm9vYmE=').toString());
        },

        testParse6: function () {
            Y.Assert.areEqual(C.lib.WordArray.create([0x666f6f62, 0x61720000], 6).toString(), C.enc.Base64.parse('Zm9vYmFy').toString());
        },

        testParse15: function () {
            Y.Assert.areEqual(C.lib.WordArray.create([0x3e3e3e3f, 0x3f3f3e3e, 0x3e3f3f3f, 0x3d2f2b00], 15).toString(), C.enc.Base64.parse('Pj4+Pz8/Pj4+Pz8/PS8r').toString());
        }
    }));
}, '$Rev$');
YUI.add('enc-hex-test', function (Y) {
    var C = CryptoJS;

    Y.Test.Runner.add(new Y.Test.Case({
        name: 'Hex',

        testStringify: function () {
            Y.Assert.areEqual('12345678', C.enc.Hex.stringify(C.lib.WordArray.create([0x12345678])));
        },

        testParse: function () {
            Y.Assert.areEqual(C.lib.WordArray.create([0x12345678]).toString(), C.enc.Hex.parse('12345678').toString());
        }
    }));
}, '$Rev$');
YUI.add('enc-latin1-test', function (Y) {
    var C = CryptoJS;

    Y.Test.Runner.add(new Y.Test.Case({
        name: 'Latin1',

        testStringify: function () {
            Y.Assert.areEqual('\x12\x34\x56\x78', C.enc.Latin1.stringify(C.lib.WordArray.create([0x12345678])));
        },

        testParse: function () {
            Y.Assert.areEqual(C.lib.WordArray.create([0x12345678]).toString(), C.enc.Latin1.parse('\x12\x34\x56\x78').toString());
        }
    }));
}, '$Rev$');
YUI.add('enc-utf16-test', function (Y) {
    var C = CryptoJS;

    Y.Test.Runner.add(new Y.Test.Case({
        name: 'Utf16',

        testStringify1: function () {
            Y.Assert.areEqual('z', C.enc.Utf16.stringify(C.lib.WordArray.create([0x007a0000], 2)));
        },

        testStringify2: function () {
            Y.Assert.areEqual('水', C.enc.Utf16.stringify(C.lib.WordArray.create([0x6c340000], 2)));
        },

        testStringify3: function () {
            Y.Assert.areEqual('𐀀', C.enc.Utf16.stringify(C.lib.WordArray.create([0xd800dc00], 4)));
        },

        testStringify4: function () {
            Y.Assert.areEqual('𝄞', C.enc.Utf16.stringify(C.lib.WordArray.create([0xd834dd1e], 4)));
        },

        testStringify5: function () {
            Y.Assert.areEqual('􏿽', C.enc.Utf16.stringify(C.lib.WordArray.create([0xdbffdffd], 4)));
        },

        testStringifyLE: function () {
            Y.Assert.areEqual('􏿽', C.enc.Utf16LE.stringify(C.lib.WordArray.create([0xffdbfddf], 4)));
        },

        testParse1: function () {
            Y.Assert.areEqual(C.lib.WordArray.create([0x007a0000], 2).toString(), C.enc.Utf16.parse('z').toString());
        },

        testParse2: function () {
            Y.Assert.areEqual(C.lib.WordArray.create([0x6c340000], 2).toString(), C.enc.Utf16.parse('水').toString());
        },

        testParse3: function () {
            Y.Assert.areEqual(C.lib.WordArray.create([0xd800dc00], 4).toString(), C.enc.Utf16.parse('𐀀').toString());
        },

        testParse4: function () {
            Y.Assert.areEqual(C.lib.WordArray.create([0xd834dd1e], 4).toString(), C.enc.Utf16.parse('𝄞').toString());
        },

        testParse5: function () {
            Y.Assert.areEqual(C.lib.WordArray.create([0xdbffdffd], 4).toString(), C.enc.Utf16.parse('􏿽').toString());
        },

        testParseLE: function () {
            Y.Assert.areEqual(C.lib.WordArray.create([0xffdbfddf], 4).toString(), C.enc.Utf16LE.parse('􏿽').toString());
        }
    }));
}, '$Rev$');
YUI.add('enc-utf8-test', function (Y) {
    var C = CryptoJS;

    Y.Test.Runner.add(new Y.Test.Case({
        name: 'Utf8',

        testStringify1: function () {
            Y.Assert.areEqual('$', C.enc.Utf8.stringify(C.lib.WordArray.create([0x24000000], 1)));
        },

        testStringify2: function () {
            Y.Assert.areEqual('¢', C.enc.Utf8.stringify(C.lib.WordArray.create([0xc2a20000], 2)));
        },

        testStringify3: function () {
            Y.Assert.areEqual('€', C.enc.Utf8.stringify(C.lib.WordArray.create([0xe282ac00], 3)));
        },

        testStringify4: function () {
            Y.Assert.areEqual('𤭢', C.enc.Utf8.stringify(C.lib.WordArray.create([0xf0a4ada2], 4)));
        },

        testParse1: function () {
            Y.Assert.areEqual(C.lib.WordArray.create([0x24000000], 1).toString(), C.enc.Utf8.parse('$').toString());
        },

        testParse2: function () {
            Y.Assert.areEqual(C.lib.WordArray.create([0xc2a20000], 2).toString(), C.enc.Utf8.parse('¢').toString());
        },

        testParse3: function () {
            Y.Assert.areEqual(C.lib.WordArray.create([0xe282ac00], 3).toString(), C.enc.Utf8.parse('€').toString());
        },

        testParse4: function () {
            Y.Assert.areEqual(C.lib.WordArray.create([0xf0a4ada2], 4).toString(), C.enc.Utf8.parse('𤭢').toString());
        }
    }));
}, '$Rev$');
YUI.add('algo-evpkdf-profile', function (Y) {
    var C = CryptoJS;

    Y.Profiler.add({
        name: 'EvpKDF',

        profileKeySize256Iterations20: function () {
            C.algo.EvpKDF.create({ keySize: 256/32, iterations: 20 }).compute('password', 'ATHENA.MIT.EDUraeburn');
        }
    });
}, '$Rev$');
YUI.add('algo-evpkdf-test', function (Y) {
    var C = CryptoJS;

    Y.Test.Runner.add(new Y.Test.Case({
        name: 'EvpKDF',

        testVector: function () {
            Y.Assert.areEqual('fdbdf3419fff98bdb0241390f62a9db35f4aba29d77566377997314ebfc709f20b5ca7b1081f94b1ac12e3c8ba87d05a', C.EvpKDF('password', 'saltsalt', { keySize: (256+128)/32 }).toString());
        },

        // There are no official test vectors that I could find, and the EVP implementation is short on comments.
        // Need to use the C code to generate more test vectors.
        // The iteration count in particular needs to be tested.

        testInputIntegrity: function () {
            var password = C.lib.WordArray.create([0x12345678]);
            var salt = C.lib.WordArray.create([0x12345678]);

            var expectedPassword = password.toString();
            var expectedSalt = salt.toString();

            C.EvpKDF(password, salt);

            Y.Assert.areEqual(expectedPassword, password.toString());
            Y.Assert.areEqual(expectedSalt, salt.toString());
        },

        testHelper: function () {
            Y.Assert.areEqual(C.algo.EvpKDF.create({ keySize: (256+128)/32 }).compute('password', 'saltsalt').toString(), C.EvpKDF('password', 'saltsalt', { keySize: (256+128)/32 }).toString());
        }
    }));
}, '$Rev$');
YUI.add('format-openssl-test', function (Y) {
    var C = CryptoJS;

    Y.Test.Runner.add(new Y.Test.Case({
        name: 'OpenSSLFormatter',

        setUp: function () {
            this.data = {};

            this.data.ciphertext = C.lib.WordArray.create([0x00010203, 0x04050607, 0x08090a0b, 0x0c0d0e0f]);
            this.data.salt = C.lib.WordArray.create([0x01234567, 0x89abcdef]);
        },

        testSaltedToString: function () {
            Y.Assert.areEqual(C.enc.Latin1.parse('Salted__').concat(this.data.salt).concat(this.data.ciphertext).toString(C.enc.Base64), C.format.OpenSSL.stringify(C.lib.CipherParams.create({ ciphertext: this.data.ciphertext, salt: this.data.salt })));
        },

        testUnsaltedToString: function () {
            Y.Assert.areEqual(this.data.ciphertext.toString(C.enc.Base64), C.format.OpenSSL.stringify(C.lib.CipherParams.create({ ciphertext: this.data.ciphertext })));
        },

        testSaltedFromString: function () {
            var openSSLStr = C.format.OpenSSL.stringify(C.lib.CipherParams.create({ ciphertext: this.data.ciphertext, salt: this.data.salt }));
            var cipherParams = C.format.OpenSSL.parse(openSSLStr);

            Y.Assert.areEqual(this.data.ciphertext.toString(), cipherParams.ciphertext.toString());
            Y.Assert.areEqual(this.data.salt.toString(), cipherParams.salt.toString());
        },

        testUnsaltedFromString: function () {
            var openSSLStr = C.format.OpenSSL.stringify(C.lib.CipherParams.create({ ciphertext: this.data.ciphertext }));
            var cipherParams = C.format.OpenSSL.parse(openSSLStr);

            Y.Assert.areEqual(this.data.ciphertext.toString(), cipherParams.ciphertext.toString());
        }
    }));
}, '$Rev$');
YUI.add('algo-hmac-md5-profile', function (Y) {
    var C = CryptoJS;

    Y.Profiler.add({
        name: 'HMAC MD5',

        setUp: function () {
            this.data = {
                key: C.lib.WordArray.random(128/8)
            };
        },

        profileSinglePartMessage: function () {
            var singlePartMessage = '';
            for (var i = 0; i < 500; i++) {
                singlePartMessage += '12345678901234567890123456789012345678901234567890';
            }

            C.algo.HMAC.create(C.algo.MD5, this.data.key).finalize(singlePartMessage) + '';
        },

        profileMultiPartMessage: function () {
            var hmac = C.algo.HMAC.create(C.algo.MD5, this.data.key);
            for (var i = 0; i < 500; i++) {
                hmac.update('12345678901234567890123456789012345678901234567890');
            }
            hmac.finalize() + '';
        }
    });
}, '$Rev$');
YUI.add('algo-hmac-md5-test', function (Y) {
    var C = CryptoJS;

    Y.Test.Runner.add(new Y.Test.Case({
        name: 'HMAC MD5',

        testVector1: function () {
            Y.Assert.areEqual('9294727a3638bb1c13f48ef8158bfc9d', C.HmacMD5('Hi There', C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).toString());
        },

        testVector2: function () {
            Y.Assert.areEqual('750c783e6ab0b503eaa86e310a5db738', C.HmacMD5('what do ya want for nothing?', 'Jefe').toString());
        },

        testVector3: function () {
            Y.Assert.areEqual('56be34521d144c88dbb8c733f0e8b3f6', C.HmacMD5(C.enc.Hex.parse('dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd'), C.enc.Hex.parse('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')).toString());
        },

        testVector4: function () {
            Y.Assert.areEqual('7ee2a3cc979ab19865704644ce13355c', C.HmacMD5('ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'A').toString());
        },

        testVector5: function () {
            Y.Assert.areEqual('0e1bd89c43e3e6e3b3f8cf1d5ba4f77a', C.HmacMD5('abcdefghijklmnopqrstuvwxyz', 'A').toString());
        },

        testUpdate: function () {
            var hmac = C.algo.HMAC.create(C.algo.MD5, C.enc.Hex.parse('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'));
            hmac.update(C.enc.Hex.parse('dddddddddddddddddddddddddddddddddddd'));
            hmac.update(C.enc.Hex.parse('dddddddddddddddddddddddddddddddd'));
            hmac.update(C.enc.Hex.parse('dddddddddddddddddddddddddddddddd'));

            Y.Assert.areEqual(C.HmacMD5(C.enc.Hex.parse('dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd'), C.enc.Hex.parse('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')).toString(), hmac.finalize().toString());
        },

        testInputIntegrity: function () {
            var message = C.lib.WordArray.create([0x12345678]);
            var key = C.lib.WordArray.create([0x12345678]);

            var expectedMessage = message.toString();
            var expectedKey = key.toString();

            C.HmacMD5(message, key);

            Y.Assert.areEqual(expectedMessage, message.toString());
            Y.Assert.areEqual(expectedKey, key.toString());
        },

        testRespectKeySigBytes: function () {
            var key = C.lib.WordArray.random(8);
            key.sigBytes = 4;

            var keyClamped = key.clone();
            keyClamped.clamp();

            Y.Assert.areEqual(CryptoJS.HmacSHA256("Message", keyClamped).toString(), CryptoJS.HmacSHA256("Message", key).toString());
        }
    }));
}, '$Rev$');
YUI.add('algo-hmac-sha224-test', function (Y) {
    var C = CryptoJS;

    Y.Test.Runner.add(new Y.Test.Case({
        name: 'HMAC SHA224',

        testVector1: function () {
            Y.Assert.areEqual('4e841ce7a4ae83fbcf71e3cd64bfbf277f73a14680aae8c518ac7861', C.HmacSHA224('Hi There', C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).toString());
        },

        testVector2: function () {
            Y.Assert.areEqual('a30e01098bc6dbbf45690f3a7e9e6d0f8bbea2a39e6148008fd05e44', C.HmacSHA224('what do ya want for nothing?', 'Jefe').toString());
        },

        testVector3: function () {
            Y.Assert.areEqual('cbff7c2716bbaa7c77bed4f491d3e8456cb6c574e92f672b291acf5b', C.HmacSHA224(C.enc.Hex.parse('dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd'), C.enc.Hex.parse('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')).toString());
        },

        testVector4: function () {
            Y.Assert.areEqual('61bf669da4fdcd8e5c3bd09ebbb4a986d3d1b298d3ca05c511f7aeff', C.HmacSHA224('ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'A').toString());
        },

        testVector5: function () {
            Y.Assert.areEqual('16fc69ada3c3edc1fe9144d6b98d93393833ae442bedf681110a1176', C.HmacSHA224('abcdefghijklmnopqrstuvwxyz', 'A').toString());
        },

        testUpdate: function () {
            var hmac = C.algo.HMAC.create(C.algo.SHA224, C.enc.Hex.parse('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'));
            hmac.update(C.enc.Hex.parse('dddddddddddddddddddddddddddddddddddd'));
            hmac.update(C.enc.Hex.parse('dddddddddddddddddddddddddddddddd'));
            hmac.update(C.enc.Hex.parse('dddddddddddddddddddddddddddddddd'));

            Y.Assert.areEqual(C.HmacSHA224(C.enc.Hex.parse('dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd'), C.enc.Hex.parse('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')).toString(), hmac.finalize().toString());
        },

        testInputIntegrity: function () {
            var message = C.lib.WordArray.create([0x12345678]);
            var key = C.lib.WordArray.create([0x12345678]);

            var expectedMessage = message.toString();
            var expectedKey = key.toString();

            C.HmacSHA224(message, key);

            Y.Assert.areEqual(expectedMessage, message.toString());
            Y.Assert.areEqual(expectedKey, key.toString());
        },

        testRespectKeySigBytes: function () {
            var key = C.lib.WordArray.random(8);
            key.sigBytes = 4;

            var keyClamped = key.clone();
            keyClamped.clamp();

            Y.Assert.areEqual(CryptoJS.HmacSHA224("Message", keyClamped).toString(), CryptoJS.HmacSHA224("Message", key).toString());
        }
    }));
}, '$Rev$');
YUI.add('algo-hmac-sha256-test', function (Y) {
    var C = CryptoJS;

    Y.Test.Runner.add(new Y.Test.Case({
        name: 'HMAC SHA256',

        testVector1: function () {
            Y.Assert.areEqual('492ce020fe2534a5789dc3848806c78f4f6711397f08e7e7a12ca5a4483c8aa6', C.HmacSHA256('Hi There', C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).toString());
        },

        testVector2: function () {
            Y.Assert.areEqual('5bdcc146bf60754e6a042426089575c75a003f089d2739839dec58b964ec3843', C.HmacSHA256('what do ya want for nothing?', 'Jefe').toString());
        },

        testVector3: function () {
            Y.Assert.areEqual('7dda3cc169743a6484649f94f0eda0f9f2ff496a9733fb796ed5adb40a44c3c1', C.HmacSHA256(C.enc.Hex.parse('dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd'), C.enc.Hex.parse('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')).toString());
        },

        testVector4: function () {
            Y.Assert.areEqual('a89dc8178c1184a62df87adaa77bf86e93064863d93c5131140b0ae98b866687', C.HmacSHA256('ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'A').toString());
        },

        testVector5: function () {
            Y.Assert.areEqual('d8cb78419c02fe20b90f8b77427dd9f81817a751d74c2e484e0ac5fc4e6ca986', C.HmacSHA256('abcdefghijklmnopqrstuvwxyz', 'A').toString());
        },

        testUpdate: function () {
            var hmac = C.algo.HMAC.create(C.algo.SHA256, C.enc.Hex.parse('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'));
            hmac.update(C.enc.Hex.parse('dddddddddddddddddddddddddddddddddddd'));
            hmac.update(C.enc.Hex.parse('dddddddddddddddddddddddddddddddd'));
            hmac.update(C.enc.Hex.parse('dddddddddddddddddddddddddddddddd'));

            Y.Assert.areEqual(C.HmacSHA256(C.enc.Hex.parse('dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd'), C.enc.Hex.parse('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')).toString(), hmac.finalize().toString());
        },

        testInputIntegrity: function () {
            var message = C.lib.WordArray.create([0x12345678]);
            var key = C.lib.WordArray.create([0x12345678]);

            var expectedMessage = message.toString();
            var expectedKey = key.toString();

            C.HmacSHA256(message, key);

            Y.Assert.areEqual(expectedMessage, message.toString());
            Y.Assert.areEqual(expectedKey, key.toString());
        },

        testRespectKeySigBytes: function () {
            var key = C.lib.WordArray.random(8);
            key.sigBytes = 4;

            var keyClamped = key.clone();
            keyClamped.clamp();

            Y.Assert.areEqual(CryptoJS.HmacSHA256("Message", keyClamped).toString(), CryptoJS.HmacSHA256("Message", key).toString());
        }
    }));
}, '$Rev$');
YUI.add('algo-hmac-sha384-test', function (Y) {
    var C = CryptoJS;

    Y.Test.Runner.add(new Y.Test.Case({
        name: 'HMAC SHA384',

        testVector1: function () {
            Y.Assert.areEqual('7afaa633e20d379b02395915fbc385ff8dc27dcd3885e1068ab942eeab52ec1f20ad382a92370d8b2e0ac8b83c4d53bf', C.HmacSHA384('Hi There', C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).toString());
        },

        testVector2: function () {
            Y.Assert.areEqual('af45d2e376484031617f78d2b58a6b1b9c7ef464f5a01b47e42ec3736322445e8e2240ca5e69e2c78b3239ecfab21649', C.HmacSHA384('what do ya want for nothing?', 'Jefe').toString());
        },

        testVector3: function () {
            Y.Assert.areEqual('1383e82e28286b91f4cc7afbd13d5b5c6f887c05e7c4542484043a37a5fe45802a9470fb663bd7b6570fe2f503fc92f5', C.HmacSHA384(C.enc.Hex.parse('dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd'), C.enc.Hex.parse('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')).toString());
        },

        testVector4: function () {
            Y.Assert.areEqual('365dfb271adb8e30fe6c74220b75df1b38c2d19b9d37f2e5a0ec2f3f22bd0406bf5b786e98d81b82c36d3d8a1be6cd07', C.HmacSHA384('ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'A').toString());
        },

        testVector5: function () {
            Y.Assert.areEqual('a8357d5e84da64140e41545562ae0782e2a58e39c6cd98939fad8d9080e774c84b7eaca4ba07f6dbf0f12eab912c5285', C.HmacSHA384('abcdefghijklmnopqrstuvwxyz', 'A').toString());
        },

        testUpdate: function () {
            var hmac = C.algo.HMAC.create(C.algo.SHA384, C.enc.Hex.parse('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'));
            hmac.update(C.enc.Hex.parse('dddddddddddddddddddddddddddddddddddd'));
            hmac.update(C.enc.Hex.parse('dddddddddddddddddddddddddddddddd'));
            hmac.update(C.enc.Hex.parse('dddddddddddddddddddddddddddddddd'));

            Y.Assert.areEqual(C.HmacSHA384(C.enc.Hex.parse('dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd'), C.enc.Hex.parse('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')).toString(), hmac.finalize().toString());
        },

        testInputIntegrity: function () {
            var message = C.lib.WordArray.create([0x12345678]);
            var key = C.lib.WordArray.create([0x12345678]);

            var expectedMessage = message.toString();
            var expectedKey = key.toString();

            C.HmacSHA384(message, key);

            Y.Assert.areEqual(expectedMessage, message.toString());
            Y.Assert.areEqual(expectedKey, key.toString());
        },

        testRespectKeySigBytes: function () {
            var key = C.lib.WordArray.random(8);
            key.sigBytes = 4;

            var keyClamped = key.clone();
            keyClamped.clamp();

            Y.Assert.areEqual(CryptoJS.HmacSHA384("Message", keyClamped).toString(), CryptoJS.HmacSHA384("Message", key).toString());
        }
    }));
}, '$Rev$');
YUI.add('algo-hmac-sha512-test', function (Y) {
    var C = CryptoJS;

    Y.Test.Runner.add(new Y.Test.Case({
        name: 'HMAC SHA512',

        testVector1: function () {
            Y.Assert.areEqual('7641c48a3b4aa8f887c07b3e83f96affb89c978fed8c96fcbbf4ad596eebfe496f9f16da6cd080ba393c6f365ad72b50d15c71bfb1d6b81f66a911786c6ce932', C.HmacSHA512('Hi There', C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).toString());
        },

        testVector2: function () {
            Y.Assert.areEqual('164b7a7bfcf819e2e395fbe73b56e0a387bd64222e831fd610270cd7ea2505549758bf75c05a994a6d034f65f8f0e6fdcaeab1a34d4a6b4b636e070a38bce737', C.HmacSHA512('what do ya want for nothing?', 'Jefe').toString());
        },

        testVector3: function () {
            Y.Assert.areEqual('ad9b5c7de72693737cd5e9d9f41170d18841fec1201c1c1b02e05cae116718009f771cad9946ddbf7e3cde3e818d9ae85d91b2badae94172d096a44a79c91e86', C.HmacSHA512(C.enc.Hex.parse('dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd'), C.enc.Hex.parse('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')).toString());
        },

        testVector4: function () {
            Y.Assert.areEqual('a303979f7c94bb39a8ab6ce05cdbe28f0255da8bb305263e3478ef7e855f0242729bf1d2be55398f14da8e63f0302465a8a3f76c297bd584ad028d18ed7f0195', C.HmacSHA512('ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'A').toString());
        },

        testVector5: function () {
            Y.Assert.areEqual('8c2d56f7628325e62124c0a870ad98d101327fc42696899a06ce0d7121454022fae597e42c25ac3a4c380fd514f553702a5b0afaa9b5a22050902f024368e9d9', C.HmacSHA512('abcdefghijklmnopqrstuvwxyz', 'A').toString());
        },

        testUpdate: function () {
            var hmac = C.algo.HMAC.create(C.algo.SHA512, C.enc.Hex.parse('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'));
            hmac.update(C.enc.Hex.parse('dddddddddddddddddddddddddddddddddddd'));
            hmac.update(C.enc.Hex.parse('dddddddddddddddddddddddddddddddd'));
            hmac.update(C.enc.Hex.parse('dddddddddddddddddddddddddddddddd'));

            Y.Assert.areEqual(C.HmacSHA512(C.enc.Hex.parse('dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd'), C.enc.Hex.parse('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')).toString(), hmac.finalize().toString());
        },

        testInputIntegrity: function () {
            var message = C.lib.WordArray.create([0x12345678]);
            var key = C.lib.WordArray.create([0x12345678]);

            var expectedMessage = message.toString();
            var expectedKey = key.toString();

            C.HmacSHA512(message, key);

            Y.Assert.areEqual(expectedMessage, message.toString());
            Y.Assert.areEqual(expectedKey, key.toString());
        },

        testRespectKeySigBytes: function () {
            var key = C.lib.WordArray.random(8);
            key.sigBytes = 4;

            var keyClamped = key.clone();
            keyClamped.clamp();

            Y.Assert.areEqual(CryptoJS.HmacSHA512("Message", keyClamped).toString(), CryptoJS.HmacSHA512("Message", key).toString());
        }
    }));
}, '$Rev$');
YUI.add('kdf-openssl-test', function (Y) {
    var C = CryptoJS;

    Y.Test.Runner.add(new Y.Test.Case({
        name: 'OpenSSLKdf',

        testVector: function () {
            var derivedParams = C.kdf.OpenSSL.execute('password', 256/32, 128/32, C.enc.Hex.parse('0a9d8620cf7219f1'));

            Y.Assert.areEqual('50f32e0ec9408e02ff42364a52aac95c3694fc027256c6f488bf84b8e60effcd', derivedParams.key.toString());
            Y.Assert.areEqual('81381e39b94fd692dff7e2239a298cb6', derivedParams.iv.toString());
            Y.Assert.areEqual('0a9d8620cf7219f1', derivedParams.salt.toString());
        }
    }));
}, '$Rev$');
YUI.add('lib-base-test', function (Y) {
    var C = CryptoJS;

    Y.Test.Runner.add(new Y.Test.Case({
        name: 'Base',

        setUp: function () {
            this.data = {};

            this.data.overrides = {
                init: function (arg) {
                    this.initFired = true;
                    this.initArg = arg;
                },

                toString: function () {
                }
            };

            this.data.mixins = {
                mixinMethod: function () {
                }
            };

            this.data.Obj = C.lib.Base.extend(this.data.overrides);

            this.data.Obj.mixIn(this.data.mixins);

            this.data.obj = this.data.Obj.create('argValue');

            this.data.objClone = this.data.obj.clone();
        },

        testExtendInheritance: function () {
            Y.Assert.areEqual(C.lib.Base.extend, this.data.Obj.extend);
            Y.Assert.isFalse(this.data.Obj.hasOwnProperty('extend'));
        },

        testExtendSuper: function () {
            Y.Assert.areEqual(C.lib.Base, this.data.Obj.$super);
        },

        testExtendOverrideInit: function () {
            Y.Assert.areEqual(this.data.overrides.init, this.data.Obj.init);
            Y.Assert.isTrue(this.data.Obj.hasOwnProperty('init'));
        },

        testExtendOverrideToString: function () {
            Y.Assert.areEqual(this.data.overrides.toString, this.data.Obj.toString);
            Y.Assert.isTrue(this.data.Obj.hasOwnProperty('toString'));
        },

        testCreateInheritanceFromBase: function () {
            Y.Assert.areEqual(C.lib.Base.extend, this.data.obj.extend);
            Y.Assert.isFalse(this.data.obj.hasOwnProperty('extend'));
        },

        testCreateSuper: function () {
            Y.Assert.areEqual(this.data.Obj, this.data.obj.$super);
        },

        testCreateInit: function () {
            Y.Assert.isTrue(this.data.obj.initFired);
            Y.Assert.areEqual('argValue', this.data.obj.initArg);
        },

        testMixIn: function () {
            Y.Assert.areEqual(this.data.mixins.mixinMethod, this.data.Obj.mixinMethod);
            Y.Assert.isTrue(this.data.Obj.hasOwnProperty('mixinMethod'));
        },

        testCloneDistinct: function () {
            Y.Assert.areNotEqual(this.data.obj, this.data.objClone);
        },

        testCloneCopy: function () {
            Y.Assert.areEqual(this.data.obj.initArg, this.data.objClone.initArg);
        },

        testCloneIndependent: function () {
            this.data.obj.initArg = 'newValue';

            Y.Assert.areNotEqual(this.data.obj.initArg, this.data.objClone.initArg);
        },

        testCloneLeavesOriginalInitPrototypeUnchanged: function() {
            Y.Assert.areEqual(this.data.obj, this.data.obj.init.prototype);
            Y.Assert.areEqual(this.data.objClone, this.data.objClone.init.prototype);
            Y.Assert.areNotEqual(this.data.obj.init.prototype, this.data.objClone.init.prototype);
        }
    }));
}, '$Rev$');
YUI.add('lib-cipherparams-test', function (Y) {
    var C = CryptoJS;

    Y.Test.Runner.add(new Y.Test.Case({
        name: 'CipherParams',

        setUp: function () {
            this.data = {};

            this.data.ciphertext = C.enc.Hex.parse('000102030405060708090a0b0c0d0e0f');
            this.data.key = C.enc.Hex.parse('101112131415161718191a1b1c1d1e1f');
            this.data.iv = C.enc.Hex.parse('202122232425262728292a2b2c2d2e2f');
            this.data.salt = C.enc.Hex.parse('0123456789abcdef');
            this.data.algorithm = C.algo.AES;
            this.data.mode = C.mode.CBC;
            this.data.padding = C.pad.PKCS7;
            this.data.blockSize = this.data.algorithm.blockSize;
            this.data.formatter = C.format.OpenSSL;

            this.data.cipherParams = C.lib.CipherParams.create({
                ciphertext: this.data.ciphertext,
                key: this.data.key,
                iv: this.data.iv,
                salt: this.data.salt,
                algorithm: this.data.algorithm,
                mode: this.data.mode,
                padding: this.data.padding,
                blockSize: this.data.blockSize,
                formatter: this.data.formatter
            });
        },

        testInit: function () {
            Y.Assert.areEqual(this.data.ciphertext, this.data.cipherParams.ciphertext);
            Y.Assert.areEqual(this.data.key, this.data.cipherParams.key);
            Y.Assert.areEqual(this.data.iv, this.data.cipherParams.iv);
            Y.Assert.areEqual(this.data.salt, this.data.cipherParams.salt);
            Y.Assert.areEqual(this.data.algorithm, this.data.cipherParams.algorithm);
            Y.Assert.areEqual(this.data.mode, this.data.cipherParams.mode);
            Y.Assert.areEqual(this.data.padding, this.data.cipherParams.padding);
            Y.Assert.areEqual(this.data.blockSize, this.data.cipherParams.blockSize);
            Y.Assert.areEqual(this.data.formatter, this.data.cipherParams.formatter);
        },

        testToString0: function () {
            Y.Assert.areEqual(C.format.OpenSSL.stringify(this.data.cipherParams), this.data.cipherParams.toString());
        },

        testToString1: function () {
            var JsonFormatter = {
                stringify: function (cipherParams) {
                    return '{ ct: ' + cipherParams.ciphertext + ', iv: ' + cipherParams.iv + ' }';
                }
            };

            Y.Assert.areEqual(JsonFormatter.stringify(this.data.cipherParams), this.data.cipherParams.toString(JsonFormatter));
        }
    }));
}, '$Rev$');
YUI.add('lib-passwordbasedcipher-test', function (Y) {
    var C = CryptoJS;

    Y.Test.Runner.add(new Y.Test.Case({
        name: 'PasswordBasedCipher',

        testEncrypt: function () {
            // Compute actual
            var actual = C.lib.PasswordBasedCipher.encrypt(C.algo.AES, 'Hello, World!', 'password');

            // Compute expected
            var aes = C.algo.AES.createEncryptor(actual.key, { iv: actual.iv });
            var expected = aes.finalize('Hello, World!');

            Y.Assert.areEqual(expected.toString(), actual.ciphertext.toString());
        },

        testDecrypt: function () {
            var ciphertext = C.lib.PasswordBasedCipher.encrypt(C.algo.AES, 'Hello, World!', 'password');
            var plaintext = C.lib.PasswordBasedCipher.decrypt(C.algo.AES, ciphertext, 'password');

            Y.Assert.areEqual('Hello, World!', plaintext.toString(C.enc.Utf8));
        }
    }));
}, '$Rev$');
YUI.add('lib-serializablecipher-test', function (Y) {
    var C = CryptoJS;

    Y.Test.Runner.add(new Y.Test.Case({
        name: 'SerializableCipher',

        setUp: function () {
            this.data = {};

            this.data.message = C.lib.WordArray.create([0x00010203, 0x04050607, 0x08090a0b, 0x0c0d0e0f]);
            this.data.key = C.lib.WordArray.create([0x10111213, 0x14151617, 0x18191a1b, 0x1c1d1e1f]);
            this.data.iv = C.lib.WordArray.create([0x20212223, 0x24252627, 0x28292a2b, 0x2c2d2e2f]);
        },

        testEncrypt: function () {
            // Compute expected
            var aes = C.algo.AES.createEncryptor(this.data.key, { iv: this.data.iv });
            var ciphertext = aes.finalize(this.data.message);
            var expected = C.lib.CipherParams.create({
                ciphertext: ciphertext,
                key: this.data.key,
                iv: this.data.iv,
                algorithm: C.algo.AES,
                mode: aes.cfg.mode,
                padding: aes.cfg.padding,
                blockSize: aes.blockSize,
                formatter: C.format.OpenSSL
            });

            // Compute actual
            var actual = C.lib.SerializableCipher.encrypt(C.algo.AES, this.data.message, this.data.key, { iv: this.data.iv });

            // Test
            Y.Assert.areEqual(expected.toString(), actual.toString());
            Y.Assert.areEqual(expected.ciphertext.toString(), actual.ciphertext.toString());
            Y.Assert.areEqual(expected.key.toString(), actual.key.toString());
            Y.Assert.areEqual(expected.iv.toString(), actual.iv.toString());
            Y.Assert.areEqual(expected.algorithm, actual.algorithm);
            Y.Assert.areEqual(expected.mode, actual.mode);
            Y.Assert.areEqual(expected.padding, actual.padding);
            Y.Assert.areEqual(expected.blockSize, actual.blockSize);
        },

        testDecrypt: function () {
            var encrypted = C.lib.SerializableCipher.encrypt(C.algo.AES, this.data.message, this.data.key, { iv: this.data.iv }) + '';
            var decrypted = C.lib.SerializableCipher.decrypt(C.algo.AES, encrypted, this.data.key, { iv: this.data.iv });

            Y.Assert.areEqual(this.data.message.toString(), decrypted.toString());
        }
    }));
}, '$Rev$');
YUI.add('lib-wordarray-test', function (Y) {
    var C = CryptoJS;

    if (typeof ArrayBuffer != 'undefined') {
        Y.Test.Runner.add(new Y.Test.Case({
            name: 'TypedArrays',

            setUp: function () {
                this.data = {};

                this.data.buffer = new ArrayBuffer(8);

                var uint8View = new Uint8Array(this.data.buffer);
                uint8View[0] = 0x01;
                uint8View[1] = 0x23;
                uint8View[2] = 0x45;
                uint8View[3] = 0x67;
                uint8View[4] = 0x89;
                uint8View[5] = 0xab;
                uint8View[6] = 0xcd;
                uint8View[7] = 0xef;
            },

            testInt8Array: function () {
                Y.Assert.areEqual('0123456789abcdef', C.lib.WordArray.create(new Int8Array(this.data.buffer)).toString());
            },

            testUint8Array: function () {
                Y.Assert.areEqual('0123456789abcdef', C.lib.WordArray.create(new Uint8Array(this.data.buffer)).toString());
            },

            testUint8ClampedArray: function () {
                Y.Assert.areEqual('0123456789abcdef', C.lib.WordArray.create(new Uint8ClampedArray(this.data.buffer)).toString());
            },

            testInt16Array: function () {
                Y.Assert.areEqual('0123456789abcdef', C.lib.WordArray.create(new Int16Array(this.data.buffer)).toString());
            },

            testUint16Array: function () {
                Y.Assert.areEqual('0123456789abcdef', C.lib.WordArray.create(new Uint16Array(this.data.buffer)).toString());
            },

            testInt32Array: function () {
                Y.Assert.areEqual('0123456789abcdef', C.lib.WordArray.create(new Int32Array(this.data.buffer)).toString());
            },

            testUint32Array: function () {
                Y.Assert.areEqual('0123456789abcdef', C.lib.WordArray.create(new Uint32Array(this.data.buffer)).toString());
            },

            testPartialView: function () {
                Y.Assert.areEqual('456789ab', C.lib.WordArray.create(new Int16Array(this.data.buffer, 2, 2)).toString());
            }
        }));
    }
}, '$Rev$');
YUI.add('lib-wordarray-test', function (Y) {
    var C = CryptoJS;

    Y.Test.Runner.add(new Y.Test.Case({
        name: 'WordArray',

        testInit0: function () {
            Y.Assert.areEqual('', C.lib.WordArray.create().toString());
        },

        testInit1: function () {
            Y.Assert.areEqual('12345678', C.lib.WordArray.create([0x12345678]).toString());
        },

        testInit2: function () {
            Y.Assert.areEqual('1234', C.lib.WordArray.create([0x12345678], 2).toString());
        },

        testToStringPassedEncoder: function () {
            Y.Assert.areEqual('\x12\x34\x56\x78', C.lib.WordArray.create([0x12345678]).toString(C.enc.Latin1));
        },

        testToStringDefaultEncoder: function () {
            Y.Assert.areEqual('12345678', C.lib.WordArray.create([0x12345678]).toString());
        },

        testConcat3: function () {
            var wordArray1 = C.lib.WordArray.create([0x12345678], 3);
            var wordArray2 = C.lib.WordArray.create([0x12345678], 3);

            Y.Assert.areEqual('123456123456', wordArray1.concat(wordArray2).toString());
            Y.Assert.areEqual('123456123456', wordArray1.toString());
        },

        testConcat4: function () {
            var wordArray1 = C.lib.WordArray.create([0x12345678], 4);
            var wordArray2 = C.lib.WordArray.create([0x12345678], 3);

            Y.Assert.areEqual('12345678123456', wordArray1.concat(wordArray2).toString());
            Y.Assert.areEqual('12345678123456', wordArray1.toString());
        },

        testConcat5: function () {
            var wordArray1 = C.lib.WordArray.create([0x12345678], 5);
            var wordArray2 = C.lib.WordArray.create([0x12345678], 3);

            Y.Assert.areEqual('1234567800123456', wordArray1.concat(wordArray2).toString());
            Y.Assert.areEqual('1234567800123456', wordArray1.toString());
        },

        testConcatLong: function () {
            var wordArray1 = C.lib.WordArray.create();

            var wordArray2 = C.lib.WordArray.create();
            var wordArray3 = C.lib.WordArray.create();
            for (var i = 0; i < 500000; i++) {
                wordArray2.words[i] = i;
                wordArray3.words[i] = i;
            }
            wordArray2.sigBytes = wordArray3.sigBytes = 500000;

            Y.Assert.areEqual(wordArray2.toString() + wordArray3.toString(), wordArray1.concat(wordArray2.concat(wordArray3)).toString());
        },

        testClamp: function () {
            var wordArray = C.lib.WordArray.create([0x12345678, 0x12345678], 3);
            wordArray.clamp();

            Y.Assert.areEqual([0x12345600].toString(), wordArray.words.toString());
        },

        testClone: function () {
            var wordArray = C.lib.WordArray.create([0x12345678]);
            var clone = wordArray.clone();
            clone.words[0] = 0;

            Y.Assert.areNotEqual(wordArray.toString(), clone.toString());
        },

        testRandom: function () {
            Y.Assert.areNotEqual(C.lib.WordArray.random(8).toString(), C.lib.WordArray.random(8).toString());
            Y.Assert.areEqual(8, C.lib.WordArray.random(8).sigBytes);
        }
    }));
}, '$Rev$');
YUI.add('algo-md5-profile', function (Y) {
    var C = CryptoJS;

    Y.Profiler.add({
        name: 'MD5',

        profileSinglePartMessage: function () {
            var singlePartMessage = '';
            for (var i = 0; i < 500; i++) {
                singlePartMessage += '12345678901234567890123456789012345678901234567890';
            }

            C.algo.MD5.create().finalize(singlePartMessage) + '';
        },

        profileMultiPartMessage: function () {
            var md5 = C.algo.MD5.create();
            for (var i = 0; i < 500; i++) {
                md5.update('12345678901234567890123456789012345678901234567890');
            }
            md5.finalize() + '';
        }
    });
}, '$Rev$');
YUI.add('algo-md5-test', function (Y) {
    var C = CryptoJS;

    Y.Test.Runner.add(new Y.Test.Case({
        name: 'MD5',

        testVector1: function () {
            Y.Assert.areEqual('d41d8cd98f00b204e9800998ecf8427e', C.MD5('').toString());
        },

        testVector2: function () {
            Y.Assert.areEqual('0cc175b9c0f1b6a831c399e269772661', C.MD5('a').toString());
        },

        testVector3: function () {
            Y.Assert.areEqual('900150983cd24fb0d6963f7d28e17f72', C.MD5('abc').toString());
        },

        testVector4: function () {
            Y.Assert.areEqual('f96b697d7cb7938d525a2f31aaf161d0', C.MD5('message digest').toString());
        },

        testVector5: function () {
            Y.Assert.areEqual('c3fcd3d76192e4007dfb496cca67e13b', C.MD5('abcdefghijklmnopqrstuvwxyz').toString());
        },

        testVector6: function () {
            Y.Assert.areEqual('d174ab98d277d9f5a5611c2c9f419d9f', C.MD5('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789').toString());
        },

        testVector7: function () {
            Y.Assert.areEqual('57edf4a22be3c955ac49da2e2107b67a', C.MD5('12345678901234567890123456789012345678901234567890123456789012345678901234567890').toString());
        },

        testUpdateAndLongMessage: function () {
            var md5 = C.algo.MD5.create();
            for (var i = 0; i < 100; i++) {
                md5.update('12345678901234567890123456789012345678901234567890');
            }

            Y.Assert.areEqual('7d017545e0268a6a12f2b507871d0429', md5.finalize().toString());
        },

        testClone: function () {
            var md5 = C.algo.MD5.create();

            Y.Assert.areEqual(C.MD5('a').toString(), md5.update('a').clone().finalize().toString());
            Y.Assert.areEqual(C.MD5('ab').toString(), md5.update('b').clone().finalize().toString());
            Y.Assert.areEqual(C.MD5('abc').toString(), md5.update('c').clone().finalize().toString());
        },

        testInputIntegrity: function () {
            var message = C.lib.WordArray.create([0x12345678]);

            var expected = message.toString();

            C.MD5(message);

            Y.Assert.areEqual(expected, message.toString());
        },

        testHelper: function () {
            Y.Assert.areEqual(C.algo.MD5.create().finalize('').toString(), C.MD5('').toString());
        },

        testHmacHelper: function () {
            Y.Assert.areEqual(C.algo.HMAC.create(C.algo.MD5, C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).finalize('Hi There').toString(), C.HmacMD5('Hi There', C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).toString());
        }
    }));
}, '$Rev$');
YUI.add('mode-cbc-test', function (Y) {
    var C = CryptoJS;

    Y.Test.Runner.add(new Y.Test.Case({
        name: 'CBC',

        setUp: function () {
            this.data = {};

            this.data.message = C.lib.WordArray.create([
                0x00010203, 0x04050607, 0x08090a0b, 0x0c0d0e0f,
                0x10111213, 0x14151617, 0x18191a1b, 0x1c1d1e1f
            ]);
            this.data.key = C.lib.WordArray.create([0x20212223, 0x24252627, 0x28292a2b, 0x2c2d2e2f]);
            this.data.iv = C.lib.WordArray.create([0x30313233, 0x34353637, 0x38393a3b, 0x3c3d3e3f]);
        },

        testEncryptor: function () {
            // Compute expected
            var expected = this.data.message.clone();
            var aes = C.algo.AES.createEncryptor(this.data.key);

            // First block XORed with IV, then encrypted
            for (var i = 0; i < 4; i++) {
                expected.words[i] ^= this.data.iv.words[i];
            }
            aes.encryptBlock(expected.words, 0);

            // Subsequent blocks XORed with previous crypted block, then encrypted
            for (var i = 4; i < 8; i++) {
                expected.words[i] ^= expected.words[i - 4];
            }
            aes.encryptBlock(expected.words, 4);

            // Compute actual
            var actual = C.AES.encrypt(this.data.message, this.data.key, { iv: this.data.iv, mode: C.mode.CBC, padding: C.pad.NoPadding }).ciphertext;

            // Test
            Y.Assert.areEqual(expected.toString(), actual.toString());
        },

        testDecryptor: function () {
            var encrypted = C.AES.encrypt(this.data.message, this.data.key, { iv: this.data.iv, mode: C.mode.CBC, padding: C.pad.NoPadding });
            var decrypted = C.AES.decrypt(encrypted, this.data.key, { iv: this.data.iv, mode: C.mode.CBC, padding: C.pad.NoPadding });

            Y.Assert.areEqual(this.data.message.toString(), decrypted.toString());
        }
    }));
}, '$Rev$');
YUI.add('mode-cfb-test', function (Y) {
    var C = CryptoJS;

    Y.Test.Runner.add(new Y.Test.Case({
        name: 'CFB',

        setUp: function () {
            this.data = {};

            this.data.message = C.lib.WordArray.create([
                0x00010203, 0x04050607, 0x08090a0b, 0x0c0d0e0f,
                0x10111213, 0x14151617, 0x18191a1b, 0x1c1d1e1f
            ]);
            this.data.key = C.lib.WordArray.create([0x20212223, 0x24252627, 0x28292a2b, 0x2c2d2e2f]);
            this.data.iv = C.lib.WordArray.create([0x30313233, 0x34353637, 0x38393a3b, 0x3c3d3e3f]);
        },

        testEncryptor: function () {
            // Compute expected
            var expected = this.data.message.clone();
            var aes = C.algo.AES.createEncryptor(this.data.key);

            // First block XORed with encrypted IV
            var keystream = this.data.iv.words.slice(0);
            aes.encryptBlock(keystream, 0);
            for (var i = 0; i < 4; i++) {
                expected.words[i] ^= keystream[i];
            }

            // Subsequent blocks XORed with encrypted previous crypted block
            var keystream = expected.words.slice(0, 4);
            aes.encryptBlock(keystream, 0);
            for (var i = 4; i < 8; i++) {
                expected.words[i] ^= keystream[i % 4];
            }

            // Compute actual
            var actual = C.AES.encrypt(this.data.message, this.data.key, { iv: this.data.iv, mode: C.mode.CFB, padding: C.pad.NoPadding }).ciphertext;

            // Test
            Y.Assert.areEqual(expected.toString(), actual.toString());
        },

        testDecryptor: function () {
            var encrypted = C.AES.encrypt(this.data.message, this.data.key, { iv: this.data.iv, mode: C.mode.CFB, padding: C.pad.NoPadding });
            var decrypted = C.AES.decrypt(encrypted, this.data.key, { iv: this.data.iv, mode: C.mode.CFB, padding: C.pad.NoPadding });

            Y.Assert.areEqual(this.data.message.toString(), decrypted.toString());
        }
    }));
}, '$Rev$');
YUI.add('mode-ctr-test', function (Y) {
    var C = CryptoJS;

    Y.Test.Runner.add(new Y.Test.Case({
        name: 'CTR',

        setUp: function () {
            this.data = {};

            this.data.message = C.lib.WordArray.create([
                0x00010203, 0x04050607, 0x08090a0b, 0x0c0d0e0f,
                0x10111213, 0x14151617, 0x18191a1b, 0x1c1d1e1f
            ]);
            this.data.key = C.lib.WordArray.create([0x20212223, 0x24252627, 0x28292a2b, 0x2c2d2e2f]);
            this.data.iv = C.lib.WordArray.create([0x30313233, 0x34353637, 0x38393a3b, 0x3c3d3e3f]);
        },

        testEncryptor: function () {
            // Compute expected
            var expected = this.data.message.clone();
            var aes = C.algo.AES.createEncryptor(this.data.key);

            // Counter initialized with IV
            var counter = this.data.iv.words.slice(0);

            // First block XORed with encrypted counter
            var keystream = counter.slice(0);
            aes.encryptBlock(keystream, 0);
            for (var i = 0; i < 4; i++) {
                expected.words[i] ^= keystream[i];
            }

            // Subsequent blocks XORed with encrypted incremented counter
            counter[3]++;
            var keystream = counter.slice(0);
            aes.encryptBlock(keystream, 0);
            for (var i = 4; i < 8; i++) {
                expected.words[i] ^= keystream[i % 4];
            }

            // Compute actual
            var actual = C.AES.encrypt(this.data.message, this.data.key, { iv: this.data.iv, mode: C.mode.CTR, padding: C.pad.NoPadding }).ciphertext;

            // Test
            Y.Assert.areEqual(expected.toString(), actual.toString());
        },

        testDecryptor: function () {
            var encrypted = C.AES.encrypt(this.data.message, this.data.key, { iv: this.data.iv, mode: C.mode.CTR, padding: C.pad.NoPadding });
            var decrypted = C.AES.decrypt(encrypted, this.data.key, { iv: this.data.iv, mode: C.mode.CTR, padding: C.pad.NoPadding });

            Y.Assert.areEqual(this.data.message.toString(), decrypted.toString());
        }
    }));
}, '$Rev$');
YUI.add('mode-ecb-test', function (Y) {
    var C = CryptoJS;

    Y.Test.Runner.add(new Y.Test.Case({
        name: 'ECB',

        setUp: function () {
            this.data = {};

            this.data.message = C.lib.WordArray.create([
                0x00010203, 0x04050607, 0x08090a0b, 0x0c0d0e0f,
                0x10111213, 0x14151617, 0x18191a1b, 0x1c1d1e1f
            ]);
            this.data.key = C.lib.WordArray.create([0x20212223, 0x24252627, 0x28292a2b, 0x2c2d2e2f]);
        },

        testEncryptor: function () {
            // Compute expected
            var expected = this.data.message.clone();
            var aes = C.algo.AES.createEncryptor(this.data.key);
            aes.encryptBlock(expected.words, 0);
            aes.encryptBlock(expected.words, 4);

            // Compute actual
            var actual = C.AES.encrypt(this.data.message, this.data.key, { mode: C.mode.ECB, padding: C.pad.NoPadding }).ciphertext;

            // Test
            Y.Assert.areEqual(expected.toString(), actual.toString());
        },

        testDecryptor: function () {
            var encrypted = C.AES.encrypt(this.data.message, this.data.key, { mode: C.mode.ECB, padding: C.pad.NoPadding });
            var decrypted = C.AES.decrypt(encrypted, this.data.key, { mode: C.mode.ECB, padding: C.pad.NoPadding });

            Y.Assert.areEqual(this.data.message.toString(), decrypted.toString());
        }
    }));
}, '$Rev$');
YUI.add('mode-ofb-test', function (Y) {
    var C = CryptoJS;

    Y.Test.Runner.add(new Y.Test.Case({
        name: 'OFB',

        setUp: function () {
            this.data = {};

            this.data.message = C.lib.WordArray.create([
                0x00010203, 0x04050607, 0x08090a0b, 0x0c0d0e0f,
                0x10111213, 0x14151617, 0x18191a1b, 0x1c1d1e1f
            ]);
            this.data.key = C.lib.WordArray.create([0x20212223, 0x24252627, 0x28292a2b, 0x2c2d2e2f]);
            this.data.iv = C.lib.WordArray.create([0x30313233, 0x34353637, 0x38393a3b, 0x3c3d3e3f]);
        },

        testEncryptor: function () {
            // Compute expected
            var expected = this.data.message.clone();
            var aes = C.algo.AES.createEncryptor(this.data.key);

            // First block XORed with encrypted IV
            var keystream = this.data.iv.words.slice(0);
            aes.encryptBlock(keystream, 0);
            for (var i = 0; i < 4; i++) {
                expected.words[i] ^= keystream[i];
            }

            // Subsequent blocks XORed with encrypted previous keystream
            aes.encryptBlock(keystream, 0);
            for (var i = 4; i < 8; i++) {
                expected.words[i] ^= keystream[i % 4];
            }

            // Compute actual
            var actual = C.AES.encrypt(this.data.message, this.data.key, { iv: this.data.iv, mode: C.mode.OFB, padding: C.pad.NoPadding }).ciphertext;

            // Test
            Y.Assert.areEqual(expected.toString(), actual.toString());
        },

        testDecryptor: function () {
            var encrypted = C.AES.encrypt(this.data.message, this.data.key, { iv: this.data.iv, mode: C.mode.OFB, padding: C.pad.NoPadding });
            var decrypted = C.AES.decrypt(encrypted, this.data.key, { iv: this.data.iv, mode: C.mode.OFB, padding: C.pad.NoPadding });

            Y.Assert.areEqual(this.data.message.toString(), decrypted.toString());
        }
    }));
}, '$Rev$');
YUI.add('pad-ansix923-test', function (Y) {
    var C = CryptoJS;

    Y.Test.Runner.add(new Y.Test.Case({
        name: 'AnsiX923',

        testPad: function () {
            var data = C.lib.WordArray.create([0xdddddd00], 3);
            C.pad.AnsiX923.pad(data, 2);

            Y.Assert.areEqual(C.lib.WordArray.create([0xdddddd00, 0x00000005]).toString(), data.toString());
        },

        testPadClamp: function () {
            var data = C.lib.WordArray.create([0xdddddddd, 0xdddddddd], 3);
            C.pad.AnsiX923.pad(data, 2);

            Y.Assert.areEqual(C.lib.WordArray.create([0xdddddd00, 0x00000005]).toString(), data.toString());
        },

        testUnpad: function () {
            var data = C.lib.WordArray.create([0xdddddd00, 0x00000005]);
            C.pad.AnsiX923.unpad(data);

            Y.Assert.areEqual(C.lib.WordArray.create([0xdddddd00], 3).toString(), data.toString());
        }
    }));
}, '$Rev$');
YUI.add('pad-iso10126-test', function (Y) {
    var C = CryptoJS;

    Y.Test.Runner.add(new Y.Test.Case({
        name: 'Iso10126',

        setUp: function () {
            this.data = {};

            // Save original random method
            this.data.random = C.lib.WordArray.random;

            // Replace random method with one that returns a predictable value
            C.lib.WordArray.random = function (nBytes) {
                var words = [];
                for (var i = 0; i < nBytes; i += 4) {
                    words.push([0x11223344]);
                }

                return C.lib.WordArray.create(words, nBytes);
            };
        },

        tearDown: function () {
            // Restore random method
            C.lib.WordArray.random = this.data.random;
        },

        testPad: function () {
            var data = C.lib.WordArray.create([0xdddddd00], 3);
            C.pad.Iso10126.pad(data, 2);

            Y.Assert.areEqual(C.lib.WordArray.create([0xdddddd11, 0x22334405]).toString(), data.toString());
        },

        testPadClamp: function () {
            var data = C.lib.WordArray.create([0xdddddddd, 0xdddddddd], 3);
            C.pad.Iso10126.pad(data, 2);

            Y.Assert.areEqual(C.lib.WordArray.create([0xdddddd11, 0x22334405]).toString(), data.toString());
        },

        testUnpad: function () {
            var data = C.lib.WordArray.create([0xdddddd11, 0x22334405]);
            C.pad.Iso10126.unpad(data);

            Y.Assert.areEqual(C.lib.WordArray.create([0xdddddd00], 3).toString(), data.toString());
        }
    }));
}, '$Rev$');
YUI.add('pad-iso97971-test', function (Y) {
    var C = CryptoJS;

    Y.Test.Runner.add(new Y.Test.Case({
        name: 'Iso97971',

        testPad1: function () {
            var data = C.lib.WordArray.create([0xdddddd00], 3);
            C.pad.Iso97971.pad(data, 1);

            Y.Assert.areEqual(C.lib.WordArray.create([0xdddddd80]).toString(), data.toString());
        },

        testPad2: function () {
            var data = C.lib.WordArray.create([0xdddddd00], 3);
            C.pad.Iso97971.pad(data, 2);

            Y.Assert.areEqual(C.lib.WordArray.create([0xdddddd80, 0x00000000]).toString(), data.toString());
        },

        testPadClamp: function () {
            var data = C.lib.WordArray.create([0xdddddddd, 0xdddddddd], 3);
            C.pad.Iso97971.pad(data, 2);

            Y.Assert.areEqual(C.lib.WordArray.create([0xdddddd80, 0x00000000]).toString(), data.toString());
        },

        testUnpad: function () {
            var data = C.lib.WordArray.create([0xdddddd80, 0x00000000]);
            C.pad.Iso97971.unpad(data);

            Y.Assert.areEqual(C.lib.WordArray.create([0xdddddd00], 3).toString(), data.toString());
        }
    }));
}, '$Rev$');
YUI.add('pad-pkcs7-test', function (Y) {
    var C = CryptoJS;

    Y.Test.Runner.add(new Y.Test.Case({
        name: 'Pkcs7',

        testPad: function () {
            var data = C.lib.WordArray.create([0xdddddd00], 3);
            C.pad.Pkcs7.pad(data, 2);

            Y.Assert.areEqual(C.lib.WordArray.create([0xdddddd05, 0x05050505]).toString(), data.toString());
        },

        testPadClamp: function () {
            var data = C.lib.WordArray.create([0xdddddddd, 0xdddddddd], 3);
            C.pad.Pkcs7.pad(data, 2);

            Y.Assert.areEqual(C.lib.WordArray.create([0xdddddd05, 0x05050505]).toString(), data.toString());
        },

        testUnpad: function () {
            var data = C.lib.WordArray.create([0xdddddd05, 0x05050505]);
            C.pad.Pkcs7.unpad(data);

            Y.Assert.areEqual(C.lib.WordArray.create([0xdddddd00], 3).toString(), data.toString());
        }
    }));
}, '$Rev$');
YUI.add('pad-zeropadding-test', function (Y) {
    var C = CryptoJS;

    Y.Test.Runner.add(new Y.Test.Case({
        name: 'ZeroPadding',

        testPad: function () {
            var data = C.lib.WordArray.create([0xdddddd00], 3);
            C.pad.ZeroPadding.pad(data, 2);

            Y.Assert.areEqual(C.lib.WordArray.create([0xdddddd00, 0x00000000]).toString(), data.toString());
        },

        testPadClamp: function () {
            var data = C.lib.WordArray.create([0xdddddddd, 0xdddddddd], 3);
            C.pad.ZeroPadding.pad(data, 2);

            Y.Assert.areEqual(C.lib.WordArray.create([0xdddddd00, 0x00000000]).toString(), data.toString());
        },

        testUnpad: function () {
            var data = C.lib.WordArray.create([0xdddddd00, 0x00000000]);
            C.pad.ZeroPadding.unpad(data);

            Y.Assert.areEqual(C.lib.WordArray.create([0xdddddd00], 3).toString(), data.toString());
        }
    }));
}, '$Rev$');
YUI.add('algo-pbkdf2-profile', function (Y) {
    var C = CryptoJS;

    Y.Profiler.add({
        name: 'PBKDF2',

        profileKeySize256Iterations20: function () {
            C.algo.PBKDF2.create({ keySize: 256/32, iterations: 20 }).compute('password', 'ATHENA.MIT.EDUraeburn');
        }
    });
}, '$Rev$');
YUI.add('algo-pbkdf2-test', function (Y) {
    var C = CryptoJS;

    Y.Test.Runner.add(new Y.Test.Case({
        name: 'PBKDF2',

        testKeySize128: function () {
            Y.Assert.areEqual('62929ab995a1111c75c37bc562261ea3', C.PBKDF2('password', 'ATHENA.MIT.EDUraeburn', { keySize: 128/32 }).toString());
        },

        testKeySize256: function () {
            Y.Assert.areEqual('62929ab995a1111c75c37bc562261ea3fb3cdc7e725c4ca87c03cec5bb7663e1', C.PBKDF2('password', 'ATHENA.MIT.EDUraeburn', { keySize: 256/32 }).toString());
        },

        testKeySize128Iterations2: function () {
            Y.Assert.areEqual('262fb72ea65b44ab5ceba7f8c8bfa781', C.PBKDF2('password', 'ATHENA.MIT.EDUraeburn', { keySize: 128/32, iterations: 2 }).toString());
        },

        testKeySize256Iterations2: function () {
            Y.Assert.areEqual('262fb72ea65b44ab5ceba7f8c8bfa7815ff9939204eb7357a59a75877d745777', C.PBKDF2('password', 'ATHENA.MIT.EDUraeburn', { keySize: 256/32, iterations: 2 }).toString());
        },

        testKeySize128Iterations1200: function () {
            Y.Assert.areEqual('c76a982415f1acc71dc197273c5b6ada', C.PBKDF2('password', 'ATHENA.MIT.EDUraeburn', { keySize: 128/32, iterations: 1200 }).toString());
        },

        testKeySize256Iterations1200: function () {
            Y.Assert.areEqual('c76a982415f1acc71dc197273c5b6ada32f62915ed461718aad32843762433fa', C.PBKDF2('password', 'ATHENA.MIT.EDUraeburn', { keySize: 256/32, iterations: 1200 }).toString());
        },

        testKeySize128Iterations5: function () {
            Y.Assert.areEqual('74e98b2e9eeddaab3113c1efc6d82b07', C.PBKDF2('password', C.enc.Hex.parse('1234567878563412'), { keySize: 128/32, iterations: 5 }).toString());
        },

        testKeySize256Iterations5: function () {
            Y.Assert.areEqual('74e98b2e9eeddaab3113c1efc6d82b073c4860195b3e0737fa21a4778f376321', C.PBKDF2('password', C.enc.Hex.parse('1234567878563412'), { keySize: 256/32, iterations: 5 }).toString());
        },

        testKeySize128Iterations1200PassPhraseEqualsBlockSize: function () {
            Y.Assert.areEqual('c1dfb29a4d2f2fb67c6f78d074d66367', C.PBKDF2('XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', 'pass phrase equals block size', { keySize: 128/32, iterations: 1200 }).toString());
        },

        testKeySize256Iterations1200PassPhraseEqualsBlockSize: function () {
            Y.Assert.areEqual('c1dfb29a4d2f2fb67c6f78d074d663671e6fd4da1e598572b1fecf256cb7cf61', C.PBKDF2('XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', 'pass phrase equals block size', { keySize: 256/32, iterations: 1200 }).toString());
        },

        testKeySize128Iterations1200PassPhraseExceedsBlockSize: function () {
            Y.Assert.areEqual('22344bc4b6e32675a8090f3ea80be01d', C.PBKDF2('XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', 'pass phrase exceeds block size', { keySize: 128/32, iterations: 1200 }).toString());
        },

        testKeySize256Iterations1200PassPhraseExceedsBlockSize: function () {
            Y.Assert.areEqual('22344bc4b6e32675a8090f3ea80be01d5f95126a2cddc3facc4a5e6dca04ec58', C.PBKDF2('XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', 'pass phrase exceeds block size', { keySize: 256/32, iterations: 1200 }).toString());
        },

        testKeySize128Iterations50: function () {
            Y.Assert.areEqual('44b0781253db3141ac4174af29325818', C.PBKDF2(C.enc.Hex.parse('f09d849e'), 'EXAMPLE.COMpianist', { keySize: 128/32, iterations: 50 }).toString());
        },

        testKeySize256Iterations50: function () {
            Y.Assert.areEqual('44b0781253db3141ac4174af29325818584698d507a79f9879033dec308a2b77', C.PBKDF2(C.enc.Hex.parse('f09d849e'), 'EXAMPLE.COMpianist', { keySize: 256/32, iterations: 50 }).toString());
        },

        testInputIntegrity: function () {
            var password = C.lib.WordArray.create([0x12345678]);
            var salt = C.lib.WordArray.create([0x12345678]);

            var expectedPassword = password.toString();
            var expectedSalt = salt.toString();

            C.PBKDF2(password, salt);

            Y.Assert.areEqual(expectedPassword, password.toString());
            Y.Assert.areEqual(expectedSalt, salt.toString());
        },

        testHelper: function () {
            Y.Assert.areEqual(C.algo.PBKDF2.create({ keySize: 128/32 }).compute('password', 'ATHENA.MIT.EDUraeburn').toString(), C.PBKDF2('password', 'ATHENA.MIT.EDUraeburn', { keySize: 128/32 }).toString());
        }
    }));
}, '$Rev$');
<!doctype html>
<html>
    <head>
        <meta charset="utf-8">
        <title>CryptoJS Profile</title>

        <!-- CryptoJS -->
        <script src="../src/core.js"></script>
        <script src="../src/x64-core.js"></script>
        <script src="../src/enc-utf16.js"></script>
        <script src="../src/enc-base64.js"></script>
        <script src="../src/md5.js"></script>
        <script src="../src/sha1.js"></script>
        <script src="../src/sha256.js"></script>
        <script src="../src/sha512.js"></script>
        <script src="../src/sha3.js"></script>
        <script src="../src/hmac.js"></script>
        <script src="../src/pbkdf2.js"></script>
        <script src="../src/evpkdf.js"></script>
        <script src="../src/cipher-core.js"></script>
        <script src="../src/mode-cfb.js"></script>
        <script src="../src/mode-ctr.js"></script>
        <script src="../src/mode-ofb.js"></script>
        <script src="../src/mode-ecb.js"></script>
        <script src="../src/pad-ansix923.js"></script>
        <script src="../src/pad-iso10126.js"></script>
        <script src="../src/pad-zeropadding.js"></script>
        <script src="../src/pad-iso97971.js"></script>
        <script src="../src/pad-nopadding.js"></script>
        <script src="../src/rc4.js"></script>
        <script src="../src/rabbit.js"></script>
        <script src="../src/aes.js"></script>
        <script src="../src/tripledes.js"></script>

        <!-- YUI -->
        <script src="http://yui.yahooapis.com/3.4.1/build/yui/yui-min.js"></script>

        <!-- Profile subjects -->
        <script src="md5-profile.js"></script>
        <script src="sha1-profile.js"></script>
        <script src="sha256-profile.js"></script>
        <script src="sha512-profile.js"></script>
        <script src="sha3-profile.js"></script>
        <script src="hmac-profile.js"></script>
        <script src="pbkdf2-profile.js"></script>
        <script src="evpkdf-profile.js"></script>
        <script src="rc4-profile.js"></script>
        <script src="rabbit-profile.js"></script>
        <script src="aes-profile.js"></script>
        <script src="des-profile.js"></script>
        <script src="tripledes-profile.js"></script>

        <!-- Profile reports -->
        <script>
            YUI().use('profiler', 'console', 'substitute', function (Y) {
                // Implement Profiler.add
                Y.Profiler._subjects = [];
                Y.Profiler.add = function (subject) {
                    Y.Profiler._subjects.push(subject);
                };
                Y.Profiler.getSubjects = function () {
                    return Y.Profiler._subjects;
                };

                // Objects to profile
                var objects = [
                    'CryptoJS.lib.Base',
                    'CryptoJS.lib.WordArray',

                    'CryptoJS.x64.Word',
                    'CryptoJS.x64.WordArray',

                    'CryptoJS.enc.Hex',
                    'CryptoJS.enc.Latin1',
                    'CryptoJS.enc.Utf8',
                    'CryptoJS.enc.Utf16',
                    'CryptoJS.enc.Base64',

                    'CryptoJS.lib.BufferedBlockAlgorithm',
                    'CryptoJS.lib.Hasher',

                    'CryptoJS.algo.MD5',
                    'CryptoJS.algo.SHA1',
                    'CryptoJS.algo.SHA256',
                    'CryptoJS.algo.SHA512',
                    'CryptoJS.algo.SHA3',

                    'CryptoJS.algo.HMAC',

                    'CryptoJS.algo.PBKDF2',
                    'CryptoJS.algo.EvpKDF',

                    'CryptoJS.lib.Cipher',
                    'CryptoJS.lib.StreamCipher',
                    'CryptoJS.lib.BlockCipher',
                    'CryptoJS.lib.BlockCipherMode',
                    'CryptoJS.lib.CipherParams',
                    'CryptoJS.lib.SerializableCipher',
                    'CryptoJS.lib.PasswordBasedCipher',

                    'CryptoJS.mode.CBC', 'CryptoJS.mode.CBC.Encryptor', 'CryptoJS.mode.CBC.Decryptor',
                    'CryptoJS.mode.CFB', 'CryptoJS.mode.CFB.Encryptor', 'CryptoJS.mode.CFB.Decryptor',
                    'CryptoJS.mode.CTR', 'CryptoJS.mode.CTR.Encryptor', 'CryptoJS.mode.CTR.Decryptor',
                    'CryptoJS.mode.OFB', 'CryptoJS.mode.OFB.Encryptor', 'CryptoJS.mode.OFB.Decryptor',
                    'CryptoJS.mode.ECB', 'CryptoJS.mode.ECB.Encryptor', 'CryptoJS.mode.ECB.Decryptor',

                    'CryptoJS.pad.Pkcs7',
                    'CryptoJS.pad.AnsiX923',
                    'CryptoJS.pad.Iso10126',
                    'CryptoJS.pad.Iso97971',
                    'CryptoJS.pad.ZeroPadding',
                    'CryptoJS.pad.NoPadding',

                    'CryptoJS.format.OpenSSL',

                    'CryptoJS.kdf.OpenSSL',

                    'CryptoJS.algo.RC4',
                    'CryptoJS.algo.RC4Drop',
                    'CryptoJS.algo.Rabbit',
                    'CryptoJS.algo.AES',
                    'CryptoJS.algo.DES',
                    'CryptoJS.algo.TripleDES'
                ];

                function registerObjects() {
                    for (var i = 0; i < objects.length; i++) {
                        Y.Profiler.registerObject(objects[i]);
                    }
                }

                function unregisterObjects() {
                    for (var i = 0; i < objects.length; i++) {
                        Y.Profiler.unregisterObject(objects[i]);
                    }
                }

                // Load profile subjects
                Y.use('*', function (Y) {
                    // Iterate over profile subjects
                    var subjects = Y.Profiler.getSubjects();
                    for (var nSubject = 0; nSubject < subjects.length; nSubject++) {
                        // Shortcut
                        var subject = subjects[nSubject];

                        // Iterate over profile subject methods
                        for (var methodName in subject) {
                            if (typeof subject[methodName] == 'function' && methodName.indexOf('profile') == 0) {
                                // Set up
                                if (subject['setUp']) {
                                    subject['setUp']();
                                }

                                // Run
                                registerObjects();
                                subject[methodName]();
                                unregisterObjects();

                                // Tear down
                                if (subject['tearDown']) {
                                    subject['tearDown']();
                                }

                                // Get reports
                                var reports = Y.Profiler.getFullReport(function (report) {
                                    // Skip reports with 0 calls
                                    if ( ! report.calls) {
                                        return false;
                                    }

                                    // Create "total" entry
                                    report.total = 0;
                                    for (var i = 0; i < report.points.length; i++) {
                                        report.total += report.points[i];
                                    }

                                    // Round "avg" entry
                                    report.avg = Number(report.avg.toFixed(4));

                                    return true;
                                });

                                // Add name to reports
                                for (var name in reports) {
                                    reports[name].name = name;
                                }

                                // Sort reports by total time
                                var orderedReports = [];
                                for (var name in reports) {
                                    orderedReports.push(reports[name]);
                                }
                                orderedReports.sort(function (a, b) {
                                    return ((b.total - a.total) || (b.calls - a.calls));
                                });

                                // Create profile source
                                var source = subject.name + '_' + methodName;

                                // Create console
                                var yconsole = new Y.Console({
                                    style: 'block',
                                    width: '100%',
                                    height: '600px',
                                    entryTemplate:
                                        '<div class="{entry_class} {cat_class} {src_class}">' +
                                        '    <pre class="{entry_content_class}">{message}</pre>' +
                                        '</div>',
                                    strings: {
                                        title: source,
                                        pause: 'Pause',
                                        clear: 'Clear',
                                        collapse: 'Collapse',
                                        expand: 'Expand'
                                    },
                                    newestOnTop: false,
                                    render: true
                                });

                                // Restrict profile sources
                                (function (yconsole, source) {
                                    yconsole.on('entry', function (e) {
                                        if (e.message.source != source) {
                                            e.preventDefault();
                                        }
                                    });
                                }(yconsole, source));

                                // Collapse doesn't seem to work reliably unless we do it after DOM ready
                                (function (yconsole) {
                                    Y.on('domready', function () {
                                        yconsole.collapse();
                                    });
                                }(yconsole));

                                // Log reports
                                for (var i = 0; i < orderedReports.length; i++) {
                                    var template =
                                        '[{total}ms] {name}(): Called {calls} times. ' +
                                        'Avg: {avg}ms, Min: {min}ms, Max: {max}ms';
                                    var message = Y.substitute(template, orderedReports[i]);

                                    Y.log(message, 'time', source);
                                }

                                // Clean slate for next profile subject
                                Y.Profiler.clear();
                            }
                        }
                    }
                });
            });
        </script>

        <!-- Console -->
        <style type="text/css">
            body.yui3-skin-sam .yui3-console {
                margin: 1em 0;
            }
            body.yui3-skin-sam .yui3-console-entry-meta,
            body.yui3-skin-sam .yui3-console-entry-content {
                display: inline-block;
                vertical-align: top;
            }
            body.yui3-skin-sam .yui3-console-entry-cat {
                display: inline-block;
                width: 35px;
                text-align: center;
            }
            body.yui3-skin-sam .yui3-console-entry {
                min-height: 0;
            }
            body.yui3-skin-sam .yui3-console-ft .yui3-console-filters-categories,
            body.yui3-skin-sam .yui3-console-ft .yui3-console-filters-sources {
                display: none;
            }
        </style>
    </head>
    <body class="yui3-skin-sam">
    </body>
</html>
YUI.add('algo-rabbit-legacy-test', function (Y) {
    var C = CryptoJS;

    Y.Test.Runner.add(new Y.Test.Case({
        name: 'RabbitLegacy',

        testVector1: function () {
            Y.Assert.areEqual('02f74a1c26456bf5ecd6a536f05457b1', C.RabbitLegacy.encrypt(C.enc.Hex.parse('00000000000000000000000000000000'), C.enc.Hex.parse('00000000000000000000000000000000')).ciphertext.toString());
        },

        testVector2: function () {
            Y.Assert.areEqual('9c51e28784c37fe9a127f63ec8f32d3d', C.RabbitLegacy.encrypt(C.enc.Hex.parse('00000000000000000000000000000000'), C.enc.Hex.parse('dc51c3ac3bfc62f12e3d36fe91281329')).ciphertext.toString());
        },

        testVector3: function () {
            Y.Assert.areEqual('9b60d002fd5ceb32accd41a0cd0db10c', C.RabbitLegacy.encrypt(C.enc.Hex.parse('00000000000000000000000000000000'), C.enc.Hex.parse('c09b0043e9e9ab0187e0c73383957415')).ciphertext.toString());
        },

        testVector4: function () {
            Y.Assert.areEqual('edb70567375dcd7cd89554f85e27a7c6', C.RabbitLegacy.encrypt(C.enc.Hex.parse('00000000000000000000000000000000'), C.enc.Hex.parse('00000000000000000000000000000000'), { iv: C.enc.Hex.parse('0000000000000000') }).ciphertext.toString());
        },

        testVector5: function () {
            Y.Assert.areEqual('6d7d012292ccdce0e2120058b94ecd1f', C.RabbitLegacy.encrypt(C.enc.Hex.parse('00000000000000000000000000000000'), C.enc.Hex.parse('00000000000000000000000000000000'), { iv: C.enc.Hex.parse('597e26c175f573c3') }).ciphertext.toString());
        },

        testVector6: function () {
            Y.Assert.areEqual('4d1051a123afb670bf8d8505c8d85a44', C.RabbitLegacy.encrypt(C.enc.Hex.parse('00000000000000000000000000000000'), C.enc.Hex.parse('00000000000000000000000000000000'), { iv: C.enc.Hex.parse('2717f4d21a56eba6') }).ciphertext.toString());
        },

        testMultiPart: function () {
            var rabbit = C.algo.RabbitLegacy.createEncryptor(C.enc.Hex.parse('00000000000000000000000000000000'));
            var ciphertext1 = rabbit.process(C.enc.Hex.parse('000000000000'));
            var ciphertext2 = rabbit.process(C.enc.Hex.parse('0000000000'));
            var ciphertext3 = rabbit.process(C.enc.Hex.parse('0000000000'));
            var ciphertext4 = rabbit.finalize();

            Y.Assert.areEqual('02f74a1c26456bf5ecd6a536f05457b1', ciphertext1.concat(ciphertext2).concat(ciphertext3).concat(ciphertext4).toString());
        },

        testInputIntegrity: function () {
            var message = C.enc.Hex.parse('00000000000000000000000000000000');
            var key = C.enc.Hex.parse('00000000000000000000000000000000');
            var iv = C.enc.Hex.parse('0000000000000000');

            var expectedMessage = message.toString();
            var expectedKey = key.toString();
            var expectedIv = iv.toString();

            C.RabbitLegacy.encrypt(message, key, { iv: iv });

            Y.Assert.areEqual(expectedMessage, message.toString());
            Y.Assert.areEqual(expectedKey, key.toString());
            Y.Assert.areEqual(expectedIv, iv.toString());
        },

        testHelper: function () {
            // Save original random method
            var random = C.lib.WordArray.random;

            // Replace random method with one that returns a predictable value
            C.lib.WordArray.random = function (nBytes) {
                var words = [];
                for (var i = 0; i < nBytes; i += 4) {
                    words.push([0x11223344]);
                }

                return C.lib.WordArray.create(words, nBytes);
            };

            // Test
            Y.Assert.areEqual(C.algo.RabbitLegacy.createEncryptor(C.MD5('Jefe')).finalize('Hi There').toString(), C.RabbitLegacy.encrypt('Hi There', C.MD5('Jefe')).ciphertext.toString());
            Y.Assert.areEqual(C.lib.SerializableCipher.encrypt(C.algo.RabbitLegacy, 'Hi There', C.MD5('Jefe')).toString(), C.RabbitLegacy.encrypt('Hi There', C.MD5('Jefe')).toString());
            Y.Assert.areEqual(C.lib.PasswordBasedCipher.encrypt(C.algo.RabbitLegacy, 'Hi There', 'Jefe').toString(), C.RabbitLegacy.encrypt('Hi There', 'Jefe').toString());

            // Restore random method
            C.lib.WordArray.random = random;
        }
    }));
}, '$Rev$');
YUI.add('algo-rabbit-profile', function (Y) {
    var C = CryptoJS;

    Y.Profiler.add({
        name: 'Rabbit',

        setUp: function () {
            this.data = {
                key: C.enc.Hex.parse('000102030405060708090a0b0c0d0e0f')
            };
        },

        profileSinglePartMessage: function () {
            var singlePartMessage = '';
            for (var i = 0; i < 500; i++) {
                singlePartMessage += '12345678901234567890123456789012345678901234567890';
            }

            C.algo.Rabbit.createEncryptor(this.data.key).finalize(singlePartMessage) + '';
        },

        profileMultiPartMessage: function () {
            var rabbit = C.algo.Rabbit.createEncryptor(this.data.key);
            for (var i = 0; i < 500; i++) {
                rabbit.process('12345678901234567890123456789012345678901234567890') + '';
            }
            rabbit.finalize() + '';
        }
    });
}, '$Rev$');
YUI.add('algo-rabbit-test', function (Y) {
    var C = CryptoJS;

    Y.Test.Runner.add(new Y.Test.Case({
        name: 'Rabbit',

        testVector1: function () {
            Y.Assert.areEqual('02f74a1c26456bf5ecd6a536f05457b1', C.Rabbit.encrypt(C.enc.Hex.parse('00000000000000000000000000000000'), C.enc.Hex.parse('00000000000000000000000000000000')).ciphertext.toString());
        },

        testVector2: function () {
            Y.Assert.areEqual('3d02e0c730559112b473b790dee018df', C.Rabbit.encrypt(C.enc.Hex.parse('00000000000000000000000000000000'), C.enc.Hex.parse('c21fcf3881cd5ee8628accb0a9890df8')).ciphertext.toString());
        },

        testVector3: function () {
            Y.Assert.areEqual('a3a97abb80393820b7e50c4abb53823d', C.Rabbit.encrypt(C.enc.Hex.parse('00000000000000000000000000000000'), C.enc.Hex.parse('1d272c6a2d8e3dfcac14056b78d633a0')).ciphertext.toString());
        },

        testVector4: function () {
            Y.Assert.areEqual('75d186d6bc6905c64f1b2dfdd51f7bfc', C.Rabbit.encrypt(C.enc.Hex.parse('00000000000000000000000000000000'), C.enc.Hex.parse('0053a6f94c9ff24598eb3e91e4378add'), { iv: C.enc.Hex.parse('0d74db42a91077de') }).ciphertext.toString());
        },

        testVector5: function () {
            Y.Assert.areEqual('476e2750c73856c93563b5f546f56a6a', C.Rabbit.encrypt(C.enc.Hex.parse('00000000000000000000000000000000'), C.enc.Hex.parse('0558abfe51a4f74a9df04396e93c8fe2'), { iv: C.enc.Hex.parse('167de44bb21980e7') }).ciphertext.toString());
        },

        testVector6: function () {
            Y.Assert.areEqual('921fcf4983891365a7dc901924b5e24b', C.Rabbit.encrypt(C.enc.Hex.parse('00000000000000000000000000000000'), C.enc.Hex.parse('0a5db00356a9fc4fa2f5489bee4194e7'), { iv: C.enc.Hex.parse('1f86ed54bb2289f0') }).ciphertext.toString());
        },

        testVector7: function () {
            Y.Assert.areEqual('613cb0ba96aff6cacf2a459a102a7f78', C.Rabbit.encrypt(C.enc.Hex.parse('00000000000000000000000000000000'), C.enc.Hex.parse('0f62b5085bae0154a7fa4da0f34699ec'), { iv: C.enc.Hex.parse('288ff65dc42b92f9') }).ciphertext.toString());
        },

        testMultiPart: function () {
            var rabbit = C.algo.Rabbit.createEncryptor(C.enc.Hex.parse('00000000000000000000000000000000'));
            var ciphertext1 = rabbit.process(C.enc.Hex.parse('000000000000'));
            var ciphertext2 = rabbit.process(C.enc.Hex.parse('0000000000'));
            var ciphertext3 = rabbit.process(C.enc.Hex.parse('0000000000'));
            var ciphertext4 = rabbit.finalize();

            Y.Assert.areEqual('02f74a1c26456bf5ecd6a536f05457b1', ciphertext1.concat(ciphertext2).concat(ciphertext3).concat(ciphertext4).toString());
        },

        testInputIntegrity: function () {
            var message = C.enc.Hex.parse('00000000000000000000000000000000');
            var key = C.enc.Hex.parse('00000000000000000000000000000000');
            var iv = C.enc.Hex.parse('0000000000000000');

            var expectedMessage = message.toString();
            var expectedKey = key.toString();
            var expectedIv = iv.toString();

            C.Rabbit.encrypt(message, key, { iv: iv });

            Y.Assert.areEqual(expectedMessage, message.toString());
            Y.Assert.areEqual(expectedKey, key.toString());
            Y.Assert.areEqual(expectedIv, iv.toString());
        },

        testHelper: function () {
            // Save original random method
            var random = C.lib.WordArray.random;

            // Replace random method with one that returns a predictable value
            C.lib.WordArray.random = function (nBytes) {
                var words = [];
                for (var i = 0; i < nBytes; i += 4) {
                    words.push([0x11223344]);
                }

                return C.lib.WordArray.create(words, nBytes);
            };

            // Test
            Y.Assert.areEqual(C.algo.Rabbit.createEncryptor(C.MD5('Jefe')).finalize('Hi There').toString(), C.Rabbit.encrypt('Hi There', C.MD5('Jefe')).ciphertext.toString());
            Y.Assert.areEqual(C.lib.SerializableCipher.encrypt(C.algo.Rabbit, 'Hi There', C.MD5('Jefe')).toString(), C.Rabbit.encrypt('Hi There', C.MD5('Jefe')).toString());
            Y.Assert.areEqual(C.lib.PasswordBasedCipher.encrypt(C.algo.Rabbit, 'Hi There', 'Jefe').toString(), C.Rabbit.encrypt('Hi There', 'Jefe').toString());

            // Restore random method
            C.lib.WordArray.random = random;
        }
    }));
}, '$Rev$');
YUI.add('algo-rc4-profile', function (Y) {
    var C = CryptoJS;

    Y.Profiler.add({
        name: 'RC4',

        setUp: function () {
            this.data = {
                key: C.enc.Hex.parse('000102030405060708090a0b0c0d0e0f')
            };
        },

        profileSinglePartMessage: function () {
            var singlePartMessage = '';
            for (var i = 0; i < 500; i++) {
                singlePartMessage += '12345678901234567890123456789012345678901234567890';
            }

            C.algo.RC4.createEncryptor(this.data.key).finalize(singlePartMessage) + '';
        },

        profileMultiPartMessage: function () {
            var rc4 = C.algo.RC4.createEncryptor(this.data.key);
            for (var i = 0; i < 500; i++) {
                rc4.process('12345678901234567890123456789012345678901234567890') + '';
            }
            rc4.finalize() + '';
        }
    });
}, '$Rev$');
YUI.add('algo-rc4-test', function (Y) {
    var C = CryptoJS;

    Y.Test.Runner.add(new Y.Test.Case({
        name: 'RC4',

        testVector1: function () {
            Y.Assert.areEqual('7494c2e7104b0879', C.RC4.encrypt(C.enc.Hex.parse('0000000000000000'), C.enc.Hex.parse('0123456789abcdef')).ciphertext.toString());
        },

        testVector2: function () {
            Y.Assert.areEqual('f13829c9de', C.RC4.encrypt(C.enc.Hex.parse('dcee4cf92c'), C.enc.Hex.parse('618a63d2fb')).ciphertext.toString());
        },

        testDrop: function () {
            Y.Assert.areEqual(
                C.RC4.encrypt(C.enc.Hex.parse('00000000000000000000000000000000'), C.enc.Hex.parse('0123456789abcdef')).ciphertext.toString().substr(16),
                C.RC4Drop.encrypt(C.enc.Hex.parse('0000000000000000'), C.enc.Hex.parse('0123456789abcdef'), { drop: 2 }).ciphertext.toString()
            );
        },

        testMultiPart: function () {
            var rc4 = C.algo.RC4.createEncryptor(C.enc.Hex.parse('0123456789abcdef'));
            var ciphertext1 = rc4.process(C.enc.Hex.parse('00000000'));
            var ciphertext2 = rc4.process(C.enc.Hex.parse('0000'));
            var ciphertext3 = rc4.process(C.enc.Hex.parse('0000'));
            var ciphertext4 = rc4.finalize();

            Y.Assert.areEqual('7494c2e7104b0879', ciphertext1.concat(ciphertext2).concat(ciphertext3).concat(ciphertext4).toString());
        },

        testInputIntegrity: function () {
            var message = C.enc.Hex.parse('0000000000000000');
            var key = C.enc.Hex.parse('0123456789abcdef');

            var expectedMessage = message.toString();
            var expectedKey = key.toString();

            C.RC4.encrypt(message, key);

            Y.Assert.areEqual(expectedMessage, message.toString());
            Y.Assert.areEqual(expectedKey, key.toString());
        },

        testHelper: function () {
            // Save original random method
            var random = C.lib.WordArray.random;

            // Replace random method with one that returns a predictable value
            C.lib.WordArray.random = function (nBytes) {
                var words = [];
                for (var i = 0; i < nBytes; i += 4) {
                    words.push([0x11223344]);
                }

                return C.lib.WordArray.create(words, nBytes);
            };

            // Test
            Y.Assert.areEqual(C.algo.RC4.createEncryptor(C.SHA256('Jefe')).finalize('Hi There').toString(), C.RC4.encrypt('Hi There', C.SHA256('Jefe')).ciphertext.toString());
            Y.Assert.areEqual(C.lib.SerializableCipher.encrypt(C.algo.RC4, 'Hi There', C.SHA256('Jefe')).toString(), C.RC4.encrypt('Hi There', C.SHA256('Jefe')).toString());
            Y.Assert.areEqual(C.lib.PasswordBasedCipher.encrypt(C.algo.RC4, 'Hi There', 'Jefe').toString(), C.RC4.encrypt('Hi There', 'Jefe').toString());

            // Restore random method
            C.lib.WordArray.random = random;
        }
    }));
}, '$Rev$');
YUI.add('algo-ripemd160-test', function (Y) {
    var C = CryptoJS;

    Y.Test.Runner.add(new Y.Test.Case({
        name: 'RIPEMD160',

        testVector1: function () {
            Y.Assert.areEqual('37f332f68db77bd9d7edd4969571ad671cf9dd3b', C.RIPEMD160('The quick brown fox jumps over the lazy dog').toString());
        },

        testVector2: function () {
            Y.Assert.areEqual('132072df690933835eb8b6ad0b77e7b6f14acad7', C.RIPEMD160('The quick brown fox jumps over the lazy cog').toString());
        },

        testVector3: function () {
            Y.Assert.areEqual('9c1185a5c5e9fc54612808977ee8f548b2258d31', C.RIPEMD160('').toString());
        }
    }));
}, '$Rev$');
YUI.add('algo-sha1-profile', function (Y) {
    var C = CryptoJS;

    Y.Profiler.add({
        name: 'SHA1',

        profileSinglePartMessage: function () {
            var singlePartMessage = '';
            for (var i = 0; i < 500; i++) {
                singlePartMessage += '12345678901234567890123456789012345678901234567890';
            }

            C.algo.SHA1.create().finalize(singlePartMessage) + '';
        },

        profileMultiPartMessage: function () {
            var sha1 = C.algo.SHA1.create();
            for (var i = 0; i < 500; i++) {
                sha1.update('12345678901234567890123456789012345678901234567890');
            }
            sha1.finalize() + '';
        }
    });
}, '$Rev$');
YUI.add('algo-sha1-test', function (Y) {
    var C = CryptoJS;

    Y.Test.Runner.add(new Y.Test.Case({
        name: 'SHA1',

        testVector1: function () {
            Y.Assert.areEqual('da39a3ee5e6b4b0d3255bfef95601890afd80709', C.SHA1('').toString());
        },

        testVector2: function () {
            Y.Assert.areEqual('86f7e437faa5a7fce15d1ddcb9eaeaea377667b8', C.SHA1('a').toString());
        },

        testVector3: function () {
            Y.Assert.areEqual('a9993e364706816aba3e25717850c26c9cd0d89d', C.SHA1('abc').toString());
        },

        testVector4: function () {
            Y.Assert.areEqual('c12252ceda8be8994d5fa0290a47231c1d16aae3', C.SHA1('message digest').toString());
        },

        testVector5: function () {
            Y.Assert.areEqual('32d10c7b8cf96570ca04ce37f2a19d84240d3a89', C.SHA1('abcdefghijklmnopqrstuvwxyz').toString());
        },

        testVector6: function () {
            Y.Assert.areEqual('761c457bf73b14d27e9e9265c46f4b4dda11f940', C.SHA1('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789').toString());
        },

        testVector7: function () {
            Y.Assert.areEqual('50abf5706a150990a08b2c5ea40fa0e585554732', C.SHA1('12345678901234567890123456789012345678901234567890123456789012345678901234567890').toString());
        },

        testUpdateAndLongMessage: function () {
            var sha1 = C.algo.SHA1.create();
            for (var i = 0; i < 100; i++) {
                sha1.update('12345678901234567890123456789012345678901234567890');
            }

            Y.Assert.areEqual('85e4c4b3933d5553ebf82090409a9d90226d845c', sha1.finalize().toString());
        },

        testClone: function () {
            var sha1 = C.algo.SHA1.create();

            Y.Assert.areEqual(C.SHA1('a').toString(), sha1.update('a').clone().finalize().toString());
            Y.Assert.areEqual(C.SHA1('ab').toString(), sha1.update('b').clone().finalize().toString());
            Y.Assert.areEqual(C.SHA1('abc').toString(), sha1.update('c').clone().finalize().toString());
        },

        testInputIntegrity: function () {
            var message = C.lib.WordArray.create([0x12345678]);

            var expected = message.toString();

            C.SHA1(message);

            Y.Assert.areEqual(expected, message.toString());
        },

        testHelper: function () {
            Y.Assert.areEqual(C.algo.SHA1.create().finalize('').toString(), C.SHA1('').toString());
        },

        testHmacHelper: function () {
            Y.Assert.areEqual(C.algo.HMAC.create(C.algo.SHA1, C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).finalize('Hi There').toString(), C.HmacSHA1('Hi There', C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).toString());
        }
    }));
}, '$Rev$');
YUI.add('algo-sha224-test', function (Y) {
    var C = CryptoJS;

    Y.Test.Runner.add(new Y.Test.Case({
        name: 'SHA224',

        testVector1: function () {
            Y.Assert.areEqual('d14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f', C.SHA224('').toString());
        },

        testVector2: function () {
            Y.Assert.areEqual('730e109bd7a8a32b1cb9d9a09aa2325d2430587ddbc0c38bad911525', C.SHA224('The quick brown fox jumps over the lazy dog').toString());
        },

        testVector3: function () {
            Y.Assert.areEqual('619cba8e8e05826e9b8c519c0a5c68f4fb653e8a3d8aa04bb2c8cd4c', C.SHA224('The quick brown fox jumps over the lazy dog.').toString());
        }
    }));
}, '$Rev$');
YUI.add('algo-sha256-profile', function (Y) {
    var C = CryptoJS;

    Y.Profiler.add({
        name: 'SHA256',

        profileSinglePartMessage: function () {
            var singlePartMessage = '';
            for (var i = 0; i < 500; i++) {
                singlePartMessage += '12345678901234567890123456789012345678901234567890';
            }

            C.algo.SHA256.create().finalize(singlePartMessage) + '';
        },

        profileMultiPartMessage: function () {
            var sha256 = C.algo.SHA256.create();
            for (var i = 0; i < 500; i++) {
                sha256.update('12345678901234567890123456789012345678901234567890');
            }
            sha256.finalize() + '';
        }
    });
}, '$Rev$');
YUI.add('algo-sha256-test', function (Y) {
    var C = CryptoJS;

    Y.Test.Runner.add(new Y.Test.Case({
        name: 'SHA256',

        testVector1: function () {
            Y.Assert.areEqual('e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', C.SHA256('').toString());
        },

        testVector2: function () {
            Y.Assert.areEqual('ca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb', C.SHA256('a').toString());
        },

        testVector3: function () {
            Y.Assert.areEqual('ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad', C.SHA256('abc').toString());
        },

        testVector4: function () {
            Y.Assert.areEqual('f7846f55cf23e14eebeab5b4e1550cad5b509e3348fbc4efa3a1413d393cb650', C.SHA256('message digest').toString());
        },

        testVector5: function () {
            Y.Assert.areEqual('71c480df93d6ae2f1efad1447c66c9525e316218cf51fc8d9ed832f2daf18b73', C.SHA256('abcdefghijklmnopqrstuvwxyz').toString());
        },

        testVector6: function () {
            Y.Assert.areEqual('db4bfcbd4da0cd85a60c3c37d3fbd8805c77f15fc6b1fdfe614ee0a7c8fdb4c0', C.SHA256('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789').toString());
        },

        testVector7: function () {
            Y.Assert.areEqual('f371bc4a311f2b009eef952dd83ca80e2b60026c8e935592d0f9c308453c813e', C.SHA256('12345678901234567890123456789012345678901234567890123456789012345678901234567890').toString());
        },

        testUpdateAndLongMessage: function () {
            var sha256 = C.algo.SHA256.create();
            for (var i = 0; i < 100; i++) {
                sha256.update('12345678901234567890123456789012345678901234567890');
            }

            Y.Assert.areEqual('f8146961d9b73d8da49ccd526fca65439cdd5b402f76971556d5f52fd129843e', sha256.finalize().toString());
        },

        testClone: function () {
            var sha256 = C.algo.SHA256.create();

            Y.Assert.areEqual(C.SHA256('a').toString(), sha256.update('a').clone().finalize().toString());
            Y.Assert.areEqual(C.SHA256('ab').toString(), sha256.update('b').clone().finalize().toString());
            Y.Assert.areEqual(C.SHA256('abc').toString(), sha256.update('c').clone().finalize().toString());
        },

        testInputIntegrity: function () {
            var message = C.lib.WordArray.create([0x12345678]);

            var expected = message.toString();

            C.SHA256(message);

            Y.Assert.areEqual(expected, message.toString());
        },

        testHelper: function () {
            Y.Assert.areEqual(C.algo.SHA256.create().finalize('').toString(), C.SHA256('').toString());
        },

        testHmacHelper: function () {
            Y.Assert.areEqual(C.algo.HMAC.create(C.algo.SHA256, C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).finalize('Hi There').toString(), C.HmacSHA256('Hi There', C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).toString());
        }
    }));
}, '$Rev$');
YUI.add('algo-sha3-profile', function (Y) {
    var C = CryptoJS;

    Y.Profiler.add({
        name: 'SHA3',

        profileSinglePartMessage: function () {
            var singlePartMessage = '';
            for (var i = 0; i < 500; i++) {
                singlePartMessage += '12345678901234567890123456789012345678901234567890';
            }

            C.algo.SHA3.create().finalize(singlePartMessage) + '';
        },

        profileMultiPartMessage: function () {
            var sha3 = C.algo.SHA3.create();
            for (var i = 0; i < 500; i++) {
                sha3.update('12345678901234567890123456789012345678901234567890');
            }
            sha3.finalize() + '';
        }
    });
}, '$Rev$');
YUI.add('algo-sha3-test', function (Y) {
    var C = CryptoJS;

    Y.Test.Runner.add(new Y.Test.Case({
        name: 'SHA3',

        testVector1: function () {
            Y.Assert.areEqual('0eab42de4c3ceb9235fc91acffe746b29c29a8c366b7c60e4e67c466f36a4304c00fa9caf9d87976ba469bcbe06713b435f091ef2769fb160cdab33d3670680e', C.SHA3('', { outputLength: 512 }).toString());
        },

        testVector2: function () {
            Y.Assert.areEqual('81950e7096d31d4f22e3db71cac725bf59e81af54c7ca9e6aeee71c010fc5467466312a01aa5c137cfb140646941556796f612c9351268737c7e9a2b9631d1fa', C.SHA3(C.enc.Hex.parse('3a3a819c48efde2ad914fbf00e18ab6bc4f14513ab27d0c178a188b61431e7f5623cb66b23346775d386b50e982c493adbbfc54b9a3cd383382336a1a0b2150a15358f336d03ae18f666c7573d55c4fd181c29e6ccfde63ea35f0adf5885cfc0a3d84a2b2e4dd24496db789e663170cef74798aa1bbcd4574ea0bba40489d764b2f83aadc66b148b4a0cd95246c127d5871c4f11418690a5ddf01246a0c80a43c70088b6183639dcfda4125bd113a8f49ee23ed306faac576c3fb0c1e256671d817fc2534a52f5b439f72e424de376f4c565cca82307dd9ef76da5b7c4eb7e085172e328807c02d011ffbf33785378d79dc266f6a5be6bb0e4a92eceebaeb1'), { outputLength: 512 }).toString());
        },

        testVector3: function () {
            Y.Assert.areEqual('2c23146a63a29acf99e73b88f8c24eaa7dc60aa771780ccc006afbfa8fe2479b2dd2b21362337441ac12b515911957ff', C.SHA3('', { outputLength: 384 }).toString());
        },

        testVector4: function () {
            Y.Assert.areEqual('6bff1c8405a3fe594e360e3bccea1ebcd509310dc79b9e45c263783d7a5dd662c6789b18bd567dbdda1554f5bee6a860', C.SHA3(C.enc.Hex.parse('3a3a819c48efde2ad914fbf00e18ab6bc4f14513ab27d0c178a188b61431e7f5623cb66b23346775d386b50e982c493adbbfc54b9a3cd383382336a1a0b2150a15358f336d03ae18f666c7573d55c4fd181c29e6ccfde63ea35f0adf5885cfc0a3d84a2b2e4dd24496db789e663170cef74798aa1bbcd4574ea0bba40489d764b2f83aadc66b148b4a0cd95246c127d5871c4f11418690a5ddf01246a0c80a43c70088b6183639dcfda4125bd113a8f49ee23ed306faac576c3fb0c1e256671d817fc2534a52f5b439f72e424de376f4c565cca82307dd9ef76da5b7c4eb7e085172e328807c02d011ffbf33785378d79dc266f6a5be6bb0e4a92eceebaeb1'), { outputLength: 384 }).toString());
        },

        testVector5: function () {
            Y.Assert.areEqual('c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470', C.SHA3('', { outputLength: 256 }).toString());
        },

        testVector6: function () {
            Y.Assert.areEqual('348fb774adc970a16b1105669442625e6adaa8257a89effdb5a802f161b862ea', C.SHA3(C.enc.Hex.parse('3a3a819c48efde2ad914fbf00e18ab6bc4f14513ab27d0c178a188b61431e7f5623cb66b23346775d386b50e982c493adbbfc54b9a3cd383382336a1a0b2150a15358f336d03ae18f666c7573d55c4fd181c29e6ccfde63ea35f0adf5885cfc0a3d84a2b2e4dd24496db789e663170cef74798aa1bbcd4574ea0bba40489d764b2f83aadc66b148b4a0cd95246c127d5871c4f11418690a5ddf01246a0c80a43c70088b6183639dcfda4125bd113a8f49ee23ed306faac576c3fb0c1e256671d817fc2534a52f5b439f72e424de376f4c565cca82307dd9ef76da5b7c4eb7e085172e328807c02d011ffbf33785378d79dc266f6a5be6bb0e4a92eceebaeb1'), { outputLength: 256 }).toString());
        },

        testVector7: function () {
            Y.Assert.areEqual('f71837502ba8e10837bdd8d365adb85591895602fc552b48b7390abd', C.SHA3('', { outputLength: 224 }).toString());
        },

        testVector8: function () {
            Y.Assert.areEqual('5af56987ea9cf11fcd0eac5ebc14b037365e9b1123e31cb2dfc7929a', C.SHA3(C.enc.Hex.parse('3a3a819c48efde2ad914fbf00e18ab6bc4f14513ab27d0c178a188b61431e7f5623cb66b23346775d386b50e982c493adbbfc54b9a3cd383382336a1a0b2150a15358f336d03ae18f666c7573d55c4fd181c29e6ccfde63ea35f0adf5885cfc0a3d84a2b2e4dd24496db789e663170cef74798aa1bbcd4574ea0bba40489d764b2f83aadc66b148b4a0cd95246c127d5871c4f11418690a5ddf01246a0c80a43c70088b6183639dcfda4125bd113a8f49ee23ed306faac576c3fb0c1e256671d817fc2534a52f5b439f72e424de376f4c565cca82307dd9ef76da5b7c4eb7e085172e328807c02d011ffbf33785378d79dc266f6a5be6bb0e4a92eceebaeb1'), { outputLength: 224 }).toString());
        },

        testDefaultOutputLength: function () {
            Y.Assert.areEqual('0eab42de4c3ceb9235fc91acffe746b29c29a8c366b7c60e4e67c466f36a4304c00fa9caf9d87976ba469bcbe06713b435f091ef2769fb160cdab33d3670680e', C.SHA3('').toString());
        },

        testClone: function () {
            var sha3 = C.algo.SHA3.create();

            Y.Assert.areEqual(C.SHA3('a').toString(), sha3.update('a').clone().finalize().toString());
            Y.Assert.areEqual(C.SHA3('ab').toString(), sha3.update('b').clone().finalize().toString());
            Y.Assert.areEqual(C.SHA3('abc').toString(), sha3.update('c').clone().finalize().toString());
        },

        testInputIntegrity: function () {
            var message = C.lib.WordArray.create([0x12345678]);

            var expected = message.toString();

            C.SHA3(message);

            Y.Assert.areEqual(expected, message.toString());
        },

        testHelper: function () {
            Y.Assert.areEqual(C.algo.SHA3.create({ outputLength: 256 }).finalize('').toString(), C.SHA3('', { outputLength: 256 }).toString());
        },

        testHmacHelper: function () {
            Y.Assert.areEqual(C.algo.HMAC.create(C.algo.SHA3, C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).finalize('Hi There').toString(), C.HmacSHA3('Hi There', C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).toString());
        }
    }));
}, '$Rev$');
YUI.add('algo-sha384-test', function (Y) {
    var C = CryptoJS;

    Y.Test.Runner.add(new Y.Test.Case({
        name: 'SHA384',

        testVector1: function () {
            Y.Assert.areEqual('38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b', C.SHA384('').toString());
        },

        testVector2: function () {
            Y.Assert.areEqual('ca737f1014a48f4c0b6dd43cb177b0afd9e5169367544c494011e3317dbf9a509cb1e5dc1e85a941bbee3d7f2afbc9b1', C.SHA384('The quick brown fox jumps over the lazy dog').toString());
        },

        testVector3: function () {
            Y.Assert.areEqual('ed892481d8272ca6df370bf706e4d7bc1b5739fa2177aae6c50e946678718fc67a7af2819a021c2fc34e91bdb63409d7', C.SHA384('The quick brown fox jumps over the lazy dog.').toString());
        },

        testUpdateAndLongMessage: function () {
            var sha384 = C.algo.SHA384.create();
            for (var i = 0; i < 100; i++) {
                sha384.update('12345678901234567890123456789012345678901234567890');
            }

            Y.Assert.areEqual('297a519246d6f639a4020119e1f03fc8d77171647b2ff75ea4125b7150fed0cdcc93f8dca1c3c6a624d5e88d780d82cd', sha384.finalize().toString());
        },

        testClone: function () {
            var sha384 = C.algo.SHA384.create();

            Y.Assert.areEqual(C.SHA384('a').toString(), sha384.update('a').clone().finalize().toString());
            Y.Assert.areEqual(C.SHA384('ab').toString(), sha384.update('b').clone().finalize().toString());
            Y.Assert.areEqual(C.SHA384('abc').toString(), sha384.update('c').clone().finalize().toString());
        },

        testInputIntegrity: function () {
            var message = C.lib.WordArray.create([0x12345678]);

            var expected = message.toString();

            C.SHA384(message);

            Y.Assert.areEqual(expected, message.toString());
        },

        testHelper: function () {
            Y.Assert.areEqual(C.algo.SHA384.create().finalize('').toString(), C.SHA384('').toString());
        },

        testHmacHelper: function () {
            Y.Assert.areEqual(C.algo.HMAC.create(C.algo.SHA384, C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).finalize('Hi There').toString(), C.HmacSHA384('Hi There', C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).toString());
        }
    }));
}, '$Rev$');
YUI.add('algo-sha512-profile', function (Y) {
    var C = CryptoJS;

    Y.Profiler.add({
        name: 'SHA512',

        profileSinglePartMessage: function () {
            var singlePartMessage = '';
            for (var i = 0; i < 500; i++) {
                singlePartMessage += '12345678901234567890123456789012345678901234567890';
            }

            C.algo.SHA512.create().finalize(singlePartMessage) + '';
        },

        profileMultiPartMessage: function () {
            var sha512 = C.algo.SHA512.create();
            for (var i = 0; i < 500; i++) {
                sha512.update('12345678901234567890123456789012345678901234567890');
            }
            sha512.finalize() + '';
        }
    });
}, '$Rev$');
YUI.add('algo-sha512-test', function (Y) {
    var C = CryptoJS;

    Y.Test.Runner.add(new Y.Test.Case({
        name: 'SHA512',

        testVector1: function () {
            Y.Assert.areEqual('cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e', C.SHA512('').toString());
        },

        testVector2: function () {
            Y.Assert.areEqual('07e547d9586f6a73f73fbac0435ed76951218fb7d0c8d788a309d785436bbb642e93a252a954f23912547d1e8a3b5ed6e1bfd7097821233fa0538f3db854fee6', C.SHA512('The quick brown fox jumps over the lazy dog').toString());
        },

        testVector3: function () {
            Y.Assert.areEqual('91ea1245f20d46ae9a037a989f54f1f790f0a47607eeb8a14d12890cea77a1bbc6c7ed9cf205e67b7f2b8fd4c7dfd3a7a8617e45f3c463d481c7e586c39ac1ed', C.SHA512('The quick brown fox jumps over the lazy dog.').toString());
        },

        testUpdateAndLongMessage: function () {
            var sha512 = C.algo.SHA512.create();
            for (var i = 0; i < 100; i++) {
                sha512.update('12345678901234567890123456789012345678901234567890');
            }

            Y.Assert.areEqual('9bc64f37c54606dff234b6607e06683c7ba248558d0ec74a11525d9f59e0be566489cc9413c00ca5e9db705fc52ba71214bcf118f65072fe284af8f8cf9500af', sha512.finalize().toString());
        },

        testClone: function () {
            var sha512 = C.algo.SHA512.create();

            Y.Assert.areEqual(C.SHA512('a').toString(), sha512.update('a').clone().finalize().toString());
            Y.Assert.areEqual(C.SHA512('ab').toString(), sha512.update('b').clone().finalize().toString());
            Y.Assert.areEqual(C.SHA512('abc').toString(), sha512.update('c').clone().finalize().toString());
        },

        testInputIntegrity: function () {
            var message = C.lib.WordArray.create([0x12345678]);

            var expected = message.toString();

            C.SHA512(message);

            Y.Assert.areEqual(expected, message.toString());
        },

        testHelper: function () {
            Y.Assert.areEqual(C.algo.SHA512.create().finalize('').toString(), C.SHA512('').toString());
        },

        testHmacHelper: function () {
            Y.Assert.areEqual(C.algo.HMAC.create(C.algo.SHA512, C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).finalize('Hi There').toString(), C.HmacSHA512('Hi There', C.enc.Hex.parse('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b')).toString());
        }
    }));
}, '$Rev$');
<!doctype html>
<html>
    <head>
        <meta charset="utf-8">
        <title>CryptoJS Test Suite</title>

        <!-- CryptoJS -->
        <script src="../build/crypto-js.js"></script>

        <!-- YUI -->
        <script src="http://yui.yahooapis.com/3.5.1/build/yui/yui-min.js"></script>

        <!-- Tests -->
        <script src="lib-base-test.js"></script>
        <script src="lib-wordarray-test.js"></script>
        <script src="lib-typedarrays-test.js"></script>
        <script src="x64-word-test.js"></script>
        <script src="x64-wordarray-test.js"></script>
        <script src="enc-hex-test.js"></script>
        <script src="enc-latin1-test.js"></script>
        <script src="enc-utf8-test.js"></script>
        <script src="enc-utf16-test.js"></script>
        <script src="enc-base64-test.js"></script>
        <script src="md5-test.js"></script>
        <script src="sha1-test.js"></script>
        <script src="sha256-test.js"></script>
        <script src="sha224-test.js"></script>
        <script src="sha512-test.js"></script>
        <script src="sha384-test.js"></script>
        <script src="sha3-test.js"></script>
        <script src="ripemd160-test.js"></script>
        <script src="hmac-md5-test.js"></script>
        <script src="hmac-sha224-test.js"></script>
        <script src="hmac-sha256-test.js"></script>
        <script src="hmac-sha384-test.js"></script>
        <script src="hmac-sha512-test.js"></script>
        <script src="pbkdf2-test.js"></script>
        <script src="evpkdf-test.js"></script>
        <script src="mode-cbc-test.js"></script>
        <script src="mode-cfb-test.js"></script>
        <script src="mode-ctr-test.js"></script>
        <script src="mode-ofb-test.js"></script>
        <script src="mode-ecb-test.js"></script>
        <script src="pad-pkcs7-test.js"></script>
        <script src="pad-ansix923-test.js"></script>
        <script src="pad-iso10126-test.js"></script>
        <script src="pad-zeropadding-test.js"></script>
        <script src="pad-iso97971-test.js"></script>
        <script src="lib-cipherparams-test.js"></script>
        <script src="format-openssl-test.js"></script>
        <script src="lib-serializablecipher-test.js"></script>
        <script src="kdf-openssl-test.js"></script>
        <script src="lib-passwordbasedcipher-test.js"></script>
        <script src="rc4-test.js"></script>
        <script src="rabbit-test.js"></script>
        <script src="rabbit-legacy-test.js"></script>
        <script src="cipher-test.js"></script>
        <script src="aes-test.js"></script>
        <script src="des-test.js"></script>
        <script src="tripledes-test.js"></script>

        <!-- Test runner -->
        <script>
            YUI().use('test', 'console', function (Y) {
                Y.use('*', function (Y) {
                    new Y.Console({
                        style: 'block',
                        width: '600px',
                        height: '600px',
                        entryTemplate:
                          '<div class="{entry_class} {cat_class} {src_class}">' +
                          '    <p class="{entry_meta_class}">' +
                          '        <span class="{entry_cat_class}">{category}</span>' +
                          '    </p>' +
                          '    <pre class="{entry_content_class}">{message}</pre>' +
                          '</div>',
                        newestOnTop: false,
                        consoleLimit: 500,
                        render: true
                    });

                    Y.Test.Runner.run();
                });
            });
        </script>

        <style>
            body.yui3-skin-sam .yui3-console-entry-meta,
            body.yui3-skin-sam .yui3-console-entry-content {
                display: inline-block;
                vertical-align: top;
            }
            body.yui3-skin-sam .yui3-console-entry-cat {
                display: inline-block;
                width: 35px;
                text-align: center;
            }
            body.yui3-skin-sam .yui3-console-entry {
                min-height: 0;
            }
        </style>
    </head>
    <body class="yui3-skin-sam">
    </body>
</html>
<!doctype html>
<html>
    <head>
        <meta charset="utf-8">
        <title>CryptoJS Test Suite</title>

        <!-- CryptoJS -->
        <script src="../src/core.js"></script>
        <script src="../src/lib-typedarrays.js"></script>
        <script src="../src/x64-core.js"></script>
        <script src="../src/enc-utf16.js"></script>
        <script src="../src/enc-base64.js"></script>
        <script src="../src/md5.js"></script>
        <script src="../src/sha1.js"></script>
        <script src="../src/sha256.js"></script>
        <script src="../src/sha224.js"></script>
        <script src="../src/sha512.js"></script>
        <script src="../src/sha384.js"></script>
        <script src="../src/sha3.js"></script>
        <script src="../src/ripemd160.js"></script>
        <script src="../src/hmac.js"></script>
        <script src="../src/pbkdf2.js"></script>
        <script src="../src/evpkdf.js"></script>
        <script src="../src/cipher-core.js"></script>
        <script src="../src/mode-cfb.js"></script>
        <script src="../src/mode-ctr.js"></script>
        <script src="../src/mode-ofb.js"></script>
        <script src="../src/mode-ecb.js"></script>
        <script src="../src/pad-ansix923.js"></script>
        <script src="../src/pad-iso10126.js"></script>
        <script src="../src/pad-zeropadding.js"></script>
        <script src="../src/pad-iso97971.js"></script>
        <script src="../src/pad-nopadding.js"></script>
        <script src="../src/rc4.js"></script>
        <script src="../src/rabbit.js"></script>
        <script src="../src/rabbit-legacy.js"></script>
        <script src="../src/aes.js"></script>
        <script src="../src/blowfish.js"></script>
        <script src="../src/tripledes.js"></script>

        <!-- YUI -->
        <script src="http://yui.yahooapis.com/3.5.1/build/yui/yui-min.js"></script>

        <!-- Tests -->
        <script src="lib-base-test.js"></script>
        <script src="lib-wordarray-test.js"></script>
        <script src="lib-typedarrays-test.js"></script>
        <script src="x64-word-test.js"></script>
        <script src="x64-wordarray-test.js"></script>
        <script src="enc-hex-test.js"></script>
        <script src="enc-latin1-test.js"></script>
        <script src="enc-utf8-test.js"></script>
        <script src="enc-utf16-test.js"></script>
        <script src="enc-base64-test.js"></script>
        <script src="md5-test.js"></script>
        <script src="sha1-test.js"></script>
        <script src="sha256-test.js"></script>
        <script src="sha224-test.js"></script>
        <script src="sha512-test.js"></script>
        <script src="sha384-test.js"></script>
        <script src="sha3-test.js"></script>
        <script src="ripemd160-test.js"></script>
        <script src="hmac-md5-test.js"></script>
        <script src="hmac-sha224-test.js"></script>
        <script src="hmac-sha256-test.js"></script>
        <script src="hmac-sha384-test.js"></script>
        <script src="hmac-sha512-test.js"></script>
        <script src="pbkdf2-test.js"></script>
        <script src="evpkdf-test.js"></script>
        <script src="mode-cbc-test.js"></script>
        <script src="mode-cfb-test.js"></script>
        <script src="mode-ctr-test.js"></script>
        <script src="mode-ofb-test.js"></script>
        <script src="mode-ecb-test.js"></script>
        <script src="pad-pkcs7-test.js"></script>
        <script src="pad-ansix923-test.js"></script>
        <script src="pad-iso10126-test.js"></script>
        <script src="pad-zeropadding-test.js"></script>
        <script src="pad-iso97971-test.js"></script>
        <script src="lib-cipherparams-test.js"></script>
        <script src="format-openssl-test.js"></script>
        <script src="lib-serializablecipher-test.js"></script>
        <script src="kdf-openssl-test.js"></script>
        <script src="lib-passwordbasedcipher-test.js"></script>
        <script src="rc4-test.js"></script>
        <script src="rabbit-test.js"></script>
        <script src="rabbit-legacy-test.js"></script>
        <script src="cipher-test.js"></script>
        <script src="aes-test.js"></script>
        <script src="des-test.js"></script>
        <script src="tripledes-test.js"></script>
        <script src="config-test.js"></script>
        <script src="blowfish-test.js"></script>

        <!-- Test runner -->
        <script>
            YUI().use('test', 'console', function (Y) {
                Y.use('*', function (Y) {
                    new Y.Console({
                        style: 'block',
                        width: '600px',
                        height: '600px',
                        entryTemplate:
                          '<div class="{entry_class} {cat_class} {src_class}">' +
                          '    <p class="{entry_meta_class}">' +
                          '        <span class="{entry_cat_class}">{category}</span>' +
                          '    </p>' +
                          '    <pre class="{entry_content_class}">{message}</pre>' +
                          '</div>',
                        newestOnTop: false,
                        consoleLimit: 500,
                        render: true
                    });

                    Y.Test.Runner.run();
                });
            });
        </script>

        <style>
            body.yui3-skin-sam .yui3-console-entry-meta,
            body.yui3-skin-sam .yui3-console-entry-content {
                display: inline-block;
                vertical-align: top;
            }
            body.yui3-skin-sam .yui3-console-entry-cat {
                display: inline-block;
                width: 35px;
                text-align: center;
            }
            body.yui3-skin-sam .yui3-console-entry {
                min-height: 0;
            }
        </style>
    </head>
    <body class="yui3-skin-sam">
    </body>
</html>
<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>CryptoJS Test Suite</title>

    <!-- CryptoJS -->
    <script src="../src/core.js"></script>
    <script src="../src/lib-typedarrays.js"></script>
    <script src="../src/x64-core.js"></script>
    <script src="../src/enc-utf16.js"></script>
    <script src="../src/enc-base64.js"></script>
    <script src="../src/enc-base64url.js"></script>
    <script src="../src/md5.js"></script>
    <script src="../src/sha1.js"></script>
    <script src="../src/sha256.js"></script>
    <script src="../src/sha224.js"></script>
    <script src="../src/sha512.js"></script>
    <script src="../src/sha384.js"></script>
    <script src="../src/sha3.js"></script>
    <script src="../src/ripemd160.js"></script>
    <script src="../src/hmac.js"></script>
    <script src="../src/pbkdf2.js"></script>
    <script src="../src/evpkdf.js"></script>
    <script src="../src/cipher-core.js"></script>
    <script src="../src/mode-cfb.js"></script>
    <script src="../src/mode-ctr.js"></script>
    <script src="../src/mode-ofb.js"></script>
    <script src="../src/mode-ecb.js"></script>
    <script src="../src/pad-ansix923.js"></script>
    <script src="../src/pad-iso10126.js"></script>
    <script src="../src/pad-zeropadding.js"></script>
    <script src="../src/pad-iso97971.js"></script>
    <script src="../src/pad-nopadding.js"></script>
    <script src="../src/rc4.js"></script>
    <script src="../src/rabbit.js"></script>
    <script src="../src/rabbit-legacy.js"></script>
    <script src="../src/aes.js"></script>
    <script src="../src/tripledes.js"></script>


    <!-- Test runner -->
    <script>
      var message = "152999073894506063@http://localhost:3000/protected/index@89effb07-588e-4bf4-ba16-c10b2a136ae9@1553508995647";
      var key = "u-rXsMB_aegAnzC_CJt27plLGNqOfR2EHI5o2ro1NO";
      var baseKey = CryptoJS.enc.Base64url.parse(key);
      console.log("key："+baseKey.toString());
      var hash = CryptoJS.HmacSHA256(message, baseKey);
      var hashInBase64 = CryptoJS.enc.Base64url.stringify(hash);
      document.write(hashInBase64);
      document.write("\n");
      var shashInBase64 = CryptoJS.enc.Base64url.stringify(hash);
      console.log("result："+hash.toString())
      document.write(shashInBase64);
      console.log("done："+shashInBase64);
      var url = 'http://www.ctyun.cn/serviceValidate?service=http://localhost:3000/protected/index&ticket=89effb07-588e-4bf4-ba16-c10b2a136ae9&timestamp=1553508995647&appId=152999073894506063&signature=evvc3Ix87nk-KkuIaQJrLP7Vu76dTsh-BwnC6AHXFfU'
    </script>


</head>
<body>
</body>
</html>
YUI.add('algo-tripledes-profile', function (Y) {
    var C = CryptoJS;

    Y.Profiler.add({
        name: 'TripleDES',

        setUp: function () {
            this.data = {
                key: C.enc.Hex.parse('0001020304050607'),
                iv: C.enc.Hex.parse('08090a0b0c0d0e0f')
            };
        },

        profileSinglePartMessage: function () {
            var singlePartMessage = '';
            for (var i = 0; i < 100; i++) {
                singlePartMessage += '12345678901234567890123456789012345678901234567890';
            }

            C.algo.TripleDES.createEncryptor(this.data.key, { iv: this.data.iv }).finalize(singlePartMessage) + '';
        },

        profileMultiPartMessage: function () {
            var des = C.algo.TripleDES.createEncryptor(this.data.key, { iv: this.data.iv });
            for (var i = 0; i < 100; i++) {
                des.process('12345678901234567890123456789012345678901234567890') + '';
            }
            des.finalize() + '';
        }
    });
}, '$Rev$');
YUI.add('algo-tripledes-test', function (Y) {
    var C = CryptoJS;

    Y.Test.Runner.add(new Y.Test.Case({
        name: 'TripleDES',

        testEncrypt1: function () {
            Y.Assert.areEqual('95a8d72813daa94d', C.TripleDES.encrypt(C.enc.Hex.parse('0000000000000000'), C.enc.Hex.parse('800101010101010180010101010101018001010101010101'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).ciphertext.toString());
        },

        testEncrypt2: function () {
            Y.Assert.areEqual('869efd7f9f265a09', C.TripleDES.encrypt(C.enc.Hex.parse('0000000000000000'), C.enc.Hex.parse('010101010101010201010101010101020101010101010102'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).ciphertext.toString());
        },

        testEncrypt3: function () {
            Y.Assert.areEqual('95f8a5e5dd31d900', C.TripleDES.encrypt(C.enc.Hex.parse('8000000000000000'), C.enc.Hex.parse('010101010101010101010101010101010101010101010101'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).ciphertext.toString());
        },

        testEncrypt4: function () {
            Y.Assert.areEqual('166b40b44aba4bd6', C.TripleDES.encrypt(C.enc.Hex.parse('0000000000000001'), C.enc.Hex.parse('010101010101010101010101010101010101010101010101'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).ciphertext.toString());
        },

        testDecrypt1: function () {
            Y.Assert.areEqual('0000000000000000', C.TripleDES.decrypt(C.lib.CipherParams.create({ ciphertext: C.enc.Hex.parse('95a8d72813daa94d') }), C.enc.Hex.parse('800101010101010180010101010101018001010101010101'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString());
        },

        testDecrypt2: function () {
            Y.Assert.areEqual('0000000000000000', C.TripleDES.decrypt(C.lib.CipherParams.create({ ciphertext: C.enc.Hex.parse('869efd7f9f265a09') }), C.enc.Hex.parse('010101010101010201010101010101020101010101010102'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString());
        },

        testDecrypt3: function () {
            Y.Assert.areEqual('8000000000000000', C.TripleDES.decrypt(C.lib.CipherParams.create({ ciphertext: C.enc.Hex.parse('95f8a5e5dd31d900') }), C.enc.Hex.parse('010101010101010101010101010101010101010101010101'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString());
        },

        testDecrypt4: function () {
            Y.Assert.areEqual('0000000000000001', C.TripleDES.decrypt(C.lib.CipherParams.create({ ciphertext: C.enc.Hex.parse('166b40b44aba4bd6') }), C.enc.Hex.parse('010101010101010101010101010101010101010101010101'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString());
        },

        testMultiPart: function () {
            var des = C.algo.TripleDES.createEncryptor(C.enc.Hex.parse('000102030405060708090a0b0c0d0e0f1011121314151617'), { mode: C.mode.ECB, padding: C.pad.NoPadding });
            var ciphertext1 = des.process(C.enc.Hex.parse('001122334455'));
            var ciphertext2 = des.process(C.enc.Hex.parse('66778899aa'));
            var ciphertext3 = des.process(C.enc.Hex.parse('bbccddeeff'));
            var ciphertext4 = des.finalize();

            Y.Assert.areEqual(C.TripleDES.encrypt(C.enc.Hex.parse('00112233445566778899aabbccddeeff'), C.enc.Hex.parse('000102030405060708090a0b0c0d0e0f1011121314151617'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).ciphertext.toString(), ciphertext1.concat(ciphertext2).concat(ciphertext3).concat(ciphertext4).toString());
        },

        testInputIntegrity: function () {
            var message = C.enc.Hex.parse('00112233445566778899aabbccddeeff');
            var key = C.enc.Hex.parse('000102030405060708090a0b0c0d0e0f1011121314151617');
            var iv = C.enc.Hex.parse('08090a0b0c0d0e0f');

            var expectedMessage = message.toString();
            var expectedKey = key.toString();
            var expectedIv = iv.toString();

            C.TripleDES.encrypt(message, key, { iv: iv });

            Y.Assert.areEqual(expectedMessage, message.toString());
            Y.Assert.areEqual(expectedKey, key.toString());
            Y.Assert.areEqual(expectedIv, iv.toString());
        },

        test64BitKey: function() {
            var message = C.enc.Hex.parse('00112233445566778899aabbccddeeff');
            var key = C.enc.Hex.parse('0011223344556677');
            var extendedKey = C.enc.Hex.parse('001122334455667700112233445566770011223344556677')
            
            var output1 = C.TripleDES.encrypt(message, key, { mode: C.mode.ECB }).toString();
            var output2 = C.TripleDES.encrypt(message, extendedKey, { mode: C.mode.ECB }).toString();

            Y.Assert.areEqual(output1, output2);
        },

        test128BitKey: function() {
            var message = C.enc.Hex.parse('00112233445566778899aabbccddeeff');
            var key = C.enc.Hex.parse('00112233445566778899aabbccddeeff');
            var extendedKey = C.enc.Hex.parse('00112233445566778899aabbccddeeff0011223344556677')
            
            var output1 = C.TripleDES.encrypt(message, key, { mode: C.mode.ECB }).toString();
            var output2 = C.TripleDES.encrypt(message, extendedKey, { mode: C.mode.ECB }).toString();

            Y.Assert.areEqual(output1, output2);
        },

        test256BitKey: function() {
            var message = C.enc.Hex.parse('00112233445566778899aabbccddeeff');
            var key = C.enc.Hex.parse('00112233445566778899aabbccddeeff0112233445566778899aabbccddeeff0');
            var truncatedKey = C.enc.Hex.parse('00112233445566778899aabbccddeeff0112233445566778')
            
            var output1 = C.TripleDES.encrypt(message, key, { mode: C.mode.ECB }).toString();
            var output2 = C.TripleDES.encrypt(message, truncatedKey, { mode: C.mode.ECB }).toString();

            Y.Assert.areEqual(output1, output2);
        },

        testHelper: function () {
            // Save original random method
            var random = C.lib.WordArray.random;

            // Replace random method with one that returns a predictable value
            C.lib.WordArray.random = function (nBytes) {
                var words = [];
                for (var i = 0; i < nBytes; i += 4) {
                    words.push([0x11223344]);
                }

                return C.lib.WordArray.create(words, nBytes);
            };

            // Test
            Y.Assert.areEqual(C.algo.TripleDES.createEncryptor(C.SHA256('Jefe'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).finalize('Hi There').toString(), C.TripleDES.encrypt('Hi There', C.SHA256('Jefe'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).ciphertext.toString());
            Y.Assert.areEqual(C.lib.SerializableCipher.encrypt(C.algo.TripleDES, 'Hi There', C.SHA256('Jefe'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString(), C.TripleDES.encrypt('Hi There', C.SHA256('Jefe'), { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString());
            Y.Assert.areEqual(C.lib.PasswordBasedCipher.encrypt(C.algo.TripleDES, 'Hi There', 'Jefe', { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString(), C.TripleDES.encrypt('Hi There', 'Jefe', { mode: C.mode.ECB, padding: C.pad.NoPadding }).toString());

            // Restore random method
            C.lib.WordArray.random = random;
        }
    }));
}, '$Rev$');
YUI.add('x64-word-test', function (Y) {
    var C = CryptoJS;

    Y.Test.Runner.add(new Y.Test.Case({
        name: 'X64Word',

        testInit: function () {
            var word = C.x64.Word.create(0x00010203, 0x04050607);

            Y.Assert.areEqual(0x00010203, word.high, 'word.high');
            Y.Assert.areEqual(0x04050607, word.low, 'word.low');
        }

        // testNot: function () {
            // var word = C.x64.Word.create(0x00010203, 0x04050607).not();

            // Y.Assert.areEqual(~0x00010203, word.high, 'word.high');
            // Y.Assert.areEqual(~0x04050607, word.low, 'word.low');
        // },

        // testAnd: function () {
            // var word1 = C.x64.Word.create(0x00010203, 0x04050607);
            // var word2 = C.x64.Word.create(0x18191a1b, 0x1c1d1e1f);
            // var anded = word1.and(word2);

            // Y.Assert.areEqual(0x00010203 & 0x18191a1b, anded.high, 'word.high');
            // Y.Assert.areEqual(0x04050607 & 0x1c1d1e1f, anded.low, 'word.low');
        // },

        // testOr: function () {
            // var word1 = C.x64.Word.create(0x00010203, 0x04050607);
            // var word2 = C.x64.Word.create(0x18191a1b, 0x1c1d1e1f);
            // var ored = word1.or(word2);

            // Y.Assert.areEqual(0x00010203 | 0x18191a1b, ored.high, 'word.high');
            // Y.Assert.areEqual(0x04050607 | 0x1c1d1e1f, ored.low, 'word.low');
        // },

        // testXor: function () {
            // var word1 = C.x64.Word.create(0x00010203, 0x04050607);
            // var word2 = C.x64.Word.create(0x18191a1b, 0x1c1d1e1f);
            // var xored = word1.xor(word2);

            // Y.Assert.areEqual(0x00010203 ^ 0x18191a1b, xored.high, 'word.high');
            // Y.Assert.areEqual(0x04050607 ^ 0x1c1d1e1f, xored.low, 'word.low');
        // },

        // testShiftL25: function () {
            // var word = C.x64.Word.create(0x00010203, 0x04050607).shiftL(25);

            // Y.Assert.areEqual(0x06080a0c, word.high, 'word.high');
            // Y.Assert.areEqual(0x0e000000, word.low, 'word.low');
        // },

        // testShiftL32: function () {
            // var word = C.x64.Word.create(0x00010203, 0x04050607).shiftL(32);

            // Y.Assert.areEqual(0x04050607, word.high, 'word.high');
            // Y.Assert.areEqual(0x00000000, word.low, 'word.low');
        // },

        // testShiftR7: function () {
            // var word = C.x64.Word.create(0x00010203, 0x04050607).shiftR(7);

            // Y.Assert.areEqual(0x00000204, word.high, 'word.high');
            // Y.Assert.areEqual(0x06080A0C, word.low, 'word.low');
        // },

        // testShiftR32: function () {
            // var word = C.x64.Word.create(0x00010203, 0x04050607).shiftR(32);

            // Y.Assert.areEqual(0x00000000, word.high, 'word.high');
            // Y.Assert.areEqual(0x00010203, word.low, 'word.low');
        // },

        // testRotL: function () {
            // var word = C.x64.Word.create(0x00010203, 0x04050607).rotL(25);

            // Y.Assert.areEqual(0x06080a0c, word.high, 'word.high');
            // Y.Assert.areEqual(0x0e000204, word.low, 'word.low');
        // },

        // testRotR: function () {
            // var word = C.x64.Word.create(0x00010203, 0x04050607).rotR(7);

            // Y.Assert.areEqual(0x0e000204, word.high, 'word.high');
            // Y.Assert.areEqual(0x06080a0c, word.low, 'word.low');
        // },

        // testAdd: function () {
            // var word1 = C.x64.Word.create(0x00010203, 0x04050607);
            // var word2 = C.x64.Word.create(0x18191a1b, 0x1c1d1e1f);
            // var added = word1.add(word2);

            // Y.Assert.areEqual(0x181a1c1e, added.high, 'word.high');
            // Y.Assert.areEqual(0x20222426, added.low, 'word.low');
        // }
    }));
}, '$Rev$');
YUI.add('x64-wordarray-test', function (Y) {
    var C = CryptoJS;

    Y.Test.Runner.add(new Y.Test.Case({
        name: 'X64WordArray',

        testInit0: function () {
            Y.Assert.areEqual('', C.x64.WordArray.create().toX32().toString());
        },

        testInit1: function () {
            var wordArray = C.x64.WordArray.create([
                C.x64.Word.create(0x00010203, 0x04050607),
                C.x64.Word.create(0x18191a1b, 0x1c1d1e1f)
            ]);

            Y.Assert.areEqual('000102030405060718191a1b1c1d1e1f', wordArray.toX32().toString());
        },

        testInit2: function () {
            var wordArray = C.x64.WordArray.create([
                C.x64.Word.create(0x00010203, 0x04050607),
                C.x64.Word.create(0x18191a1b, 0x1c1d1e1f)
            ], 10);

            Y.Assert.areEqual('00010203040506071819', wordArray.toX32().toString());
        },

        testToX32: function () {
            var wordArray = C.x64.WordArray.create([
                C.x64.Word.create(0x00010203, 0x04050607),
                C.x64.Word.create(0x18191a1b, 0x1c1d1e1f)
            ], 10);

            Y.Assert.areEqual('00010203040506071819', wordArray.toX32().toString());
        }
    }));
}, '$Rev$');