Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Web Encrypt API (Encrypt)
(version: 0)
Comparing performance of:
CTR vs GCM vs CBC
Created:
2 years ago
by:
Guest
Jump to the latest result
Tests:
CTR
(async () => { let ciphertext; let counter; const message = "esto es prueba"; let enc = new TextEncoder(); let encoded = enc.encode(message); const key = await window.crypto.subtle.generateKey( { name: "AES-CTR", length: 256 }, true, ["encrypt", "decrypt"] ); counter = window.crypto.getRandomValues(new Uint8Array(16)); ciphertext = await window.crypto.subtle.encrypt( { name: "AES-CTR", counter, length: 64 }, key, encoded ); })();
GCM
(async () => { let ciphertext; let iv; const message = "esto es prueba"; let enc = new TextEncoder(); const key = await window.crypto.subtle.generateKey( { name: "AES-GCM", length: 256, }, true, ["encrypt", "decrypt"] ); let encoded = enc.encode(message); iv = window.crypto.getRandomValues(new Uint8Array(12)); ciphertext = await window.crypto.subtle.encrypt( { name: "AES-GCM", iv: iv }, key, encoded ); })();
CBC
(async () => { let ciphertext; let iv; const message = "esto es prueba"; let enc = new TextEncoder(); const key = await window.crypto.subtle.generateKey( { name: "AES-CBC", length: 256 }, true, ["encrypt", "decrypt"] ); let encoded = enc.encode(message); iv = window.crypto.getRandomValues(new Uint8Array(16)); ciphertext = await window.crypto.subtle.encrypt( { name: "AES-CBC", iv }, key, encoded ); })();
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
CTR
GCM
CBC
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
8 months ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36
Browser/OS:
Chrome 139 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
CTR
85440.9 Ops/sec
GCM
105012.6 Ops/sec
CBC
98300.8 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
**Overview of the Benchmark** The provided benchmark measures the performance of three different encryption algorithms in JavaScript: AES-CTR, AES-GCM, and AES-CBC. The benchmark is designed to test the execution speed of these algorithms on a Windows desktop machine running Chrome 116. **Encryption Algorithms Compared** 1. **AES-CTR (Counter Mode)**: * A stream cipher mode that uses a counter to generate ciphertext. * Pros: Fast and simple to implement, suitable for applications requiring high-speed encryption. * Cons: Vulnerable to attacks if the counter is not properly managed. 2. **AES-GCM (Galois/Counter Mode)**: * A hybrid cipher mode that combines AES with a counter and authentication tags. * Pros: Provides both confidentiality and authenticity, suitable for applications requiring secure data transmission. * Cons: More complex to implement than CTR, requires additional computations for authentication tags. 3. **AES-CBC (Cipher Block Chaining)**: * A block cipher mode that processes plaintext in fixed-size blocks. * Pros: Simple to implement, widely supported by cryptographic libraries. * Cons: Slower than CTR and GCM due to the overhead of padding and block processing. **Library Used** The benchmark uses the Web Crypto API (W3C) for encryption operations. The W3C is a standardized API for performing various cryptographic tasks in web applications, including encryption, decryption, and signing. **Special JS Feature or Syntax** The benchmark utilizes the `async`/`await` syntax to define the test cases as asynchronous functions, which allows them to run concurrently on different execution paths. This feature enables efficient testing of multiple scenarios without blocking each other's execution. **Other Considerations** * The benchmark uses a random key generation mechanism for each encryption algorithm, ensuring that no two runs produce the same ciphertext. * The `TextEncoder` is used to encode the plaintext message before encryption. * The test cases do not include any decryption operations, only encryption and ciphertext generation. **Alternative Benchmarks** Other benchmarks that may be of interest: 1. **NaCl (Networking and Cryptography Library)**: A lightweight cryptographic library for general-purpose computing. 2. **Crypto-JS**: A JavaScript library for performing various cryptographic tasks, including encryption, decryption, and signing. 3. **WebAssembly (WASM) Cryptography**: A benchmark specifically designed to test the performance of WebAssembly-based cryptography libraries. These benchmarks can provide a more comprehensive understanding of JavaScript's capabilities in cryptography and help developers choose the most suitable algorithms for their applications.
Related benchmarks:
Sha-xxx
crypto-subtle
dsha256
crypto algo
Comments
Confirm delete:
Do you really want to delete benchmark?