Last active
August 29, 2015 14:12
-
-
Save declank/689b972dbcbfd3ccc12c to your computer and use it in GitHub Desktop.
Revisions
-
declank revised this gist
Dec 23, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,7 +10,7 @@ <h1>Demo of <a href="http://bitwiseshiftleft.github.io/sjcl/" target="_blank">St <input type="text" id="message" value="The quick brown fox jumps over the lazy dog"><br> <button id="encrypt">Encrypt</button><br> <output id="output"></output> <script src="//cdnjs.cloudflare.com/ajax/libs/sjcl/1.0.0/sjcl.min.js"></script> <script> var encryptButton = document.getElementById("encrypt"); -
declank created this gist
Dec 23, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,39 @@ <!doctype html> <html> <head> <meta charset="utf-8"> </head> <body> <h1>Demo of <a href="http://bitwiseshiftleft.github.io/sjcl/" target="_blank">Stanford Javascript Crypto Library</a></h1> <p>Generates HMAC using SHA-256</p> <input type="text" id="key" value="key"><br> <input type="text" id="message" value="The quick brown fox jumps over the lazy dog"><br> <button id="encrypt">Encrypt</button><br> <output id="output"></output> <script src="http://cdnjs.cloudflare.com/ajax/libs/sjcl/1.0.0/sjcl.min.js"></script> <script> var encryptButton = document.getElementById("encrypt"); encryptButton.addEventListener('click', function(event) { 'use strict'; if(typeof sjcl === 'undefined') { alert("Please wait for library to load..."); } else { var key = document.getElementById("key").value; var message = document.getElementById('message').value; var hmac = new sjcl.misc.hmac(sjcl.codec.utf8String.toBits(key)); var output = ""; output += "Key: " + key + "<br>"; output += "Message: " + message + '<br>'; output += "HMAC: 0x" + sjcl.codec.hex.fromBits(hmac.encrypt(message)) + '<br>'; document.getElementById('output').innerHTML = output; } }); </script> </body> </html>