Created
March 14, 2018 17:23
-
-
Save anonymous/90eff80b090960080dd642b7423d78ce to your computer and use it in GitHub Desktop.
CryptoJS AES Encryption (source: https://jsfiddle.net/beL4q171/12/)
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
<p>Message: <span id="message"></span> | |
</p> | |
<p>Encrypted: <span id="1"></span> | |
</p> | |
<p>Decrypted text: <span id="2"></span> | |
</p> |
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
var key = CryptoJS.enc.Hex.parse('0123456789abcdef'); | |
var iv = CryptoJS.enc.Hex.parse('fedcba9876543210'); | |
var message = "fubar"; | |
var encrypted = CryptoJS.AES.encrypt(message, key, { | |
iv: iv | |
}); | |
var decrypted = CryptoJS.AES.decrypt( | |
'IKcST4CbRgw5ipEZv+zaug==', key, { | |
iv: iv | |
}).toString(CryptoJS.enc.Utf8); | |
$('#message').text('"' + message + '" '); | |
$('#1').text(encrypted); | |
$('#2').text(decrypted); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment