Skip to content

Instantly share code, notes, and snippets.

@davidcotter
Created July 3, 2016 16:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidcotter/964ce5c13f3e043ea2531769fa1356d1 to your computer and use it in GitHub Desktop.
Save davidcotter/964ce5c13f3e043ea2531769fa1356d1 to your computer and use it in GitHub Desktop.
<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