> For the complete documentation index, see [llms.txt](https://docs.csml.dev/language/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.csml.dev/language/standard-library/crypto/base64-hex.md).

# Base64, Hex

You can easily encode and decode data to and from Base64 and Hex:

```cpp
say Base64("Winter is coming 🥶").encode() // V2ludGVyIGlzIGNvbWluZyDwn6W2
say Base64("V2ludGVyIGlzIGNvbWluZyDwn6W2").decode() // Winter is coming 🥶

say Hex("Winter is coming 🥶").encode() // 57696e74657220697320636f6d696e6720f09fa5b6
say Hex("57696e74657220697320636f6d696e6720f09fa5b6").decode() // Winter is coming 🥶
```

This can for example be useful when using Basic Auth in HTTP calls:

```cpp
do auth = Base64("user:password").encode()

do HTTP("https://example.com")
  .set({ "Authorization": "Basic {{auth}}" })
  .send()
```

But in general, they are useful methods to encode/decode non-URL-safe or non-ASCII data to ensure exchanges between systems run smoothly.

{% hint style="info" %}
Base64 and Hex are **NOT** encryption methods!
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.csml.dev/language/standard-library/crypto/base64-hex.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
