Thursday, 24 April 2014

Encryption in salesforce

Hi

The methods in the Crypto class provide standard algorithms for creating digests, message authentication codes, and signatures, as well as encrypting and decrypting information.
These can be used for securing content in Force.com, or for integrating with external services such as Google or Amazon WebServices (AWS).

Example code for Crypto class

public class HMacAuthCallout1 {

   public void testAlexaWSForAmazon() {
      system.debug('----Checking time-----------'+timestamp);
      String action = 'salesforce Key';
      String inputStr = action;
      String algorithmName = 'SHA1';
      Blob mac = Crypto.generateDigest(algorithmName,  Blob.valueOf(inputStr));
      system.debug('-------------'+mac);
      String md5Coded = EncodingUtil.convertToHex(mac);
      system.debug('------SHA1 Code------------'+md5Coded);     
  }
}

For more information about crypto class

http://www.salesforce.com/us/developer/docs/dbcom_apex250/Content/apex_classes_restful_crypto.htm

you can check the encrypted code in

http://sha.shadecrypt.fr/SHA1-SHA256-SHA384-SHA512/encrypt.html

No comments:

Post a Comment