function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
deepakpideepakpi 

Crypto.encryptWithManagedIV throws internal server error

Hi,

 

When I use below code I am getting internal server error.

 

 

String hexkey='CE993A13754340D1FED14A9EFB4A058D'; // given by 3rd part app developer

Blob b=Blob.valueOf(hexkey);

Blob encryptedBlob=Crypto.encryptWithManagedIV('AES128', b, 'some clear text' );

 

Did anybody face similar issue before?

 

Thanks,

Deepak

 

Pradeep_NavatarPradeep_Navatar

It seems that you have passed wrong type of parameter in method as given below :

 

Blob encryptedBlob=Crypto.encryptWithManagedIV('AES128', b, 'some clear text' );

 

3rd parameter of this method must be the Blob type. So first you need to convert it string to Blob and then pass to method.

 

Blob encryptedBlob=Crypto.encryptWithManagedIV('AES128', b, Blob.valueOf('some clear text' ));

 

Hope this helps.