• Raushan Anand
  • NEWBIE
  • 0 Points
  • Member since 2014


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 2
    Replies
Hi All,

   How to get current record id using formula fields (Hyperlink) ?

Thanks

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();