Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
crypto-subtle and md5
(version: 0)
Comparing performance of:
Crypto.js vs window.crypto SHA-256 vs MD5 crypto vs md5 js
Created:
3 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src="https://cdnjs.cloudflare.com/ajax/libs/sjcl/1.0.6/sjcl.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.9-1/crypto-js.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:
Crypto.js
CryptoJS.SHA256(data);
window.crypto SHA-256
crypto.subtle.digest("SHA-256", dataBuffer ).then(function (hash) {console.log(hex(hash));});
MD5 crypto
crypto.subtle.digest("SHA-256", dataBuffer ).then(function (hash) {console.log(hex(hash));});
md5 js
CryptoJS.MD5(data);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
Crypto.js
window.crypto SHA-256
MD5 crypto
md5 js
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:132.0) Gecko/20100101 Firefox/132.0
Browser/OS:
Firefox 132 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Crypto.js
27906.8 Ops/sec
window.crypto SHA-256
473623.2 Ops/sec
MD5 crypto
471809.9 Ops/sec
md5 js
24739.4 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's break down the provided benchmark JSON and explain what's being tested. **Benchmark Definition** The benchmark defines four test cases: 1. `Crypto.js`: This test case uses the `CryptoJS` library to compute the SHA-256 hash of a input data. 2. `window.crypto SHA-256`: This test case uses the Web Cryptography API (`crypto.subtle`) to compute the SHA-256 hash of an input data. 3. `MD5 crypto`: This test case uses the `crypto.subtle` API to compute the MD5 hash of an input data, which is similar to SHA-256 but has a different algorithm. 4. `md5 js`: This test case uses a custom implementation of the MD5 algorithm from the `crypto-js` library. **Options compared** The benchmark compares the performance of each test case: * `Crypto.js` vs. `window.crypto SHA-256` * `window.crypto SHA-256` vs. `MD5 crypto` * `window.crypto SHA-256` vs. `md5 js` **Pros and Cons** Here's a brief summary of the pros and cons of each approach: 1. **Crypto.js**: * Pros: Easy to use, widely supported, and well-maintained. * Cons: May not be as efficient as native implementations or Web Cryptography API. 2. **window.crypto SHA-256**: * Pros: Native implementation, highly optimized, and secure. * Cons: Requires modern browsers with Web Cryptography support. 3. **MD5 crypto**: * Pros: Similar to SHA-256 but may be faster due to its smaller algorithm size. * Cons: Not as widely supported or secure as SHA-256. 4. **md5 js**: * Pros: Easy to use, widely available, and well-maintained. * Cons: May not be as efficient as native implementations or Web Cryptography API. **Library and purpose** The `crypto-js` library is a JavaScript library that provides a wide range of cryptographic functions, including hashing. The library aims to simplify the process of working with cryptography in web applications. The `crypto.subtle` API is a part of the Web Cryptography API, which provides a way for web developers to use cryptographic primitives like hash functions, encryption, and digital signatures in their applications. **Special JS features** No special JavaScript features are mentioned in this benchmark.
Related benchmarks:
Sha256
Sha256
crypto-subtle
dsha256
Comments
Confirm delete:
Do you really want to delete benchmark?