---
title: Hashing and encoding
slug: campaign/docs/hashing-and-encoding
docTags: 
createdAt: 2026-07-20T15:45:09.814Z
---

This topic describes how to encode data and create hash values using field functions.

:::hint{type="info"}
**Note**

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.

:::hint{type="info"}
**Note**

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:

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

:::hint{type="info"}
**Tip**

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.

:::hint{type="info"}
**Note**

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

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

### ODR

```html
<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.

```velocity
#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.

:::hint{type="info"}
**Note**

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:

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

## SHA256 and Base64

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

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