SHA256 (v5)

Revision 5 of this benchmark created on


Description

SHA256 Performance

Preparation HTML

<script src="https://cdn.jsdelivr.net/gh/emn178/js-sha256/build/sha256.min.js"></script>
<script>
async function subtleCryptoSha256(message) {
  const msgUint8 = new TextEncoder().encode(message);
  const hashBuffer = await crypto.subtle.digest("SHA-256", msgUint8);
  const hashArray = Array.from(new Uint8Array(hashBuffer));
  const hashHex = hashArray
    .map((b) => b.toString(16).padStart(2, "0"))
    .join("");
  return hashHex;
}
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.1.1/crypto-js.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.1.1/hmac-sha256.min.js"></script>

Setup

var str = 'The quick brown fox jumps over the lazy dog';

Test runner

Ready to run.

Testing in
TestOps/sec
js-sha256
sha256(str);
ready
SubtleCrypto
subtleCryptoSha256(str);
ready
CryptoJS
CryptoJS.SHA256(str).toString();
ready

Revisions

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