CryptoJS vs Google Closure vs SJCL (v4)

Revision 4 of this benchmark created on


Preparation HTML

<script src='http://crypto.stanford.edu/sjcl/sjcl.js'></script>
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/aes.js"></script>
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/components/mode-ctr.js"></script>
<script src="https://closure-library.googlecode.com/git/closure/goog/base.js"></script>

<script>
   goog.require('goog.crypt');
   goog.require('goog.crypt.Aes');
   goog.require('goog.crypt.Cbc');
   goog.require('goog.crypt.pbkdf2');
</script>

<script>
   var encrypted, inputArr, keyphrase, iv, salt, key, aes, cbc;
   var testData = new Array(1024 * 1024 * 1);

   var i = 0;
   for (i = 0; i < (1024 * 1024 * 1); i++) {
     testData[i] = i % 10;
   }
   testText = testData.join('');
   inputArr = goog.crypt.stringToByteArray(testText);
   keyphrase = goog.crypt.stringToByteArray('password');
   iv = goog.crypt.stringToByteArray('aaaaaaaaaaaaaaaa');
   salt = goog.crypt.stringToByteArray('aaaaaaaaaaa');
   key = goog.crypt.pbkdf2.deriveKeySha1(keyphrase, salt, 4096, 128);
   aes = new goog.crypt.Aes(key);
   cbc = new goog.crypt.Cbc(aes);
   CryptoJS.algo.AES.keySize = 128/32;
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
CryptoJS
encrypted = CryptoJS.AES.encrypt(testText, "password");
ready
Google Closure
encrypted = cbc.encrypt(inputArr, iv);
ready
SJCL
encrypted = sjcl.encrypt('password', testText);
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.