Skip to content

Instantly share code, notes, and snippets.

@sachadee
Last active June 16, 2023 04:38
Show Gist options
  • Save sachadee/1a5a0c9c0fd67e954d7302a4ad5697bf to your computer and use it in GitHub Desktop.
Save sachadee/1a5a0c9c0fd67e954d7302a4ad5697bf to your computer and use it in GitHub Desktop.
AES CBC Decryption in JavaScript
<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.1.1/crypto-js.min.js"></script>
<script>
//PYTHON FIX IV ENCRYPTION AND PYTHON FIX IV
var Base64CBC ='VEX7Eequ5TM9+jlgrwnkNw==';
var iv = CryptoJS.enc.Utf8.parse('BBBBBBBBBBBBBBBB');
//PYTHON RANDOM IV ENCRYPTION AND PYTHON RANDOM IV
//var Base64CBC ='uJrS9Zp1R5WjOEUkSK9clQ==';
//var iv = CryptoJS.enc.Base64.parse('l5I5Toqn5RoX0JfTLQB9Pw==');
var key ='AAAAAAAAAAAAAAAA'//key used in Python
key = CryptoJS.enc.Utf8.parse(key);
var decrypted = CryptoJS.AES.decrypt(Base64CBC, key, { iv: iv, mode: CryptoJS.mode.CBC});
decrypted = decrypted.toString(CryptoJS.enc.Utf8);
console.log(decrypted);
alert(decrypted);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment