base32_encode
Encode a UTF-8 string to Base32 using the standard alphabet (RFC 4648 §6). The standard alphabet uses uppercase A–Z and digits 2–7. Output always includes = padding to make the length a multiple of 8 characters.
For output using the extended hex-compatible alphabet (0–9, A–V), use base32_encode_hex instead.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | Yes | The UTF-8 string to encode. |
Response
| Field | Type | Description |
|---|---|---|
output | string | The Base32-encoded string. |
Examples
Encode a plain ASCII string
{
"input": "hello world"
}
Result:
{
"output": "NBSWY3DPEB3W64TMMQ======"
}
Encode a short string and observe padding
Base32 outputs are always padded to a multiple of 8 characters. A single byte produces 8 output characters including 6 = padding chars:
{
"input": "a"
}
Result:
{
"output": "ME======"
}
Errors
Each failure carries a precise code in the response. Argument-schema and server errors are JSON-RPC protocol errors; a rejected value is returned as a tool result with isError: true (so the agent can read the code and self-correct).
| Code | When | Delivered as |
|---|---|---|
invalid_arguments | The input field is missing or not a string. | protocol error (invalid_params) |
internal_error | An unexpected server error. | protocol error (internal_error) |
Notes
- The input must be valid UTF-8. Binary data cannot be encoded directly.
- Output always includes
=padding — the output length is always a multiple of 8 characters. - The standard alphabet uses
A–Zand2–7. If you need output that preserves lexicographic sort order, usebase32_encode_hex(alphabet0–9,A–V).