# base64

<a id="base64"></a>

# base64

Base64 encoding and decoding helpers.

## Classes

| Name | Description |
|------|-------------|
| [`Decoder`](https://auscaster.com/icey/docs/api-reference/icy-base64-Decoder.md#decoder-3) | Base64 decoder. |
| [`Encoder`](https://auscaster.com/icey/docs/api-reference/icy-base64-Encoder.md#encoder-3) | Base64 encoder. |

## Functions

| Return | Name | Description |
|--------|------|-------------|
| `size_t` | [`encodedBufferCapacity`](#encodedbuffercapacity) `inline` | Returns a safe temporary buffer size for encoding up to `inputSize` bytes. Includes padding/newline slack so callers can reuse the same buffer for finalize(). |
| `std::string` | [`encode`](#encode-16) `inline` | Encodes an STL byte container to a Base64 string. |
| `std::string` | [`decode`](#decode-5) `inline` | Decodes a Base64-encoded STL container to a binary string. |

---

<a id="encodedbuffercapacity"></a>

### encodedBufferCapacity

`inline`

```cpp
inline size_t encodedBufferCapacity(size_t inputSize, int lineLength = LINE_LENGTH)
```

[Defined in src/base/include/icy/base64.h:89](https://github.com/auscaster/icey/blob/main/src/base/include/icy/base64.h#L89)

Returns a safe temporary buffer size for encoding up to `inputSize` bytes. Includes padding/newline slack so callers can reuse the same buffer for finalize().

---

<a id="encode-16"></a>

### encode

`inline`

```cpp
template<typename T> inline std::string encode(const T & bytes, int lineLength = LINE_LENGTH)
```

[Defined in src/base/include/icy/base64.h:189](https://github.com/auscaster/icey/blob/main/src/base/include/icy/base64.h#L189)

Encodes an STL byte container to a Base64 string. 
#### Returns
Base64-encoded string.

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `bytes` | `const T &` | Input data container. |
| `lineLength` | `int` | Characters per line in the output (0 disables wrapping). |

---

<a id="decode-5"></a>

### decode

`inline`

```cpp
template<typename T> inline std::string decode(const T & bytes)
```

[Defined in src/base/include/icy/base64.h:314](https://github.com/auscaster/icey/blob/main/src/base/include/icy/base64.h#L314)

Decodes a Base64-encoded STL container to a binary string. 
#### Returns
Decoded binary string.

#### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `bytes` | `const T &` | Input Base64 data container. |

## Variables

| Return | Name | Description |
|--------|------|-------------|
| `constexpr int` | [`BUFFER_SIZE`](#buffer_size) `constexpr` |  |
| `constexpr int` | [`LINE_LENGTH`](#line_length) `constexpr` |  |

---

<a id="buffer_size"></a>

### BUFFER_SIZE

`constexpr`

```cpp
constexpr int BUFFER_SIZE = 16384
```

[Defined in src/base/include/icy/base64.h:31](https://github.com/auscaster/icey/blob/main/src/base/include/icy/base64.h#L31)

---

<a id="line_length"></a>

### LINE_LENGTH

`constexpr`

```cpp
constexpr int LINE_LENGTH = 72
```

[Defined in src/base/include/icy/base64.h:32](https://github.com/auscaster/icey/blob/main/src/base/include/icy/base64.h#L32)
