> For the complete documentation index, see [llms.txt](https://www.ctfrecipes.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.ctfrecipes.com/cryptography/general-knowledge/encoding/data-encoding/base64.md).

# Base64

**Base64** is a binary-to-text encoding scheme that represents binary data as a sequence of 64 characters (letters and numbers).

## How it works

Base64 encoding works by dividing the binary data into 6-bit blocks and then representing each block as a character in a predefined set of 64 characters.

The symbol "=" is used as padding.

This results in a representation that is more compact than the original binary data, making it easier to store or transmit.

## Python

```python
import base64

data = b"SomeData"

encoded = base64.b64encode(data)

decoded = base64.b64decode(encoded)
```

## Resources

{% embed url="<https://gchq.github.io/CyberChef/#recipe=To_Base64(>" %}

{% embed url="<https://www.dcode.fr/base-64-encoding>" %}
