Base64Encode

This function Base64 encodes a string.

Arguments

Base64Encode(1,2)

Ordinal Type Required Description
1 String True String value to encode
2 String False Optional .NET character-encoding type to utilize in encoding. Valid values are ASCII, UTF-7, UTF-8, UTF-16, and UTF-32.

Example

%%[

var @str
var @enc
var @encASCII
var @encUTF7
var @encUTF8
var @encUTF16
var @encUTF32

set @str = "doug@limedash.com"

set @enc = Base64Encode(@str)
set @encASCII = Base64Encode(@str, "ASCII")
set @encUTF7 = Base64Encode(@str, "UTF-7")
set @encUTF8 = Base64Encode(@str, "UTF-8")
set @encUTF16 = Base64Encode(@str, "UTF-16")
set @encUTF32 = Base64Encode(@str, "UTF-32")

]%%
str: %%=v(@str)=%%
<br>enc: %%=v(@enc)=%%
<br>encASCII: %%=v(@encASCII)=%%
<br>encUTF7: %%=v(@encUTF7)=%%
<br>encUTF8: %%=v(@encUTF8)=%%
<br>encUTF16: %%=v(@encUTF16)=%%
<br>encUTF32: %%=v(@encUTF32)=%%

Output

str: doug@limedash.com
enc: ZG91Z0BsaW1lZGFzaC5jb20=
encASCII: ZG91Z0BsaW1lZGFzaC5jb20=
encUTF7: ZG91ZytBRUEtbGltZWRhc2guY29t
encUTF8: ZG91Z0BsaW1lZGFzaC5jb20=
encUTF16: ZABvAHUAZwBAAGwAaQBtAGUAZABhAHMAaAAuAGMAbwBtAA==
encUTF32: ZAAAAG8AAAB1AAAAZwAAAEAAAABsAAAAaQAAAG0AAABlAAAAZAAAAGEAAABzAAAAaAAAAC4AAABjAAAAbwAAAG0AAAA=