Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
sha1-js ie11
(version: 0)
Comparing performance of:
forge vs native vs sjcl vs cryptojs
Created:
4 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/rusha/0.8.7/rusha.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.9-1/crypto-js.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/forge/0.9.1/forge.min.js"></script>
Script Preparation code:
var data = new Uint32Array(1024); window.msCrypto.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:
forge
forge.md.sha1.create().update(data).digest()
native
crypto.subtle.digest("SHA-1", dataBuffer ).then(function (hash) {console.log(hex(hash));});
sjcl
sjcl.hash.sha1.hash(data);
cryptojs
CryptoJS.SHA1(data);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
forge
native
sjcl
cryptojs
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):
**Benchmark Overview** MeasureThat.net is a website that allows users to create and run JavaScript microbenchmarks. The provided benchmark tests the performance of four different libraries for generating SHA-1 hashes: `forge`, `crypto-js`, `sjcl`, and a native implementation using Web Cryptography API. **Library Descriptions** * **Forge**: Forge is an open-source library for cryptographic primitives in JavaScript. It provides implementations for various algorithms, including SHA-1. * **CryptoJS**: CryptoJS is a popular JavaScript library for cryptography and encryption. It provides a wide range of cryptographic functions, including hash functions like SHA-1. * **SJCL (Simple JavaScript Cryptography Library)**: SJCL is another open-source library for cryptographic primitives in JavaScript. It provides implementations for various algorithms, including SHA-1. **Benchmark Definitions** The benchmark definitions are: * `forge.md.sha1.create().update(data).digest()`: This defines the benchmark using Forge's SHA-1 implementation. * `crypto.subtle.digest("SHA-1", dataBuffer).then(function(hash) { console.log(hex(hash)); });`: This defines the benchmark using the Web Cryptography API (native implementation). * `sjcl.hash.sha1.hash(data);`: This defines the benchmark using SJCL's SHA-1 implementation. * `CryptoJS.SHA1(data);`: This defines the benchmark using CryptoJS's SHA-1 implementation. **Options Compared** The four libraries are compared in terms of their performance, measured by the number of executions per second (ExecutionsPerSecond). The native implementation using Web Cryptography API is also included for comparison. **Pros and Cons of Each Approach** * **Forge**: Pros: + Fast performance due to optimized implementations. + Easy to use and integrate with other cryptographic primitives. Cons: + May require additional dependencies or setup. * **CryptoJS**: Pros: + Wide range of cryptographic functions, including hash functions. + Well-maintained and widely used library. Cons: + Larger size due to additional dependencies. * **SJCL**: Pros: + Lightweight and compact implementation. + Easy to use and integrate with other libraries. Cons: + Smaller community compared to Forge and CryptoJS. * **Native Implementation (Web Cryptography API)**: Pros: + Fast performance due to optimized Web Cryptography API implementations. + Secure and trusted implementation. **Other Considerations** When choosing a library for cryptographic tasks, consider the following factors: * Performance: Choose a library with optimized implementations that meet your performance requirements. * Security: Ensure the library is well-maintained and provides secure implementations of cryptographic primitives. * Ease of use: Select a library with an easy-to-use API that integrates well with other libraries and frameworks. * Dependencies: Consider the size and complexity of the library, as well as any additional dependencies required. **Alternatives** Other alternatives to consider for SHA-1 hash functions include: * **SHA256**: A more secure and widely used hashing algorithm compared to SHA-1. * **BLAKE2**: A fast and secure hashing algorithm that is gaining popularity. * **Keccak-256**: A widely used hashing algorithm with high security and performance.
Related benchmarks:
Sha-xxx
Sha256-Hex-Effect
sha1-js-pref
sha1-js-rusha-vs-native-10mb
Comments
Confirm delete:
Do you really want to delete benchmark?