I try to convert a string using AES method in JavaScript also I only need to use the CryptoJs library to achieve this.
When I try online from this website the result is coming as I expected which my Java program can decrypt it but when I try JavaScript I don't get the same result I get from the website.
This is what I need;
Data: {"test":1}
Secret: NdRgUkXp2s5v8y/A
The result should be: chib8X9Fnr7Vtn4VLRybKg==
The reason I'm referring the website, I don't know the mode and padding method of the above result but the below result is showing as expected from the server if you know the mode of the above result you can refer that also.
You can refer online encryption using https://www.devglan.com/online-tools/aes-encryption-decryption to validate.
This is what I get when I use JavaScript which is wrong;
var encrypted = CryptoJS.AES.encrypt('{"test",1}', "NdRgUkXp2s5v8y/A");
console.log(encrypted.toString())
Result: U2FsdGVkX1/GS5CecHJ10Z4qvSP8hY1NkDNtKGlg3OE=
Also it changes each time when generate.
I use this library https://cryptojs.gitbook.io/docs/