• SOTI
  • NEWBIE
  • 0 Points
  • Member since 2010

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies

Hello,

 

I am trying to encrypt and decrypt a password using the Crypto class.

 

 

 try{
     Blob cryptoKey = Crypto.generateAesKey(128);
    	 Blob data = Blob.valueOf(weUserRec.password__c);
      Blob encryptedData = Crypto.encryptWithManagedIV('AES128', cryptoKey, data);
    
      Blob decrypt = Crypto.decryptWithManagedIV('AES128', cryptoKey, data);
 
  }catch(Exception e){
     System.debug(e.getMessage());
 }

 

The above is throwing an exception with message "Invalid initialization vector. Must be 16 bytes" (InvalidParameterValue).


Since the SF provided Managed IV methods are used here (the code is almost exactly like the sample), why does it throw this error?

Thanks.

  • November 24, 2010
  • Like
  • 0