Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 138163

How to decrypt AES 256 CBC by javascrypt (Not Nodejs)

$
0
0

How can I decrypt an encrypted string like dIwykUwOomuWcdw/QX/Aig== in AES 256 CBC mode with the key ds8am3wys3pd75nf0ggtvajw2k3uny92 and iv jm8lgqa3j1d0ajus as the picture below just with javascript (not Nodejs). I used to try with CryptoJs library but the result not like I expected.

enter image description here

<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.2/rollups/aes.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.2/rollups/pbkdf2.js"></script>
<script>
    var str = 'dIwykUwOomuWcdw/QX/Aig==';
    var key = 'ds8am3wys3pd75nf0ggtvajw2k3uny92';
    var iv  = 'jm8lgqa3j1d0ajus';

    var encrypted = CryptoJS.AES.encrypt("2730007809303", key, { iv: iv });
    var decrypted = CryptoJS.AES.decrypt(encrypted, key, { iv: iv});
    var base64_str = decrypted.toString(CryptoJS.enc.Base64);
    console.log(atob(base64_str))
</script>

By the way, how can I convert input string dIwykUwOomuWcdw/QX/Aig== as encrypted object above ?


Viewing all articles
Browse latest Browse all 138163

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>