Skip to main content
Glama

des_encrypt

Encrypt text using DES algorithm with customizable key, IV, padding mode, and output format for secure data protection.

Instructions

encrypt text with des

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentYestext to encrypt
keyNoencryption key, default is your-key
ivNoinitialization vector, default is your-iv-your-iv-
paddingNopadding mode, default is Pkcs7Pkcs7
outputFormatNooutput format, default is base64base64
modeNomode, default is ECBECB

Implementation Reference

  • Handler function that dispatches DES encryption based on mode (ECB/CBC/CFB/OFB/CTR) using DESUtil helpers, returns encrypted text.
    async ({ content, key, iv, padding, outputFormat, mode }) => { let result = ""; if (mode === "ECB") { result = DESUtil.encryptECB( content, key ?? "your-key", (padding ?? "Pkcs7") as PaddingMode, (outputFormat ?? "base64") as OutputFormat ); } else if (mode === "CBC") { result = DESUtil.encryptCBC( content, key ?? "your-key", iv ?? "your-iv-", (padding ?? "Pkcs7") as PaddingMode, (outputFormat ?? "base64") as OutputFormat ); } else if (mode === "CFB") { result = DESUtil.encryptCFB( content, key ?? "your-key", iv ?? "your-iv-", (padding ?? "Pkcs7") as PaddingMode, (outputFormat ?? "base64") as OutputFormat ); } else if (mode === "OFB") { result = DESUtil.encryptOFB( content, key ?? "your-key", iv ?? "your-iv-", (padding ?? "Pkcs7") as PaddingMode, (outputFormat ?? "base64") as OutputFormat ); } else if (mode === "CTR") { result = DESUtil.encryptCTR( content, key ?? "your-key", iv ?? "your-iv-", (padding ?? "Pkcs7") as PaddingMode, (outputFormat ?? "base64") as OutputFormat ); } else { throw new McpError(ErrorCode.InvalidParams, "Unknown mode"); } return { content: [ { type: "text", text: result, }, ], }; }
  • Zod schema defining input parameters for des_encrypt: content, optional key/iv/padding/outputFormat/mode with defaults.
    { content: z.string().describe("text to encrypt"), key: z .string() .optional() .describe("encryption key, default is your-key"), iv: z .string() .optional() .describe("initialization vector, default is your-iv-") .default("your-iv-"), padding: z .enum([ "Pkcs7", "Iso97971", "AnsiX923", "Iso10126", "ZeroPadding", "NoPadding", ]) .optional() .describe("padding mode, default is Pkcs7") .default("Pkcs7"), outputFormat: z .enum(["base64", "hex"]) .optional() .describe("output format, default is base64") .default("base64"), mode: z .string() .optional() .describe("mode, default is ECB") .default("ECB"), },
  • Registers the 'des_encrypt' tool on the MCP server within registerDESTool function.
    server.tool( "des_encrypt", "encrypt text with des", { content: z.string().describe("text to encrypt"), key: z .string() .optional() .describe("encryption key, default is your-key"), iv: z .string() .optional() .describe("initialization vector, default is your-iv-") .default("your-iv-"), padding: z .enum([ "Pkcs7", "Iso97971", "AnsiX923", "Iso10126", "ZeroPadding", "NoPadding", ]) .optional() .describe("padding mode, default is Pkcs7") .default("Pkcs7"), outputFormat: z .enum(["base64", "hex"]) .optional() .describe("output format, default is base64") .default("base64"), mode: z .string() .optional() .describe("mode, default is ECB") .default("ECB"), }, async ({ content, key, iv, padding, outputFormat, mode }) => { let result = ""; if (mode === "ECB") { result = DESUtil.encryptECB( content, key ?? "your-key", (padding ?? "Pkcs7") as PaddingMode, (outputFormat ?? "base64") as OutputFormat ); } else if (mode === "CBC") { result = DESUtil.encryptCBC( content, key ?? "your-key", iv ?? "your-iv-", (padding ?? "Pkcs7") as PaddingMode, (outputFormat ?? "base64") as OutputFormat ); } else if (mode === "CFB") { result = DESUtil.encryptCFB( content, key ?? "your-key", iv ?? "your-iv-", (padding ?? "Pkcs7") as PaddingMode, (outputFormat ?? "base64") as OutputFormat ); } else if (mode === "OFB") { result = DESUtil.encryptOFB( content, key ?? "your-key", iv ?? "your-iv-", (padding ?? "Pkcs7") as PaddingMode, (outputFormat ?? "base64") as OutputFormat ); } else if (mode === "CTR") { result = DESUtil.encryptCTR( content, key ?? "your-key", iv ?? "your-iv-", (padding ?? "Pkcs7") as PaddingMode, (outputFormat ?? "base64") as OutputFormat ); } else { throw new McpError(ErrorCode.InvalidParams, "Unknown mode"); } return { content: [ { type: "text", text: result, }, ], }; } );
  • src/index.ts:17-17 (registration)
    Calls registerDESTool to register des_encrypt and des_decrypt tools on the main server.
    registerDESTool(server);
  • DESUtil.encryptECB: Core helper for ECB mode encryption using CryptoJS.DES.encrypt.
    static encryptECB( message: string, key: string, padding: PaddingMode = "Pkcs7", outputFormat: OutputFormat = "base64" ): string { const keyHex = CryptoJS.enc.Utf8.parse(key); const encrypted = CryptoJS.DES.encrypt(message, keyHex, { mode: CryptoJS.mode.ECB, padding: CryptoJS.pad[padding], }); return outputFormat === "base64" ? encrypted.toString() : encrypted.ciphertext.toString(); }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/1595901624/crypto-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server