Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Hashing Benchmarks
(version: 0)
Comparing performance of:
SHA-1 vs SHA-256 vs SHA-384 vs SHA-512
Created:
3 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:
5 months ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36
Browser/OS:
Chrome 142 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
SHA-1
222213.2 Ops/sec
SHA-256
216883.6 Ops/sec
SHA-384
190502.4 Ops/sec
SHA-512
184251.6 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's dive into the world of JavaScript microbenchmarks! **Benchmark Definition** The provided JSON represents a benchmark definition for measuring the performance of hashing algorithms using Web Cryptography API (Web Crypto). The script prepares a random 1024-byte data array and converts it to a hexadecimal string. Then, it uses the `crypto.subtle.digest()` method to compute the hash of the data using different hashing algorithms (SHA-1, SHA-256, SHA-384, and SHA-512). **Options Compared** The benchmark compares the performance of four different hashing algorithms: 1. **SHA-1**: A widely used hashing algorithm that produces a 160-bit (20-byte) hash value. 2. **SHA-256**: A more secure hashing algorithm that produces a 256-bit (32-byte) hash value. 3. **SHA-384**: An even more secure hashing algorithm that produces a 384-bit (48-byte) hash value. 4. **SHA-512**: The most secure hashing algorithm among the four, producing a 512-bit (64-byte) hash value. **Pros and Cons of Different Approaches** * **Hashing algorithms:** Each algorithm has its own strengths and weaknesses: + SHA-1 is fast but insecure due to its relatively small output size. + SHA-256, SHA-384, and SHA-512 are slower but more secure than SHA-1. + SHA-384 and SHA-512 offer better security and entropy for cryptographic purposes. * **Hashing algorithm selection:** The choice of hashing algorithm depends on the specific use case: + For general-purpose data hashing, SHA-256 is often a good balance between speed and security. + For high-security applications (e.g., cryptocurrency), SHA-384 or SHA-512 might be necessary. **Library: Web Cryptography API** The `crypto.subtle.digest()` method uses the Web Cryptography API, which provides an interface for cryptographic primitives. The library is part of the Web Crypto Standard and is supported by modern browsers and Node.js environments. **Special JS Features/Syntax** None mentioned in this benchmark definition. **Other Alternatives** If you want to test other hashing algorithms or compare performance with alternative libraries, consider the following: 1. **Native libraries:** You can use native libraries like OpenSSL (for desktop applications) or libcrypto (for mobile applications). 2. **Third-party libraries:** There are several third-party JavaScript libraries that implement different hashing algorithms, such as Crypto-JS, WebCryptoJS, or hash.js. 3. **Online hashing services:** Some online services provide hashing APIs, like Hashicorp's Vault or AWS Key Management Service. Keep in mind that the specific alternatives will depend on your use case and requirements. I hope this explanation helps you understand what is being tested in this benchmark definition!
Related benchmarks:
Sha256
Sha256
sha1-js-rusha-vs-native-10mb
Compare digest performance
Comments
Confirm delete:
Do you really want to delete benchmark?