Runtime verified Test scripts included

Hashes a string with an algorithm chosen by name and returns the digest as lowercase hex. Errors on a missing argument or an unknown algorithm or charset.

Syntax

{{encode ...options}}

Returns string.

Parameters

Name Type Required Description
options any Yes, repeatable Named arguments only: alg (md5, sha1, sha256 or sha512) and value (the text to hash) are required; charset is UTF-8 (default) or UTF-16.

Example

Tested in a Marketing Cloud Next email on 2026-11-22:

  • {{encode alg="sha256" value="abc"}} renders ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad, as documented.
  • {{encode alg="md5" value="abc"}} renders 900150983cd24fb0d6963f7d28e17f72, as documented.
Show Next test script
<!-- Marketing Cloud Next test script for the encode helper. Paste it into the HTML component of a
     Next email and open the preview. Each line prints the result Next gave when the call
     was rendered on its own (expect) next to the result of this run (got).
     Assembled from single-call test emails (dates on the page); it has not been
     run as one email. Calls that make Next fail are listed separately. -->
<p>c1 expect=[ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad] got=[{{encode alg="sha256" value="abc"}}]</p>
<p>c2 expect=[900150983cd24fb0d6963f7d28e17f72] got=[{{encode alg="md5" value="abc"}}]</p>

Marketing Cloud Next

Works as documented

Every tested call rendered the documented result. Tested 2026-11-22 by rendering in a Marketing Cloud Next email.

See also