Decrypt the email address from cryptstring id=<%= escapeUrl(cryptString(targetData.email)) %> | Community
Skip to main content
Level 5
August 21, 2024
Solved

Decrypt the email address from cryptstring id=<%= escapeUrl(cryptString(targetData.email)) %>

  • August 21, 2024
  • 1 reply
  • 3257 views

Hi there,

"I am passing the recipient's email through a survey URL generated in Adobe Campaign and need to decrypt this email address. I'm using a JavaScript function to extract the email parameter from the URL, decrypt it, and send the data to a table. However, the decrypted string is still appearing as an encrypted string for some reason."

 

?email_id=<%= escapeUrl(cryptString(targetData.email)) %>

 


function decryptString(encryptedEmail) {
// Implement your decryption logic here
return encryptedEmail; // Placeholder: returning the input as-is
}

// Function to decrypt and extract the email address from the URL
function getEmailFromUrl() {
const params = new URLSearchParams(window.location.search);
const encryptedEmail = params.get('email_id');

// Decrypt the email address using the decryptString function
const email = decryptString(encryptedEmail);
return email;
}

// Function to validate the survey, set values, and submit the form
function validate() {
// Get the email address from the URL
const email = getEmailFromUrl();

if (!email) {
alert("Error: Email address is missing.");
return false;
}

 

if (isValid) {
// Set the email address to the "Email_Address" path
document.controller.setValue("/ctx/FOD_SurveyResponse/@Email_Address", email);

// Submit the form if validation passed
document.controller.submit('next', '_self', 'next');
}

return isValid;
}

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by rvnth

Hello @rvnth 

In Javascript activity you can just use this

 

const decryptedEmail=decryptString(ctx.vars.email_id); 


Hi @_manoj_kumar_ ,

 

Thank you for your assistance. The code below successfully enabled me to decrypt the email string and store it in the corresponding schema column.

.

 

ctx.vars.key256Bytes = "fFKwuLzAsmMYoY6f1lxpMKuFSTWLCgdc"; ctx.vars.Email_Address = ctx.vars.Email_Address.toString(); ctx.FOD_SurveyResponse.@Email_Address = decryptString(ctx.vars.Email_Address, ctx.vars.key256Bytes);

 

 

1 reply

Manoj_Kumar
Community Advisor
Community Advisor
August 21, 2024

Hello @rvnth  This is because you have created a function with similar name it is not doing anything.

 

remove this code:

function decryptString(encryptedEmail) { // Implement your decryption logic here return encryptedEmail; // Placeholder: returning the input as-is }

 

Also, I would suggest you to some other identifier than email 

Manoj     Find me on LinkedIn
rvnthAuthor
Level 5
August 22, 2024

Hi @_manoj_kumar_ ,

 

Thank you for your response. After removing decryptString, I'm encountering an error stating that decryptString is not defined in the code block below. Since the Adobe decryptString function isn't working here, is there an alternative way to decrypt?

function getEmailFromUrl() { const params = new URLSearchParams(window.location.search); const encryptedEmail = params.get('email_id'); // Decrypt the email address using the decryptString function const email = decryptString(encryptedEmail); return email; }

Thank you in advance. 

 

Is it possible to decrypt this directly at the attribute level within the Schema, or do I need to send only the decrypted string data?

Manoj_Kumar
Community Advisor
Community Advisor
August 22, 2024

Hello @rvnth  You have to use this on server side and it won't work on client side.

Here is what you should to

  • Create a variable in variables tab of web applications and name it email_id
  • Then create a  parameter in parameters tab and name it email_id, now under storage select variable and use email_id variable to store the value.
  • Now use this code to decrypt it
    <% decryptString(ctx.vars.email_id); %>
Manoj     Find me on LinkedIn