Monday, October 20, 2014

Encrypting and decrypting String

Blob data = Blob.valueOf('Test data to encrypted');
Blob cryptoValue = Crypto.generateAesKey(256);
Blob encryptedData = Crypto.encryptWithManagedIV('AES256', cryptoValue, data);
Blob decryptedData = Crypto.decryptWithManagedIV('AES256', cryptoValue, encryptedData);
String decryptedDataString = decryptedData.toString();
System.debug(decryptedDataString);

No comments:

Post a Comment