Created
January 26, 2014 10:49
-
-
Save msrivastav13/8631081 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Code for Encryption | |
string xldata='<data>xml sample data</data>'; | |
blob b=blob.valueOf(xldata); | |
Blob encryptedData = Crypto.encryptWithManagedIV('AES256',blob.valueOf('00000000000000000000000000000000'), b); | |
//String blobstr=encryptedData.toString();//Not Effective and generates ERROR BLOB is not Valid UTF-8 String | |
String b64=EncodingUtil.base64Encode(encryptedData); | |
system.debug('&&&&'+b64);//Store this in a Custom Long Text Field as this is a String | |
//Code for Decryption | |
Blob b64decoded=EncodingUtil.base64Decode(b64); | |
Blob decryptedData = Crypto.decryptWithManagedIV('AES256', blob.valueOf('00000000000000000000000000000000'),b64decoded); | |
system.debug('&&&&'+decryptedData.tostring()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
how this encryption works what is the out put