HTML Preparation code:
AخA
 
1
<script src="https://cdnjs.cloudflare.com/ajax/libs/sjcl/1.0.6/sjcl.min.js"></script>
2
<script 
3
src="https://cdnjs.cloudflare.com/ajax/libs/cryptico/0.0.1343522940/cryptico.min.js"></script>
4
<script
5
 src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.9-1/crypto-js.min.js"></script>
6
<script
7
 src="https://cdnjs.cloudflare.com/ajax/libs/forge/0.9.1/forge.min.js"></script>
Script Preparation code:
 
var data = new Uint32Array(1024);
  window.crypto.getRandomValues(data);
  var dataBuffer = new Uint8Array(data);
  data = String.fromCharCode.apply(null, dataBuffer);
  
  
  // src: https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest
  function hex(buffer) {
    var hexCodes = [];
    var view = new DataView(buffer);
    for (var i = 0; i < view.byteLength; i += 4) {
      // Using getUint32 reduces the number of iterations needed (we process 4 bytes each time)
      var value = view.getUint32(i)
      // toString(16) will give the hex representation of the number without padding
      var stringValue = value.toString(16)
      // We use concatenation and slice for padding
      var padding = '00000000'
      var paddedValue = (padding + stringValue).slice(-padding.length)
      hexCodes.push(paddedValue);
    }
  
    // Join all the hex strings into one
    return hexCodes.join("");
  }
Tests:
  • forge

     
    forge.md.sha256.create().update(data).digest()
  • native

     
    crypto.subtle.digest("SHA-256", dataBuffer ).then(function (hash) {console.log(hex(hash));});
  • sjcl

     
    sjcl.hash.sha256.hash(data);
  • crypto

     
    CryptoJS.SHA256(data);
  • cryptico

     
    SHA256(data);
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    forge
    native
    sjcl
    crypto
    cryptico

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 4 days ago)
Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Mobile Safari/537.36
Chrome Mobile 135 on Android
View result in a separate tab
Test name Executions per second
forge 36113.7 Ops/sec
native 31516.2 Ops/sec
sjcl 13161.2 Ops/sec
crypto 12195.5 Ops/sec
cryptico 5819.7 Ops/sec