File: mg_base64_X.md

package info (click to toggle)
civetweb 1.16%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 4,576 kB
  • sloc: ansic: 32,463; cpp: 1,374; sh: 480; javascript: 204; makefile: 119; php: 11; perl: 6; python: 3
file content (36 lines) | stat: -rw-r--r-- 1,568 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# Civetweb API Reference

### `mg_base64_encode( src, src_len, dst, dst_len );`
### `mg_base64_decode( src, src_len, dst, dst_len );`

### Parameters `base64_encode`

| Parameter | Type | Description |
| :--- | :--- | :--- |
|**`src`**|`const unsigned char *`|Source buffer containing bytes to be encoded into BASE-64 code.|
|**`src_len`**|`size_t`|Number of bytes in source buffer to be encoded.|
|**`dst`**|`char *`|Destination string buffer.|
|**`dst_len`**|`size_t *`|Pointer to a variable containing the available size of the destination buffer in bytes.|

### Parameters `base64_decode`

| Parameter | Type | Description |
| :--- | :--- | :--- |
|**`src`**|`const char *`|Source string containing BASE-64 encoded data.|
|**`src_len`**|`size_t`|Number of bytes in the source buffer to be decoded.|
|**`dst`**|`unsigned char *`|Destination byte buffer.|
|**`dst_len`**|`size_t *`|Pointer to a variable containing the available size of the destination buffer in bytes.|

### Return Value

| Type | Description |
| :--- | :--- |
|`int`|Error information. -1 indicates success.|

### Description

The function `mg_base64_encode()` encodes the source buffer into the destination buffer using BASE-64 encoding.
The function `mg_base64_decode()` reads a BASE-64 encoded source buffer and decodes it into the destination buffer.
Both functions return -1 on success.
If the destination buffer is not big enough, the functions return 0.
If the source buffer supplied to `mg_base64_decode()` contains invalid characters, the return value is the position of this character.