Anonymous Crypto method error: last block incomplete in decryption

I am testing some Crypto methods for decryption in the anonymous window. But getting this error while trying with valid inputs:

Blob key = Blob.valueOf('xxxxxxxxxxxxxxxx');
System.debug('key: ' +key);
Blob encodedEncryptedBlob = EncodingUtil.base64Decode('SOME ENCRYPTED VALUE');
System.debug('encodedEncryptedBlob: ' +encodedEncryptedBlob);
Blob decryptedData = Crypto.decryptWithManagedIV('AES128', key, encodedEncryptedBlob);
String decryptedDataString = decryptedData.toString();
System.debug('decryptedDataString: ' +decryptedDataString);

Error message:

FATAL_ERROR System.SecurityException: last block incomplete in decryption

What could be my mistake here?

Note: I have received those key and encrypted data from our partner, so that data is valid.


Source : Link , Question Author : Austin Evans , Answer Author : Community

Leave a Comment