Last active
August 29, 2015 14:08
-
-
Save mbbx6spp/843f7a9211ed6512efd5 to your computer and use it in GitHub Desktop.
This file contains 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
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/aes.js"></script> | |
<script> | |
function mkCipher(cipherModule, encoding) { | |
var that = this; | |
that.encrypt = cipherModule.encrypt; | |
that.decrypt = function (data, passphrase) { | |
var decrypted = cipherModule.decrypt(data, passphrase); | |
return decrypted.toString(encoding); | |
}; | |
return that; | |
} | |
(function () { | |
var AES = mkCipher(CryptoJS.AES, CryptoJS.enc.Utf8); | |
var data = "My secret message"; | |
var passphrase = "booyah!"; | |
var encrypted = AES.encrypt(data, passphrase); | |
alert("Encrypted: " + encrypted); | |
alert("Decrypted: " + AES.decrypt(encrypted, passphrase)); | |
})(); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment