Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Sha-xxx
(version: 0)
Comparing performance of:
SHA-1 vs SHA-256 vs SHA-384 vs SHA-512
Created:
7 years ago
by:
Guest
Jump to the latest result
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:
SHA-1
crypto.subtle.digest("SHA-1", dataBuffer ).then(function (hash) {console.log(hex(hash));});
SHA-256
crypto.subtle.digest("SHA-256", dataBuffer ).then(function (hash) {console.log(hex(hash));});
SHA-384
crypto.subtle.digest("SHA-384", dataBuffer ).then(function (hash) {console.log(hex(hash));});
SHA-512
crypto.subtle.digest("SHA-512", 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
SHA-1
SHA-256
SHA-384
SHA-512
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
7 months ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.6 Safari/605.1.15
Browser/OS:
Safari 18 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
SHA-1
595777.6 Ops/sec
SHA-256
683411.9 Ops/sec
SHA-384
581078.9 Ops/sec
SHA-512
1035658.8 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Measuring the performance of different hash algorithms on various browsers and devices is crucial for understanding their efficiency in various scenarios. **Benchmark Definition JSON:** The provided JSON represents a benchmark definition for measuring the performance of SHA-1, SHA-256, SHA-384, and SHA-512 algorithms. The script preparation code initializes a random 1024-byte array (`dataBuffer`) using the Web Cryptography API's `getRandomValues()` method. Then, it converts this buffer to a string by creating an array of Unicode code points from each byte. The key function in this script is `hex()`, which takes a Uint8Array (`dataBuffer`) as input and returns a hexadecimal string representation of its contents. **Options Compared:** Three different approaches are compared: 1. **SHA-1**: Measures the performance of SHA-1, which is an older hash algorithm widely used in various applications. 2. **SHA-256**: Compares the performance of SHA-256, a more modern and widely adopted hash algorithm for security purposes. 3. **SHA-384** and **SHA-512**: Evaluate the performance of these newer algorithms, designed to provide higher security standards. **Pros and Cons:** * **SHA-1:** While it's simple and fast, its low collision resistance makes it less secure compared to newer algorithms like SHA-256. * **SHA-256:** Offers better security properties than SHA-1 but requires more computational power. It's widely used in many applications due to its balance between performance and security. * **SHA-384** and **SHA-512**: These newer algorithms provide higher security standards, requiring more computations than SHA-256 but offering greater protection against collisions. **Library Used:** The Web Cryptography API is used throughout the script. This library provides an interface for creating and managing cryptographic keys, hash algorithms (like SHA-1, SHA-256), and other cryptographic primitives in a web application. **Special JS Features/Syntax:** * `getRandomValues()`: A function from the Web Cryptography API that generates cryptographically strong random numbers. * `DataView` and `Uint8Array`, `String.fromCharCode.apply(null, dataBuffer)`: These are used to manipulate binary data in JavaScript. **Alternatives:** Other alternatives for measuring hash algorithm performance could include: * Using a different benchmarking framework or library (e.g., Benchmark.js) * Compiling the same script with different compilers to see variations in execution speed * Comparing the performance of different programming languages or runtimes when running the same script
Related benchmarks:
Sha256
Sha256
Sha256-Hex-Effect
sha1-js-rusha-vs-native-10mb
Comments
Confirm delete:
Do you really want to delete benchmark?