hex_encode
Encode text to hexadecimal format. Convert plain text into hex strings for data transformation, cryptographic operations, or low-level programming tasks.
Instructions
encode text to hex
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| content | Yes | text to encode |
Implementation Reference
- src/service/hex.ts:45-55 (handler)The async handler function for the 'hex_encode' tool. Accepts a 'content' string as input, calls HexUtil.stringToHex() to encode it to hex, and returns the result as text content.
async ({ content }: { content: string }) => { const result = HexUtil.stringToHex(content); return { content: [ { type: "text", text: result, }, ], }; } - src/service/hex.ts:42-44 (schema)Input schema for the 'hex_encode' tool, defining a single required string parameter 'content' with description 'text to encode'.
{ content: z.string().describe("text to encode"), }, - src/service/hex.ts:39-56 (registration)Registration of the 'hex_encode' tool via server.tool(), with name 'hex_encode' and description 'encode text to hex'.
server.tool( "hex_encode", "encode text to hex", { content: z.string().describe("text to encode"), }, async ({ content }: { content: string }) => { const result = HexUtil.stringToHex(content); return { content: [ { type: "text", text: result, }, ], }; } ); - src/service/hex.ts:13-17 (helper)The static helper method HexUtil.stringToHex() that performs the actual encoding of a string to hex format by converting each character to its charCode and then to base-16.
static stringToHex(str: string): string { return Array.from(str) .map(char => char.charCodeAt(0).toString(16).padStart(2, '0')) .join(''); }