You need to sign in to do that
Don't have an account?
Encryption and Decryption
Hi,
I am encryptying my lead and opportunity id.
System.InvalidParameterValueException: Invalid initialization vector. Must be 16 bytes.
It is working for some records it is showing up the above error for some records
Encryption
string lid=l[0].id+'';
String key1 = Label.PWV_CryptoKey;
Blob Key = Blob.valueOf(key1);
Blob data = Blob.valueOf(lid);
Blob encryptedData = Crypto.encryptWithManagedIV('AES128', key, data);
String b64Data = EncodingUtil.base64Encode(encryptedData);
string leaURL =Label.PWV_FavoriteURL+'lid='+b64Data;
l[0].Encrypted_URL__c =leaURL;
=========================================================
Decryption:
String key1 = Label.PWV_CryptoKey;
Blob Key = Blob.valueOf(key1);
oid=ApexPages.currentPage().getParameters().get('oId');
Blob data = EncodingUtil.base64Decode(oid);
Blob decryptedData = Crypto.decryptWithManagedIV('AES128', key, data);
String decryptedDataString = decryptedData.toString();