+ Start a Discussion
PRepakaPRepaka 

encryption and decryption

hi
 
can u please tell me how to do encryption and decryption in SFDC?
 
my Requirement is:
 
When they store data in SFDC that is stored in an encrypted format. Then we want a locally installed encryption and decryption routine that would convert what was stored in the database and display it on the screen. This needs to work within the SFDC UI however the only person that would have the decryption code would be the person that own the PC.
 
can u please help for doing this encryption and decryption.
sneha_namdeosneha_namdeo

Hi,

 

Even I have a similar issue. i'm able to store the data in encrypted format but when I try and retrieve it back from the object and after decrypting it, it is displayed in the following manner --> e.g. : Blob[16] , where 16 is number of characters in input string.

 

Please help me with a method in which I can display the decrypted string.

 

Thanks in advance.

 

MoUsmanMoUsman
Hi,
You can use these methods to encrypt and decrypt your string after encrypt you can save it to data base and you can decrypt it after get retrive as well.
    /*
    @Param:String to be encrypt
    @return:encrypted String
    */
    public static String toEncryptString(String toEncrypt){
    if(toEncrypt != null){
                 Blob encrypted = Blob.valueOf(toEncrypt);
                 return EncodingUtil.base64Encode(encrypted); 
    }
    return null;
    }
    /*
    @Param:String to be decrypt
    @return:decrypted String
    */
    public static String toDecryptString(String toDecrypt){
    if(toDecrypt != null){
              Blob decrypted = EncodingUtil.base64Decode(toDecrypt);
              return decrypted.toString();
    }
    return null;
    }
 
I hope it will help you :)
Thanks
Mohammad Usman
Atif MohammedAtif Mohammed
i have already encrypted and cardnumber but i want to decrypt the cardnumber and hit the gateway of authorize.net and doback again the encryption.

cardnumber is an variable which we have Card_Number__c=cardnumber;



/*
@Param:String to be decrypt
@return:decrypted String
*/
public static String toDecryptString(String cardnumber){
if(cardnumber!= null){
Blob decrypted = EncodingUtil.base64Decode(cardnumber);
return decrypted.toString();
}
return null;
}

Please do guide me in doing decrypting of encrypted custom field.

Regards,
Atif