PBKDF2

JavaScript performance comparison

Revision 18 of this test case created by

Preparation code

<script src="http://anandam.name/pbkdf2/sha1.js">
</script>
<script src="http://anandam.name/pbkdf2/pbkdf2.js">
</script>
<script src="http://rawgithub.com/bitwiseshiftleft/sjcl/version-0.8/sjcl.js">
</script>
<script src="http://rawgithub.com/bitwiseshiftleft/sjcl/master/core/sha1.js">
</script>
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/pbkdf2.js">
</script>
<script>
  var hmacSHA1 = function(key) {
      var hasher = new sjcl.misc.hmac(key, sjcl.hash.sha1);
      this.encrypt = function() {
        return hasher.encrypt.apply(hasher, arguments);
      };
      };

  // from http://stackoverflow.com/questions/3745666/

  function hex2a(hex) {
    var str = '';
    for (var i = 0; i < hex.length; i += 2)
    str += String.fromCharCode(parseInt(hex.substr(i, 2), 16));
    return str;
  }

  var iterations = 1000;
  var password = 'password';
  var hexSalt = '29EEE7AA9C0E9315';
  var keySizeBits = 128;
  var sjclSalt = sjcl.codec.hex.toBits(hexSalt);
  var cryptoSalt = CryptoJS.enc.Hex.parse(hexSalt);
  var anandamSalt = hex2a(hexSalt);
</script>
    

Preparation code output

<script src="http://anandam.name/pbkdf2/pbkdf2.js"> </script> <script src="http://rawgithub.com/bitwiseshiftleft/sjcl/version-0.8/sjcl.js"> </script> <script src="http://rawgithub.com/bitwiseshiftleft/sjcl/master/core/sha1.js"> </script> <script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/pbkdf2.js"> </script> <script> var hmacSHA1 = function(key) { var hasher = new sjcl.misc.hmac(key, sjcl.hash.sha1); this.encrypt = function() { return hasher.encrypt.apply(hasher, arguments); }; }; // from http://stackoverflow.com/questions/3745666/ function hex2a(hex) { var str = ''; for (var i = 0; i < hex.length; i += 2) str += String.fromCharCode(parseInt(hex.substr(i, 2), 16)); return str; } var iterations = 1000; var password = 'password'; var hexSalt = '29EEE7AA9C0E9315'; var keySizeBits = 128; var sjclSalt = sjcl.codec.hex.toBits(hexSalt); var cryptoSalt = CryptoJS.enc.Hex.parse(hexSalt); var anandamSalt = hex2a(hexSalt); </script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
SJCL 0.8
sjcl.misc.pbkdf2(password, sjclSalt, iterations, keySizeBits, hmacSHA1);
pending…
CryptoJS 3.1.2
CryptoJS.PBKDF2(password, cryptoSalt, {
  keySize: keySizeBits / 32,
  iterations: iterations
});
pending…
Anandam 1.4
// async test
var pbkdf2 = new PBKDF2(password, anandamSalt, iterations, keySizeBits / 8);
pbkdf2.deriveKey(function() {}, function() {
  deferred.resolve()
});
pending…

Compare results of other browsers

Revisions

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

0 Comments