CryproJS md5 & sha1 vs utility

JavaScript performance comparison

Revision 11 of this test case created by Xotic750

Preparation code

<script src="https://rghost.net/download/44837075/15039be7f14ad3251d64db75075a9c31d3eecb96/utility3.js">
</script>
<script src="https://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/md5.js">
</script>
<script src="https://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/sha1.js">
</script>
<script src="https://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/sha256.js">
</script>
<script src="https://tiny-sha1.googlecode.com/files/tinySHA1.r4.js">
</script>
<script src="https://bitbucket.org/keesey/sha1/raw/fcbee69dcc6f6e9038e7d78376ab207e0816896a/bin/sha1.js">
</script>
<script src="https://www.movable-type.co.uk/scripts/utf8.js"></script>
<script src="https://www.movable-type.co.uk/scripts/sha1.js">
</script>
<script src="https://www.movable-type.co.uk/scripts/sha256.js">
</script>

<script>
  var s = "",
      a = [];

  $u.range(0, 9).forEach(function() {
    a.push(s);
  });

  $u.range(1, 257).forEach(function(part) {
    s = "";
    $u.range(0, 255).forEach(function(character) {
      s += String.fromCharCode(part * character);
    });

    a.push(s);
  });

  a.push(a.join(''));
</script>
    

Preparation code output

<script src="https://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/md5.js"> </script> <script src="https://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/sha1.js"> </script> <script src="https://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/sha256.js"> </script> <script src="https://tiny-sha1.googlecode.com/files/tinySHA1.r4.js"> </script> <script src="https://bitbucket.org/keesey/sha1/raw/fcbee69dcc6f6e9038e7d78376ab207e0816896a/bin/sha1.js"> </script> <script src="https://www.movable-type.co.uk/scripts/utf8.js"></script> <script src="https://www.movable-type.co.uk/scripts/sha1.js"> </script> <script src="https://www.movable-type.co.uk/scripts/sha256.js"> </script> <script> var s = "", a = []; $u.range(0, 9).forEach(function() { a.push(s); }); $u.range(1, 257).forEach(function(part) { s = ""; $u.range(0, 255).forEach(function(character) { s += String.fromCharCode(part * character); }); a.push(s); }); a.push(a.join('')); </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
utility sha1
a.forEach(function(str) {
  $u.sha1(str);
});
pending…
CryptoJs sha1
a.forEach(function(str) {
  CryptoJS.SHA1(str).toString();
});
pending…
CryptoJs md5
a.forEach(function(str) {
  CryptoJS.MD5(str).toString();
});
pending…
utility md5
a.forEach(function(str) {
  $u.md5(str);
});
pending…
tiny sha1
a.forEach(function(str) {
  SHA1(str);
});
pending…
movable-type sha1
a.forEach(function(str) {
  sha1.hash(str, true);
});
pending…
other sha1
a.forEach(function(str) {
  sha1.hash(str);
});
pending…
CryptoJs sha256
a.forEach(function(str) {
  CryptoJS.SHA256(str).toString();
});
pending…
utility sha256
a.forEach(function(str) {
  $u.sha256(str);
});
pending…
movable-type sha256
a.forEach(function(str) {
  Sha256.hash(str, true);
});
pending…
CryptoJs md5 w xtra utf8
a.forEach(function(str) {
  CryptoJS.MD5($u.utf8Encode(str)).toString();
});
pending…
CryptoJs sha1 w xtra utf8
a.forEach(function(str) {
  CryptoJS.SHA1($u.utf8Encode(str)).toString();
});
pending…
CryptoJs sha256 w xtra utf8
a.forEach(function(str) {
  CryptoJS.SHA256($u.utf8Encode(str)).toString();
});
pending…
utf8 sw1 vs sw2 check
a.forEach(function(str, index) {
  var sw1 = Utf8.encode(str),
      sw2 = $u.utf8Encode(str);

  if (sw1 !== sw2) {
    console.error(index, [str, sw1, sw2]);
    throw new Error("index: " + index + "  sw1: " + sw1 + "   sw2: " + sw2);
  }
});
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