# Base64 Module

Simple, fast base64 encoding/decoding service. Import

```
import base64 from 'base64';
```

### Methods

[encode(value)](https://docs.medable.com/reference#section-encode-value-)\
[decode(value, asBuffer)](https://docs.medable.com/reference#section-decode-value-asbuffer-)

### encode(value)

Encode a string.

**Arguments**

* `value` (String) a string to base64 encode

**Returns**

* `value` (String) a base64 encoded string

### decode(value, asBuffer)

Decode a string into a string or buffer.

**Arguments**

* `value` (String) a base64 string to decode
* `asBuffer` (Boolean=false) If true, returns a buffer instead of a string.

**Returns**

* `value` (String|Buffer) a decoded string/buffer

### Examples

Encode Example

```
import base64 from 'base64'
return base64.encode('Hold Me, Thrill Me, Encode Me')
```

Encode Response

```
{
    "object": "result",
    "data": "SG9sZCBNZSwgVGhyaWxsIE1lLCBFbmNvZGUgTWU="
}
```

Decode Example

```
import base64 from 'base64'
return base64.decode('SG9sZCBNZSwgVGhyaWxsIE1lLCBFbmNvZGUgTWU=')
```

Decode Response

```
{
    "object": "result",
    "data": "Hold Me, Thrill Me, Encode Me"
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.medable.com/cortex-api/scripting/modules-1/base64-module.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
