From c6a6c0093b9da31f3d78d43d7f72e469b4be817b Mon Sep 17 00:00:00 2001 From: "jiewen_tan@apple.com" Date: Thu, 20 Jul 2017 14:25:34 +0000 Subject: [PATCH] Unreviewed, add a demo page for a WebCrypto API blog post * demos/webcrypto/asynchronous-execution-worker.js: Added. * demos/webcrypto/asynchronous-execution.html: Added. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219682 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- Websites/webkit.org/ChangeLog | 7 ++ .../webcrypto/asynchronous-execution-worker.js | 18 +++ .../demos/webcrypto/asynchronous-execution.html | 128 +++++++++++++++++++++ 3 files changed, 153 insertions(+) create mode 100644 Websites/webkit.org/demos/webcrypto/asynchronous-execution-worker.js create mode 100644 Websites/webkit.org/demos/webcrypto/asynchronous-execution.html diff --git a/Websites/webkit.org/ChangeLog b/Websites/webkit.org/ChangeLog index f14c616..55bc75c 100644 --- a/Websites/webkit.org/ChangeLog +++ b/Websites/webkit.org/ChangeLog @@ -1,3 +1,10 @@ +2017-07-19 Jiewen Tan + + Unreviewed, add a demo page for a WebCrypto API blog post + + * demos/webcrypto/asynchronous-execution-worker.js: Added. + * demos/webcrypto/asynchronous-execution.html: Added. + 2017-06-30 Jon Lee Add a WebRTC example for a blog post diff --git a/Websites/webkit.org/demos/webcrypto/asynchronous-execution-worker.js b/Websites/webkit.org/demos/webcrypto/asynchronous-execution-worker.js new file mode 100644 index 0000000..c722aa7 --- /dev/null +++ b/Websites/webkit.org/demos/webcrypto/asynchronous-execution-worker.js @@ -0,0 +1,18 @@ +var aesCbcParams = { + name: "aes-cbc", + iv: new Uint8Array([0x6a, 0x6e, 0x4f, 0x77, 0x39, 0x39, 0x6f, 0x4f, 0x5a, 0x46, 0x4c, 0x49, 0x45, 0x50, 0x4d, 0x72]), +} +var plainText = new Uint8Array(104857600); // 100MB +var times = 10; + +onmessage = function(evt) +{ + var key = evt.data; + + var array = [ ]; + for (var i = 0; i < times; i++) + array.push(crypto.subtle.encrypt(aesCbcParams, key, plainText)); + Promise.all(array).then(function() { + postMessage(true); + }); +} diff --git a/Websites/webkit.org/demos/webcrypto/asynchronous-execution.html b/Websites/webkit.org/demos/webcrypto/asynchronous-execution.html new file mode 100644 index 0000000..fbc9b91 --- /dev/null +++ b/Websites/webkit.org/demos/webcrypto/asynchronous-execution.html @@ -0,0 +1,128 @@ + + + + + + + +
+

Asynchronous executions

+

+ Click the following buttons to see how asynchronous executions could help to improve responsiveness of a website. + To magnify the effect, a very large file ~100MB will be encrypted TEN times. Be aware of your hardware limits. +

+
+

WebKitSubtleCrypto:

+ + + +
+
+

SubtleCrypto:

+ + + +
+
+

WebWorkers:

+ + + +
+
+ + -- 1.8.3.1