Hashing and encoding

This topic describes how to encode data and create hash Algorithm that encodes digital content using a unique combination of numbers and letters, making it uniquely identifiable. In email marketing, the generated hash values enable content to be uniquely identified without making personal data such as the email address visible. values using field functions.

Use your specific data and recipient list fields, and test the field functions before using them in a mailing.

Base64

Base64 is an encoding method to not display data in clear text.

Base64 is not an encryption method, as you can decode the encoded data.

To encode the content of a recipient list field using Base64, you can use the following Velocity code as a default replacement:

#if(!$StringHelper.isEmpty($!user.data.RECIPIENTLISTFIELD))${bmMisc.encodeBase64($user.data.RECIPIENTLISTFIELD)}#end

Since the contents of recipient list fields can also be empty (unknown, NULL value), the code example converts possible NULL values into empty string values.

MD5

MD5 is a hash method that lets you create checksums, for example to verify data integrity.

MD5 is not an encryption method. Hashing is not reversible. In addition, MD5 is not collision free, because different inputs can lead to the same hash value.

The following field function templates additionally use a key to increase the security factor:

Velocity

#set ($key = "1234567890")
#set ($string = "STRINGWERT$key")
$StringHelper.md5($string)

ODR

<odr:set var="key" value="1234567890" />
<odr:set var="string" value="STRINGWERT%{key}" />
<odr:out value="%{md5(string)}" />

MD5 and Base64

The following Velocity code uses a key (0123456789) for MD5 hashing. The recipient data is encoded using Base64. The code also checks if the recipient list field is empty. Finally, the function $StringHelper.md5() generates a hash value from the sequential Base64 values.

#set($key = "0123456789")
#set($email = "$bmMisc.encodeBase64($!user.data.email)")
#if(!$StringHelper.isEmpty($!user.data.salutation))
  #set($salutation = "$bmMisc.encodeBase64($!user.data.salutation)")
#end
#if(!$StringHelper.isEmpty($!user.data.firstname))
  #set($firstname = "$bmMisc.encodeBase64($!user.data.firstname)")
#end
#if(!$StringHelper.isEmpty($!user.data.lastname))
  #set($lastname = "$bmMisc.encodeBase64($!user.data.lastname)")
#end
#if(!$StringHelper.isEmpty($!user.data.sender))
  #set($sender = "$bmMisc.encodeBase64($!user.data.sender)")
#end
#set($name = "$bmMisc.encodeBase64($mailing.name)")
#if(!$StringHelper.isEmpty($!user.data.shopsource))
  #set($shopsource = "$bmMisc.encodeBase64($!user.data.shopsource)")
#end
#set($string = "$!email$!salutation$!firstname$!lastname$!sender$!name$!shopsource$!key")
$StringHelper.md5("$string")

SHA256

SHA256 is another method to create hash values from recipient data.

SHA256 can only process String values in Velocity.

To encode the content of a recipient list field using SHA256, you can use the following Velocity code as your default replacement:

#set($string = "STRINGVALUE")
$StringHelper.sha256($string)

SHA256 and Base64

The following Velocity Code uses SHA256 and Base64 to encode the recipient's email address:

${bmMisc.hashSha256AndEncodeBase64($user.data.email)}