cryptString returns different results when applied in typology rule or directly in an email | Adobe Higher Education
Skip to main content
Level 4
February 2, 2024
Beantwortet

cryptString returns different results when applied in typology rule or directly in an email

  • February 2, 2024
  • 4 Antworten
  • 1688 Ansichten

Hi community! 

I am attempting to implement list-unsubscribe and list-unsubscribe POST in all our email smtp headers. 

The approach is that I have a webApp that accepts a POST call with an encrypted userId that I then decrypt in order to decline permission in our backend system. 

This all works when I manually add the smtp headers in an email like so: 
List-Unsubscribe-Post: List-Unsubscribe=One-Click
List-Unsubscribe: <https://tv2-mkt-prod1.campaign.adobe.com/tv2/oneClickOptOut.jssp?id=<%=cryptString(recipient.auth0)%>>

 

However when I implement a typology to do the same on all deliveries, the encrypted string is different, and I am no longer able to decrypt it in the webApp. 

 

Any pointers to why this might happen and possibly how I can solve it? 

 

I am using decryptString(encryptedString) to solve the task in the webApp.

Dieses Thema wurde für Antworten geschlossen.
Beste Antwort von Amine_Abedour

Hello @sorendp,

 

At what phase of the delivery preparation is your typo rule applied ? 

You should apply it at the start of personalization phase.

Please find mor info here.

Br,

Amine ABEDOUR 

 

 

 

 

4 Antworten

Amine_Abedour
Community Advisor
Community Advisor
February 2, 2024

Hello @sorendp,

 

At what phase of the delivery preparation is your typo rule applied ? 

You should apply it at the start of personalization phase.

Please find mor info here.

Br,

Amine ABEDOUR 

 

 

 

 

Amine ABEDOUR
SorenDPAutor
Level 4
February 2, 2024

Hi @amine_abedour 

 

Thank you very much for the reply! 


The rule is applied at personalization phase. 

 

For reference, this is the code that is implemented for the rule: 

// Define the unsubscribe URL var headerUnsubUrl ="https://tv2-mkt-prod1.campaign.adobe.com/tv2/oneClickOptOut.jssp?id=<%= cryptString(recipient.auth0)%>" // Get the value of the List-Unsubscribe header var headerUnsub = getHeader(delivery.mailParameters.headers, 'List-Unsubscribe') // If the List-Unsubscribe header does not exist if (headerUnsub === '') { // Add the List-Unsubscribe header delivery.mailParameters.headers = addHeader(delivery.mailParameters.headers,'List-Unsubscribe','<' + headerUnsubUrl + '>') } // If the List-Unsubscribe header exists and contains 'mailto' else if (headerUnsub.search('mailto')) { // Replace the existing List-Unsubscribe header delivery.mailParameters.headers = addHeader(delivery.mailParameters.headers,'List-Unsubscribe','<' + headerUnsubUrl + '>') } // Get the value of the List-Unsubscribe-Post header var headerUnsubPost = getHeader(delivery.mailParameters.headers,'List-Unsubscribe-Post') // If the List-Unsubscribe-Post header does not exist if (headerUnsubPost === '') { // Add the List-Unsubscribe-Post header delivery.mailParameters.headers = addHeader(delivery.mailParameters.headers,'List-Unsubscribe-Post','List-Unsubscribe=One-Click') } // Return true to indicate success return true // Function to add or replace a header in the provided headers function addHeader (headers, header, value) { // Create the new header line var headerLine = header + ': ' + value // Create a regular expression to find the specified header var regExp = new RegExp(header + ':(.*)$', 'i') // Split the headers into individual lines var headerLines = headers.split('\n') // Loop through each line for (var i = 0; i < headerLines.length; i++) { // Check if the specified header exists var match = headerLines[i].match(regExp) // If it exists if (match != null) { // Replace the existing header line headerLines[i] = headerLine // Return the modified headers return headerLines.join('\n') } } // If the header does not exist, add the new header line headerLines.push(headerLine) // Return the modified headers return headerLines.join('\n') } // Function to get the value of a specified header from the provided headers function getHeader(headers, header) { // Create a regular expression to find the specified header var regExp = new RegExp(header + ':(.*)$', 'i') // Split the headers into individual lines var headerLines = headers.split('\n') // Loop each line for each(line in headerLines) { // Check if the specified header exists var match = line.match(regExp) // If it exists if (match != null) { // Return the header value, removing leading whitespace return match[1].replace(/^\s*/, '') } } // If the header does not exist, return an empty string return '' }

 

DavidKangni
Community Advisor
Community Advisor
February 2, 2024

@sorendp 

The cryptString() function is salted with the time, so will never produce the specific value you've been asked to get.

If you encrypt same string with same password and without salt, you will get same result

Thanks,

David

David Kangni
SorenDPAutor
Level 4
February 9, 2024

Hi @davidkangni 
Thanks for the response! That makes total sense! Right now I am struggling to disable the use of salt. I am currently doing this in the typology rule, but it keeps giving different results each time it is run for the same input: 

 

// Define the unsubscribe URL var headerUnsubUrl ="https://tv2-mkt-prod1.campaign.adobe.com/tv2/oneClickOptOut.jssp?id=<%= cryptString(recipient.auth0, '', false)%>"

 

EDIT: It seems that the typology rule simply cannot read from the recipient table... So <%=recipient.XYZ%> results in undefined. Can't figure out how I am supposed to go about that challenge.

_Manoj_Kumar_
Community Advisor
Community Advisor
February 5, 2024

Hello @sorendp 

 

Check the value of the XtkKey Option. It should be the same for marketing and frontal servers.

 

Also, I wouldn't focus on this one because only Gmail supports the URL subscribe functionality.

For now, it is best to work with the List-unsubscribe email header because it is widely supported.

     Manoj     Find me on LinkedIn
March 13, 2024

Hi @sorendp 

 

We are in the process of implementing list-unsubscribe post in the smtp header. Similar to what you have shared in your query. I have few questions, appreciate if you can help me with it.

 1. I can see that you have mentioned that you are implementing a webapp method and the url mentioned in List Unsubscribe is refereeing to a jssp script. Can you please share more details on how you implemented this. 

2. The Campaign server is hosted in our own server and is not hosted on Adobe servers. Do you suggest any configuration changes to make this implementation work?

Happy to connect with you personally to learn more on how you have implemented it in your instance.