[SalesForce] encrypt email address in a data extension

I'd like to encrypt email address in a data extension with SHA256 within marketing cloud. This will be used as a unique identifier.

  1. When the email goes into a data extension, have the email address in one column but in another column, have the SHA256 encryption generated.
  2. Once it's there, update all subscribers attribute with this encryption.
  3. Keep this constant for every subscriber that goes into the data extension.

I'm trying to get some ideas on where to start. Would ssjs be my best option or sql?

Best Answer

Little late on the answer but I've been working on this recently and someone might find this information useful.

If you are looking to do an encryption on data once it is inside Marketing Cloud the 2 main ways to do this would be with SQL activity or script activity.

SSJS only support MD5 hashes so this is fairly limiting. AMPscript does have more support for SHA256 but as you noted in the question you cannot use SSJS + AMPscript in an Automation Studio activity.

With SQL activity you can use the HASHBYTES function, making sure you cast and convert the values in the right way. This could be run on a schedule.

CONVERT(NVARCHAR(MAX), 
HASHBYTES('SHA2_256', CAST('hellowworld' as varchar(350))),
2) as EncryptedValue

To update the All Subscribers attributes typically an export, transfer and import activity to the All Subscribers list via csv is common practice.

Related Topic