Skip to content

Instantly share code, notes, and snippets.

@MyCueCards
Created August 9, 2021 16:51
Show Gist options
  • Save MyCueCards/d03ed61dfaef17da8bde4ca350d1a4d8 to your computer and use it in GitHub Desktop.
Save MyCueCards/d03ed61dfaef17da8bde4ca350d1a4d8 to your computer and use it in GitHub Desktop.
Basic example of AMPScript SHA256() function, returning SHA256 hash tag based on the string value
%%[
SET @CheckForEmail = IsEmailAddress(_SubscriberKey)
IF @CheckForEmail == 'false' THEN
SET @FinalSubscriberKey = _SubscriberKey
ELSE
SET @FinalSubscriberKey = SHA256(_SubscriberKey,'UTF-16')
ENDIF
SET @Link = CONCAT('https://[DomainStuffHere]?mcsubkey=', @FinalSubscriberKey)
]%%
<p>
<strong>Staging URL with AMPScript =</strong> <a href="%%=RedirectTo(@Link)=%%">%%=RedirectTo(@Link)=%%</a>
</p>
<p>
<strong>1. SubscriberKey (original) =</strong> %%_SubscriberKey%%
<br>
<strong>2. SubscriberKey (if email true) =</strong> %%=v(@FinalSubscriberKey)=%%
</p>
<hr>
<p>
Salesforce Documentation: https://developer.salesforce.com/docs/atlas.en-us.noversion.mc-programmatic-content.meta/mc-programmatic-content/SHA256.htm
</p>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment