Skip to content

Instantly share code, notes, and snippets.

@LeonardoCiaccio
Created April 24, 2017 08:02
Show Gist options
  • Select an option

  • Save LeonardoCiaccio/b48f0c5e3dd154862cf69bfd6a17480e to your computer and use it in GitHub Desktop.

Select an option

Save LeonardoCiaccio/b48f0c5e3dd154862cf69bfd6a17480e to your computer and use it in GitHub Desktop.
Full working sample actually is:
<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.2/rollups/aes.js"></script>
<br><br>
<label>encrypted</label>
<div id="demo1"></div>
<br>
<label>decrypted</label>
<div id="demo2"></div>
<br>
<label>Actual Message</label>
<div id="demo3"></div>
<script>
var encrypted = CryptoJS.AES.encrypt("Message", "Secret Passphrase");
//U2FsdGVkX18ZUVvShFSES21qHsQEqZXMxQ9zgHy+bu0=
var decrypted = CryptoJS.AES.decrypt(encrypted, "Secret Passphrase");
//4d657373616765
document.getElementById("demo1").innerHTML = encrypted;
document.getElementById("demo2").innerHTML = decrypted;
document.getElementById("demo3").innerHTML = decrypted.toString(CryptoJS.enc.Utf8);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment