Activity Forums Salesforce® Discussions How to encrypt and decrypt data in Apex ?

  • How to encrypt and decrypt data in Apex ?

     Marziya updated 12 months ago 3 Members · 3 Posts
  • Kirandeep

    Member
    October 20, 2020 at 4:46 pm

    How to encrypt and decrypt data in Apex ?

  • Anjali

    Member
    October 21, 2020 at 2:15 pm

    we can encrypt and decrypt data in apex by using crypto class.

  • Marziya

    Member
    October 21, 2020 at 2:17 pm

    `//Data to encrypt`
    `Blob data = Blob.valueOf(``'Biswajeet Samal'``);`
    `//Generate an AES key for the encryption. `
    `Blob cryptoValue = Crypto.generateAesKey(``256``);`
    `//Encrypt the data`
    `Blob encryptedData = Crypto.encryptWithManagedIV(``'AES256'``, cryptoValue, data);`
    `//Decrypt the data - the first 16 bytes contain the initialization vector`
    `Blob decryptedData = Crypto.decryptWithManagedIV(``'AES256'``, cryptoValue, encryptedData);`
    `
    `

    • This reply was modified 12 months ago by  Marziya.
    • This reply was modified 12 months ago by  Marziya.
Viewing 1 - 3 of 3 posts

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos