I am working on simple encryption using the crypto class to encrypt some data fields in salesforce. The encryption class works fine for text data with max size 255. however i need to reduce the encrypted data size once encrypted.
This is sample encryption login i am using to encrypt the data.
for(Account a : scope)
{
Blob stringencry =Blob.valueOf(a.phone);
Blob encrypted = Crypto.encryptWithManagedIV('AES256', seckey, stringencry);
String b64=EncodingUtil.base64Encode(encrypted);
a.phone=b64;
}
The above logic works fine for text data type variable however the same could not be implemented for other data types like phone,url or any others .While saving the records i am receiving the "STRING_TOO_LONG" error from salesforce.
So post encryption there has to be a way in restricting the encrypted size of the data.Any light on this is great help to me.