Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Sha512
(version: 0)
Comparing performance of:
Cryptico vs Crypto.js vs sjcl vs window.crypto
Created:
6 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-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
Cryptico
Crypto.js
sjcl
window.crypto
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
6 months ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:143.0) Gecko/20100101 Firefox/143.0
Browser/OS:
Firefox 143 on Mac OS X 10.15
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Cryptico
4797.5 Ops/sec
Crypto.js
26502.4 Ops/sec
sjcl
26265.7 Ops/sec
window.crypto
573020.2 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
I'll break down the provided benchmark definition and test cases, explaining what's being tested, compared, and their pros and cons. **Benchmark Definition** The benchmark definition is a JSON object that contains information about the script to be executed. In this case, there are four different scripts: 1. **SubtleCrypto**: This option uses the Web API's `SubtleCrypto` interface to compute the SHA-512 hash of the input data. 2. **Sjcl**: This option uses the SJCL (Secure JavaScript Library) library to compute the SHA-256 hash of the input data, which is then converted to SHA-512 using a custom function (`hex()`). 3. **Crypto.js**: This option uses the Crypto-JS library to compute the SHA-256 hash of the input data, which is then converted to SHA-512 using a custom function (`hex()`). 4. **Cryptico**: This option uses a custom implementation to compute the SHA-256 hash of the input data, which is then converted to SHA-512 using a custom function (`hex()`). **Comparison** The comparison between these options is based on their performance, specifically the number of executions per second (ExecutionsPerSecond). The script with the highest value in this metric is considered the fastest. **Pros and Cons** Here's a brief summary of each option: 1. **SubtleCrypto**: * Pros: Native Web API, efficient implementation, and well-maintained. * Cons: Requires support for Web Cryptography API, which might not be available on all browsers or systems. 2. **Sjcl**: * Pros: Secure, well-tested, and widely adopted library. * Cons: Additional dependency required (SJCL), and the custom `hex()` function can introduce overhead. 3. **Crypto.js**: * Pros: Well-maintained, efficient implementation, and widely used. * Cons: Additional dependency required (Crypto-JS), and the custom `hex()` function can introduce overhead. 4. **Cryptico**: * Pros: Custom implementation, potentially optimized for performance. * Cons: No clear support from maintainers or community, and might not be as efficient as established libraries. **Other Considerations** When choosing an option, consider factors such as: * Browser support: Some options (e.g., SubtleCrypto) require specific browser support, while others (e.g., Sjcl, Crypto.js) are more widely supported. * Security: Sjcl and Crypto.js are well-established libraries with good security track records, while Cryptico's custom implementation might introduce security risks if not properly validated. * Performance: The comparison results will indicate which option performs best in terms of executions per second. **Alternatives** For SHA-512 hashing, other alternatives to the options listed above include: 1. **Web Crypto API with SHA-512**: This option uses the Web Crypto API's `digest` method to compute the SHA-512 hash directly. 2. **Bcrypt**: A widely used library for password hashing and verification that can be adapted for general-purpose hashing tasks, including SHA-512. Keep in mind that each alternative has its pros and cons, and the best choice depends on specific requirements, such as performance, security, or ease of use.
Related benchmarks:
Sha256
Sha256-2
Sha256-Hex-Effect
sha1-js-rusha-vs-native-10mb
Comments
Confirm delete:
Do you really want to delete benchmark?