Skip to main content
Glama

des_encrypt

Encrypt text using DES 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

  • Registers the 'des_encrypt' tool on the MCP server with its schema (content, key, iv, padding, outputFormat, mode) and handler callback.
    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,
            },
          ],
        };
      }
    );
  • Handler function for the 'des_encrypt' tool that dispatches to DESUtil encryption methods based on the 'mode' parameter (ECB, CBC, CFB, OFB, CTR).
    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,
          },
        ],
      };
    }
  • DESUtil.encryptECB helper - performs DES encryption in ECB mode using crypto-js.
    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();
    }
  • DESUtil.encryptCBC helper - performs DES encryption in CBC mode using crypto-js.
    static encryptCBC(
      message: string,
      key: string,
      iv: string,
      padding: PaddingMode = "Pkcs7",
      outputFormat: OutputFormat = "base64"
    ): string {
      const keyHex = CryptoJS.enc.Utf8.parse(key);
      const ivHex = CryptoJS.enc.Utf8.parse(iv);
      const encrypted = CryptoJS.DES.encrypt(message, keyHex, {
        iv: ivHex,
        mode: CryptoJS.mode.CBC,
        padding: CryptoJS.pad[padding],
      });
    
      return outputFormat === "base64"
        ? encrypted.toString()
        : encrypted.ciphertext.toString();
    }
  • DESUtil.encryptCFB helper - performs DES encryption in CFB mode using crypto-js.
    static encryptCFB(
      message: string,
      key: string,
      iv: string,
      padding: PaddingMode = "Pkcs7",
      outputFormat: OutputFormat = "base64"
    ): string {
      const keyHex = CryptoJS.enc.Utf8.parse(key);
      const ivHex = CryptoJS.enc.Utf8.parse(iv);
      const encrypted = CryptoJS.DES.encrypt(message, keyHex, {
        iv: ivHex,
        mode: CryptoJS.mode.CFB,
        padding: CryptoJS.pad[padding],
      });
    
      return outputFormat === "base64"
        ? encrypted.toString()
        : encrypted.ciphertext.toString();
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The description does not disclose behavioral traits beyond stating the basic function. Without annotations, it fails to mention that the tool is non-destructive, uses default values for optional parameters, or that it requires secure key management.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise (4 words) but lacks structure. It earns its place by stating the purpose, but could be more informative without sacrificing brevity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity with 6 parameters and no output schema, the description is insufficient. It does not explain the algorithm's security implications, default modes, or output format, relying entirely on the schema for detail.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the baseline is 3. The description adds no extra meaning beyond the schema; it only reiterates the algorithm. It does not clarify parameter relationships or provide examples.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool encrypts text using DES, distinguishing it from siblings like aes_encrypt (different algorithm) and des_decrypt (opposite operation). However, it does not specify that it uses symmetric encryption or elaborate on default parameters.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives like aes_encrypt. The description lacks context for preferred use cases, such as legacy system support or specific compliance requirements.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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