I have a form on cloudpages, my question is if it is possible to be able to encode one of the fields in md5, to send it to the DE as subscriberkey.
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It only takes a minute to sign up.Sign up to join this community
Based on their documentation
Platform.Load('Core','1') var email = Request.GetFormField('NAME_OF_EMAIL_FIELD'); var email_md5 = Platform.Function.MD5(email,"UTF-8"); // ... insert into DE
Now MD5 is not the greatest as it's known that you can generate the same hash (although very unlikely). A more secure way would be to implement SHA256 with an SSJS/AMPScript mix.
Platform.Load('Core','1') var email = Request.GetFormField('NAME_OF_EMAIL_FIELD'); Platform.Function.TreatAsContent("%%[var @email_sha set @email_sha = SHA256('"+email+"','UTF-16')]%%"); var email_sha = Variable.GetValue("@email_sha"); // ... insert into DE
Note: I've done this in production before but my code here is untested as I'm writing this off the top of my head with their documentation.