---
url: >-
  /statelake/scripting-reference/functions-and-procedures/encryption-and-encoding-functions/base64decode.md
---

# Base64Decode

**Base64Decode** decodes the input value using Base64.

**Base64** encoding/decoding is commonly used when there is a need to encode binary data for transfer over media that is designed to deal with **plain text** data.

This is to avoid the situation where a binary data character could be mistakenly interpreted as a control character or as an invalid character, and thus cause the data packet to be interrupted or become corrupted.

Base64 is used in a number of common applications, such as storing complex data in XML.

**Declaration**: Function Base64Decode( Input : string) : String;

Examples follow, also illustrating **Base64Encode**.

```pascal
procedure OnMapEvent(var Value:Variant);
var
  vOriginal, vEncoded, vDecoded: string;
begin
  vOriginal := 'cameron';
  vEncoded := Base64Encode(vOriginal);     // value will be 'Y2FtZXJvbg=='
  vDecoded := Base64Decode(vEncoded);      // value will be back to 'cameron'
  LogInfo('Original is - '+vOriginal);
  LogInfo('Encoded is - '+vEncoded);
  LogInfo('Decoded is - '+vDecoded);
  LogInfo('');

  vOriginal := 'Cameron';
  vEncoded := Base64Encode(vOriginal);      // value will be 'Q2FtZXJvbg=='
  vDecoded := Base64Decode(vEncoded);       // value will be back to 'Cameron'
  LogInfo('Original is - '+vOriginal);
  LogInfo('Encoded is - '+vEncoded);
  LogInfo('Decoded is - '+vDecoded);
  LogInfo('');

  vOriginal := 'Bugsy Malone';
  vEncoded := Base64Encode(vOriginal);      // value will be 'QnVnc3kgTWFsb25l'
  vDecoded := Base64Decode(vEncoded);       // value will be back to 'Bugsy Malone'
  LogInfo('Original is - '+vOriginal);
  LogInfo('Encoded is - '+vEncoded);
  LogInfo('Decoded is - '+vDecoded);

end;
```
