Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Sha256-2
(version: 0)
Comparing performance of:
Cryptico vs Crypto.js vs sjcl vs window.crypto
Created:
7 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) { 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:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's break down what's being tested on the provided JSON. The benchmark is designed to measure the performance of different libraries for hashing and generating SHA-256 hashes in JavaScript. Here are the options being compared: 1. **Cryptico**: A JavaScript library that provides cryptographic functions, including hashing. 2. **Crypto.js**: A popular JavaScript library for cryptography and encryption. 3. **sjcl** (Simple-JavaScript Cryptography Library): A lightweight JavaScript library for cryptographic primitives. 4. **window.crypto**: The Web Cryptography API, a built-in feature of modern browsers that allows for secure cryptographic operations. The pros and cons of each approach: * **Cryptico**, **Crypto.js**, and **sjcl** are external libraries that need to be included in the benchmark code. They provide pre-built functions for hashing and encryption, which can be efficient but also introduce dependencies and potential security risks. + Pros: Easy to use, well-maintained, and widely adopted. + Cons: Adds extra dependencies, may not be optimized for performance or security. * **window.crypto** is a built-in feature of modern browsers that provides a secure way to perform cryptographic operations. It's a more lightweight and secure option than external libraries. + Pros: Built-in, no additional dependencies, and optimized for security. + Cons: May not be supported in older browsers or environments. The benchmark code prepares the input data by generating a random array of 1024 Uint32 values and converting it to a string. The hashing function is then applied to this string using each of the four options. The `hex` function is used to generate the SHA-256 hash as a hexadecimal string. It's implemented in the benchmark code and uses the `DataView` API to read theUint32 values from the input array. Some notes on the test cases: * The **window.crypto** option uses the Web Cryptography API's `digest` method, which is a standardized way of performing cryptographic operations. * The **sjcl** option uses the `hash` function, which is a specific implementation of the SHA-256 algorithm in sjcl. * The **Crypto.js** and **Cryptico** options use their respective `SHA256` functions to generate the hash. In terms of special JavaScript features or syntax, none are mentioned explicitly. However, the use of `DataView` and `getUint32` is specific to modern browsers that support these APIs. Overall, this benchmark aims to compare the performance of different libraries for hashing and generating SHA-256 hashes in JavaScript, as well as the built-in Web Cryptography API on modern browsers. As for alternative approaches, some options could be considered: * Using a different library or implementation for hashing, such as OpenSSL or a custom implementation. * Comparing the performance of different browser engines (e.g., V8, SpiderMonkey) or environments (e.g., Node.js, WebAssembly). * Adding more test cases to cover other cryptographic operations, such as encryption and decryption. However, the current benchmark provides a good starting point for comparing the performance of popular libraries and the built-in Web Cryptography API.
Related benchmarks:
Sha256
Sha256-Hex-Effect
sha256-js
sha1-js-rusha-vs-native-10mb
Comments
Confirm delete:
Do you really want to delete benchmark?