Skip to main content

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​

ParameterTypeRequiredDescription
inputstringYesThe UTF-8 string to encode.

Response​

FieldTypeDescription
outputstringThe 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).

CodeWhenDelivered as
invalid_argumentsThe input field is missing or not a string.protocol error (invalid_params)
internal_errorAn 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 include W, X, Y, or Z. 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 use base32_decode — the alphabets are incompatible.