Reputation: 1
My task is to decrypt AES-128 in CBC Mode as I already have to encrypted hex string and the key (also in hex). I have tried a simple code like:
function doDecrypt(){
var encryptedData = "1d4c76364618b6efce62258353f89810"
var key = "11112222333344445555666677778888";
encryptedData = CryptoJS.enc.Hex.parse(encryptedData);
key = CryptoJS.enc.Hex.parse(key);
var decrypted = CryptoJS.AES.decrypt(encryptedData, key);
alert(CryptoJS.enc.Hex.stringify(decrypted));
}
The result I get is just a blank word array (in "decrpyted"), can anyone point out that where did i do wrong please?
do I need an additional information such as iv, salt or not?
Upvotes: 0
Views: 2051
Reputation: 299605
"AES-128 in CBC Mode" is not a data format. There is no universal way of writing encrypted data along with the required metadata. You need to know what you've been handed and how it was generated. Then you can work out how to implement the same with CryptoJS in most cases. In particular, you need to know the following:
When you have these answers, then you can work out how to implement it with CryptoJS.
Upvotes: 3