Unreviewed, add the final demo page for a WebCrypto API blog post
authorjiewen_tan@apple.com <jiewen_tan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 20 Jul 2017 17:18:56 +0000 (17:18 +0000)
committerjiewen_tan@apple.com <jiewen_tan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 20 Jul 2017 17:18:56 +0000 (17:18 +0000)
* demos/webcrypto/pbkdf2.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219693 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Websites/webkit.org/ChangeLog
Websites/webkit.org/demos/webcrypto/pbkdf2.html [new file with mode: 0644]

index d89256b..d7d03bf 100644 (file)
@@ -1,5 +1,11 @@
 2017-07-20  Jiewen Tan  <jiewen_tan@apple.com>
 
+        Unreviewed, add the final demo page for a WebCrypto API blog post
+
+        * demos/webcrypto/pbkdf2.html: Added.
+
+2017-07-20  Jiewen Tan  <jiewen_tan@apple.com>
+
         Unreviewed, add yet another demo page for a WebCrypto API blog post
 
         * demos/webcrypto/aes-gcm.html:
diff --git a/Websites/webkit.org/demos/webcrypto/pbkdf2.html b/Websites/webkit.org/demos/webcrypto/pbkdf2.html
new file mode 100644 (file)
index 0000000..91d6125
--- /dev/null
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <title>WebCrypto API Demo: PBKDF2</title>
+    <style>
+    .inner
+    {
+        display: inline-block;
+    }
+    </style>
+    <script type="text/javascript" src="common.js"></script>
+    <script type="text/javascript">
+    function PBKDF2()
+    {
+        var rawKey = document.getElementById("password").value;
+
+        crypto.subtle.importKey("raw", asciiToUint8Array(rawKey), "PBKDF2", false, ["deriveBits"]).then(function(baseKey) {
+            return crypto.subtle.deriveBits({name: "PBKDF2", salt: crypto.getRandomValues(new Uint8Array(16)), iterations: 100000, hash: "sha-256"}, baseKey, 128);
+        }, failAndLog).then(function(result) {
+            document.getElementById("derivedKey").innerHTML = bytesToHexString(result);
+        }, failAndLog);
+    }
+    </script>
+</head>
+<body>
+    <h1>PBKDF2</h1>
+    <p>Click the following button multiple times to see how random salts can strengthen password hashes.</p>
+    <div>
+        Password: <input type="text" id="password" value="123456789">
+        <button type="button" onclick="PBKDF2()" class="inner">derive</button>
+        <div id="derivedKey" class="inner"></div>
+    </div>
+</body>
+</html>