Let's encrypt a 100 MB file using the latest browser - WebCrypto API Speed TestÂ
How long does it take to encrypt a file using the WebCrypto API on the latest browsers? We measured the speed on Firefox, Chrome, Safari, Opera, and IE11 does support Web Cryptography, but that's based on an old version of the spec.
https://caniuse.com/#feat=cryptographyThe W3C Recommendation from 26 January 2017 describes a JavaScript API for performing basic cryptographic operations in web applications, such as hashing, signature generation and verification, and encryption and decryption.
https://www.w3.org/TR/WebCryptoAPI/Test setup: 2,4 GHz Intel Core i5, 16 GB 1333 MHz DDR3, Intel HD 3000 512 MB, running macOS Sierra v10.12.6.
JavaScript encryption library: OpenPGP.js v3.0.3
https://github.com/openpgpjs/openpgpjsAnd the winner is Firefox 59!
25 MB -> 3.0 seconds
50 MB -> 5.8 seconds
100 MB -> 14.2 seconds
2. Safari 11
25 MB -> 4.2 seconds
50 MB -> 7.3 seconds
100 MB -> timeout
3. Chrome 65
25 MB -> 10.0 seconds
50 MB -> 19.1 seconds
100 MB -> timeout
4. Opera 52
25 MB -> 13.6 seconds
50 MB -> 22.5 seconds
100 MB -> timeout
Firefox encrypts a file 4 times faster than Opera. Safari and Chrome crashes on files > 75 MB.
How we measured the performance?
var performance = window.performance;
var t0 = performance.now();
var options, encrypted;
options = {
data: new Uint8Array([0x01, 0x01, 0x01]), // input as Uint8Array (or String)
passwords: ['secret stuff'], // multiple passwords possible
armor: false // don't ASCII armor (for Uint8Array output)
};
openpgp.encrypt(options).then(function(ciphertext) {
encrypted = ciphertext.message.packets.write(); // get raw encrypted packets as Uint8Array
});
var t1 = performance.now();
alert("Call to doWork took " + (t1 - t0) / 1000 + " seconds.");