Skip to content

Instantly share code, notes, and snippets.

@graste
Created March 19, 2013 22:08
Show Gist options
  • Save graste/5200590 to your computer and use it in GitHub Desktop.
Save graste/5200590 to your computer and use it in GitHub Desktop.
CryptoJS AES Test
<html>
<head>
<title>CryptoJS AES Test</title>
</head>
<body>
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/components/core-min.js"></script>
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/aes.js"></script>
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/components/enc-base64-min.js"></script>
<p>Create new encrypted files via:</p>
<code>openssl enc -aes-256-cbc -in SOURCE.FILE -out ENCRYPTED.AES -pass pass:"Secret Passphrase" -e -base64</code>
<script>
xhr = new XMLHttpRequest();
xhr.overrideMimeType('text/plain');
xhr.open("GET", "ENCRYPTED.AES", false);
xhr.send(null);
alert(CryptoJS.AES.decrypt(xhr.responseText.replace(/\n/, ''), prompt('passphrase', '')).toString(CryptoJS.enc.Utf8));
</script>
</body>
</html>
@graste
Copy link
Author

graste commented Mar 22, 2013

Encryption:

openssl aes-256-cbc -in attack-plan.txt -out message.enc

Decryption:

openssl aes-256-cbc -d -in message.enc -out plain-text.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment