I'm trying to decrypt some data I'm receiving through HttpClient.
The data is encrypted using AES/ECB with a single synchronous key and padded using PKCS#5.
Currently i'm trying -
function decryptBlob(blob) {
var Crypto = Windows.Security.Cryptography;
var key = "M02cnQ52Ji97wvT7";
var SAP = Crypto.Core.SymmetricKeyAlgorithmProvider.openAlgorithm("AES_ECB_PKCS7");
var bufferedKey = Crypto.CryptographicBuffer.convertStringToBinary(key, Crypto.BinaryStringEncoding.Utf8)
var AES = SAP.createSymmetricKey(bufferedKey);
var data = Crypto.CryptographicBuffer.decodeFromBase64String(blob);
var iBuffer = Crypto.Core.CryptographicEngine.decrypt(AES, data, null);
}
But this gives me the error :
0x80090005 - JavaScript runtime error: Bad Data.
In the function call:
var data = Crypto.CryptographicBuffer.decodeFromBase64String(blob);
Any ideas of what errors i'm making or how i'm going about this wrong?
User contributions licensed under CC BY-SA 3.0