Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Sha256
(version: 0)
Comparing performance of:
Cryptico vs Crypto.js vs sjcl vs window.crypto
Created:
9 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/cryptico/0.0.1343522940/cryptico.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:
Cryptico
SHA256(data);
Crypto.js
CryptoJS.SHA256(data);
sjcl
sjcl.hash.sha256.hash(data);
window.crypto
crypto.subtle.digest("SHA-256", dataBuffer ).then(function (hash) {console.log(hex(hash));});
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
Cryptico
Crypto.js
sjcl
window.crypto
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
21 days ago
)
User agent:
Mozilla/5.0 (X11; Linux x86_64; rv:140.0) Gecko/20100101 Firefox/140.0
Browser/OS:
Firefox 140 on Linux
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Cryptico
3582.5 Ops/sec
Crypto.js
20457.8 Ops/sec
sjcl
18386.4 Ops/sec
window.crypto
257294.9 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's break down the provided JSON data and explain what is being tested in each benchmark. **Benchmark Definition** The benchmark definition is a script that generates a SHA-256 hash of a given input `data`. The script uses a combination of Web APIs to perform this task. Here's a brief overview: 1. A `Uint32Array` is created with 1024 elements, and random values are generated using the `window.crypto.getRandomValues()` method. 2. The generated array is converted to a `Uint8Array`, which represents the input data for the hash calculation. 3. The `String.fromCharCode.apply(null, dataBuffer)` expression converts the `Uint8Array` to a string representation of the data. **Options Compared** The benchmark compares four different libraries/libraries and their implementations for SHA-256 hashing: 1. **Cryptico**: This library provides an implementation of the SHA-256 algorithm using the Web Cryptography API. 2. **Crypto.js**: This library provides an implementation of various cryptographic algorithms, including SHA-256. It uses a proprietary algorithm that is not based on the Web Cryptography API. 3. **sjcl** (Simple JavaScript Crypto Library): This library provides an implementation of various cryptographic algorithms, including SHA-256. It uses the Web Cryptography API to perform hash calculations. 4. **window.crypto**: This option uses the Web Cryptography API to perform a SHA-256 digest calculation. **Pros and Cons** Here are some pros and cons for each option: 1. **Cryptico**: * Pros: Fast performance, easy to use, and provides a secure implementation of SHA-256. * Cons: May require additional setup for Web Cryptography API support. 2. **Crypto.js**: * Pros: Fast performance, widely supported, and provides a comprehensive cryptographic library. * Cons: Proprietary algorithm, may not be as secure as other options. 3. **sjcl**: * Pros: Fast performance, easy to use, and provides a secure implementation of SHA-256 using the Web Cryptography API. * Cons: May require additional setup for Web Cryptography API support. 4. **window.crypto**: * Pros: Secure, fast performance, and widely supported. * Cons: May have limitations in terms of browser support or specific use cases. **Libraries and Their Purpose** 1. **Cryptico**: Provides an implementation of the SHA-256 algorithm using the Web Cryptography API. 2. **Crypto.js**: Provides a comprehensive cryptographic library with various algorithms, including SHA-256. 3. **sjcl**: Provides a lightweight, fast, and secure implementation of cryptographic algorithms, including SHA-256. **Special JS Feature or Syntax** The benchmark uses the `window.crypto.getRandomValues()` method to generate random values for the input data, which is a feature introduced in modern browsers. **Other Alternatives** If you're looking for alternative libraries or implementations, here are a few options: 1. **Web Crypto API**: Provides a standard implementation of cryptographic algorithms, including SHA-256. 2. **Secure Sockets Layer (SSL) and Transport Layer Security (TLS)**: Provide secure communication protocols for data encryption and authentication. 3. **Hash functions from other libraries**, such as `crypto-js` or `sjcl`, which provide additional features and optimizations. In summary, the benchmark compares four different options for SHA-256 hashing using various libraries and implementations. Each option has its pros and cons, and understanding these differences can help developers choose the best approach for their specific use case.
Related benchmarks:
Sha256
Sha256-2
Sha256-Hex-Effect
sha1-js-rusha-vs-native-10mb
Comments
Confirm delete:
Do you really want to delete benchmark?