Created
July 3, 2016 16:50
-
-
Save davidcotter/964ce5c13f3e043ea2531769fa1356d1 to your computer and use it in GitHub Desktop.
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 characters
<html> | |
<head> | |
<script src="https://crypto.stanford.edu/sjcl/sjcl.js"></script> | |
<script src="https://code.jquery.com/jquery-3.0.0.js" integrity="sha256-jrPLZ+8vDxt2FnE1zvZXCkCcebI/C8Dt5xyaQBjxQIo=" crossorigin="anonymous"></script> | |
</head> | |
<body> | |
<form id="form"> | |
<br/>Plain: <input type="text" name="plain"> | |
<br/>Password: <input type="text" name="password"> | |
<br/><a href="#" id="go">Go</a> | |
<h3>Encrypted text</h3> <p id="encrypt"></p> | |
<h3>Decrypted Text</h3> <p id="decrypt"></p> | |
<script> | |
$("#go").click(function() { | |
var plain = $("input[name=plain]").val(); | |
var password = $("input[name=password]").val(); | |
var encrypted_data = sjcl.encrypt(password, plain); | |
var decrypted_data = sjcl.decrypt(password, encrypted_data); | |
$("#encrypt").text(encrypted_data); | |
$("#decrypt").text(decrypted_data); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment