sha256

JavaScript performance comparison

Revision 25 of this test case created by vibornoff

Info

Same as original, but processing 200Kb of preencoded text.

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="http://www.bichlmeier.info/sha256.js"></script>
<script src="http://www.webtoolkit.info/djs/webtoolkit.sha256.js"></script>
<script src="http://www.movable-type.co.uk/scripts/utf8.js"></script>
<script src="http://www.movable-type.co.uk/scripts/sha256.js"></script>
<script src="http://crypto-js.googlecode.com/files/2.2.0-crypto-sha256.js"></script>
<script src="http://point-at-infinity.org/jssha256/jssha256.js"></script>
<script src="http://code.alexweber.com.br/jquery/sha256/jquery.sha256.js"></script>
<script src="http://crypto.stanford.edu/sjcl/sjcl.js"></script>
<script src="http://vibornoff.com/sha256.js"></script>

<script>
  var digest;
</script>
<script>
Benchmark.prototype.setup = function() {
    var SIZE = 200 * 1024; // 200K
    var chunk = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus in risus non augue vestibulum semper. Nullam feugiat tortor sit amet dolor venenatis ultricies. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Pellentesque imperdiet ullamcorper ullamcorper. Aliquam eget nunc a diam dapibus ultricies. In hac habitasse platea dictumst. Curabitur nec tortor nibh, fermentum molestie massa. Vestibulum volutpat gravida nisl, vitae viverra eros bibendum a. Vestibulum sed felis arcu, et volutpat leo. Praesent semper, nibh et suscipit auctor, magna enim lacinia diam, id tristique arcu nunc at odio. Nunc vitae est risus, nec placerat velit. Ut rutrum fringilla consectetur. Fusce rutrum dui aliquet ligula suscipit aliquam. Mauris tincidunt, lacus ut suscipit sodales, justo magna accumsan justo, id tristique massa odio semper enim.';
   
    var input = chunk;
    while (input.length < SIZE) input += chunk;
    input = utf8Encode(input);
   
    var buffer = new Uint8Array(input.length);
    for (var i=0; i<input.length; i++) buffer[i] = input.charCodeAt(i);
   
    function utf8Encode(str) {
        return window.unescape(window.encodeURIComponent(str));
    }
};
</script>

Preparation code output

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
bichlmeier
digest = sha256_digest(input);
pending…
webtoolkit
digest = SHA256(input);
pending…
movable-type.co.uk
digest = Sha256.hash(input);
pending…
crypto-js
digest = Crypto.SHA256(input);
pending…
Poettering
digest = SHA256_hash(input);
pending…
Weber
digest = $.sha256(input);
pending…
sjcl
digest = sjcl.hash.sha256.hash(input);
pending…
Typed Arrays
digest = (new testCrypto.sha256).process(buffer).finish().hex();
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. Here’s a list of current revisions for this page:

0 comments

Add a comment