Activity Forums Salesforce® Discussions What is Apex crypto class and how to use it in salesforce?

  • sushant

    Member
    February 1, 2017 at 1:01 pm
  • Avnish Yadav

    Member
    September 9, 2018 at 8:15 am

    Hello,

    What is Apex Crypto Class?

    The Apex Crypto class provides a number of cryptographic functions for creating digests, message authentication codes, and signatures, as well as encrypting and decrypting information. This allows you to encrypt or decrypt information in Force.com or integrate with external services that require these functions.

    How to use Apex Crypto Class in Salesforce?

    The Crypto class provides the following functions to encrypt and decrypt using the AES algorithm:

    • encrypt()
    • decrypt()
    • encryptWithManagedIV()
    • decryptWithManagedIV()

    encrypt(algorithmName, privateKey, initializationVector, clearText)-Encrypts the Blob clearText using the specified algorithm, private key, and initialization vector. Use this method when you want to specify your own initialization vector.

    decrypt(algorithmName, privateKey, initializationVector, cipherText) - Decrypts the Blob cipherText using the specified algorithm, private key, and initialization vector. Use this method to decrypt blobs encrypted using a third party application or the encrypt method.

    encryptWithManagedIV(algorithmName, privateKey, clearText) -Encrypts the Blob clearText using the specified algorithm and private key. Use this method when you want Salesforce to generate the initialization vector for you.

    decryptWithManagedIV(algorithmName, privateKey, IVAndCipherText) -Decrypts the Blob IVAndCipherText using the specified algorithm and private key. Use this method to decrypt blobs encrypted using a third party application or the encryptWithManagedIV method.

    Hope this will help.

    Source - Salesforce developer Guide.

    Thanks.

     

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos