Use AMPscript functions to encrypt and decrypt information stored in a custom data extension. The necessary AMPscript includes the EncryptSymmetric() and DecryptSymmetric() functions.
- Create the necessary keys.
- Create the information in the data extension you wish to encrypt.
- Include the AMPscript to perform the necessary encryption.
Example
This example encrypts the plain text value ExampleData using provided values and then decrypts that variable. The @null variable represents an undeclared variable.
%%[
SET @encData=EncryptSymmetric("ExampleData", "AES", @null, "password", @null, "0000000000000000", @null, "00000000000000000000000000000000")
SET @clearData=DecryptSymmetric(@encData, "AES", @null, "password", @null, "0000000000000000", @null, "00000000000000000000000000000000")
]%%
This example accomplishes the same task using external keys instead of provided values.
%%[
SET @encData=EncryptSymmetric("ExampleData", "AES", "passwordExternalKey", @null, "saltExternalKey", @null, "IVExternalKey", @null)
SET @clearData=DecryptSymmetric(@encData, "AES", "passwordExternalKey", @null, "saltExternalKey", @null, "IVExternalKey", @null)
]%%