base32_encode_hex
Encode a UTF-8 string to Base32 using the extended hex alphabet (RFC 4648 §7). The hex alphabet uses digits 0–9 and uppercase letters A–V. This alphabet preserves the lexicographic sort order of the original data — encoded strings sort the same way their decoded counterparts would. Output always includes = padding to make the length a multiple of 8 characters.
For the standard alphabet (A–Z, 2–7), use base32_encode instead.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | Yes | The UTF-8 string to encode. |
Response
| Field | Type | Description |
|---|---|---|
output | string | The Base32Hex-encoded string. |
Examples
Encode a plain ASCII string
{
"input": "hello"
}
Result:
{
"output": "D1IMOR3F"
}
Compare standard vs. hex encoding of the same input
The two alphabets produce different output for the same input — the hex alphabet never contains W, X, Y, or Z:
{
"input": "hello world"
}
base32_encode result: NBSWY3DPEB3W64TMMQ======
base32_encode_hex result: D1IMOR3F41RMUSJCCG======
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 hex alphabet (
0–9,A–V) does not includeW,X,Y, orZ. This makes it safe for contexts where sort order must match the original byte order, such as database keys. - To decode the output of this tool, use
base32_decode_hex. Do not usebase32_decode— the alphabets are incompatible.