Skip to main content
Glama

des_decrypt

Decrypt DES-encrypted data with customizable key, IV, padding, mode, and input format (base64/hex).

Instructions

decrypt text with des

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentYestext to decrypt
keyNodecryption key, default is your-key
ivNoinitialization vector, default is your-iv-your-iv-
paddingNopadding mode, default is Pkcs7Pkcs7
inputFormatNoinput format, default is base64base64
modeNomode, default is ECBECB

Implementation Reference

  • Registration of the des_decrypt tool via server.tool() with Zod schema for input validation
    server.tool(
      "des_decrypt",
      "decrypt text with des",
      {
        content: z.string().describe("text to decrypt"),
        key: z
          .string()
          .optional()
          .describe("decryption 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"),
        inputFormat: z
          .enum(["base64", "hex"])
          .optional()
          .describe("input format, default is base64")
          .default("base64"),
        mode: z
          .enum(["ECB", "CBC", "CFB", "OFB", "CTR"])
          .optional()
          .describe("mode, default is ECB")
          .default("ECB"),
      },
      async ({ content, key, iv, padding, inputFormat, mode }) => {
        let result = "";
        if (mode === "ECB") {
          result = DESUtil.decryptECB(content, key ?? "your-key");
        } else if (mode === "CBC") {
          result = DESUtil.decryptCBC(
            content,
            key ?? "your-key",
            iv ?? "your-iv-",
            (padding ?? "Pkcs7") as PaddingMode,
            (inputFormat ?? "base64") as OutputFormat
          );
        } else if (mode === "CFB") {
          result = DESUtil.decryptCFB(
            content,
            key ?? "your-key",
            iv ?? "your-iv-",
            (padding ?? "Pkcs7") as PaddingMode,
            (inputFormat ?? "base64") as OutputFormat
          );
        } else if (mode === "OFB") {
          result = DESUtil.decryptOFB(
            content,
            key ?? "your-key",
            iv ?? "your-iv-",
            (padding ?? "Pkcs7") as PaddingMode,
            (inputFormat ?? "base64") as OutputFormat
          );
        } else if (mode === "CTR") {
          result = DESUtil.decryptCTR(
            content,
            key ?? "your-key",
            iv ?? "your-iv-",
            (padding ?? "Pkcs7") as PaddingMode,
            (inputFormat ?? "base64") as OutputFormat
          );
        }
        return {
          content: [
            {
              type: "text",
              text: result,
            },
          ],
        };
      }
    );
  • Zod schema defining input parameters for des_decrypt: content, key, iv, padding, inputFormat, mode
      content: z.string().describe("text to decrypt"),
      key: z
        .string()
        .optional()
        .describe("decryption 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"),
      inputFormat: z
        .enum(["base64", "hex"])
        .optional()
        .describe("input format, default is base64")
        .default("base64"),
      mode: z
        .enum(["ECB", "CBC", "CFB", "OFB", "CTR"])
        .optional()
        .describe("mode, default is ECB")
        .default("ECB"),
    },
  • Handler function for des_decrypt tool - delegates to DESUtil decrypt methods based on mode
    async ({ content, key, iv, padding, inputFormat, mode }) => {
      let result = "";
      if (mode === "ECB") {
        result = DESUtil.decryptECB(content, key ?? "your-key");
      } else if (mode === "CBC") {
        result = DESUtil.decryptCBC(
          content,
          key ?? "your-key",
          iv ?? "your-iv-",
          (padding ?? "Pkcs7") as PaddingMode,
          (inputFormat ?? "base64") as OutputFormat
        );
      } else if (mode === "CFB") {
        result = DESUtil.decryptCFB(
          content,
          key ?? "your-key",
          iv ?? "your-iv-",
          (padding ?? "Pkcs7") as PaddingMode,
          (inputFormat ?? "base64") as OutputFormat
        );
      } else if (mode === "OFB") {
        result = DESUtil.decryptOFB(
          content,
          key ?? "your-key",
          iv ?? "your-iv-",
          (padding ?? "Pkcs7") as PaddingMode,
          (inputFormat ?? "base64") as OutputFormat
        );
      } else if (mode === "CTR") {
        result = DESUtil.decryptCTR(
          content,
          key ?? "your-key",
          iv ?? "your-iv-",
          (padding ?? "Pkcs7") as PaddingMode,
          (inputFormat ?? "base64") as OutputFormat
        );
      }
      return {
        content: [
          {
            type: "text",
            text: result,
          },
        ],
      };
    }
  • DESUtil.decryptECB - decrypts ciphertext in ECB mode using CryptoJS.DES.decrypt
    static decryptECB(
      ciphertext: string,
      key: string,
      padding: PaddingMode = "Pkcs7",
      inputFormat: OutputFormat = "base64"
    ): string {
      const keyHex = CryptoJS.enc.Utf8.parse(key);
      let decrypted;
    
      if (inputFormat === "hex") {
        const ciphertextHex = CryptoJS.enc.Hex.parse(ciphertext);
        const ciphertextParams = CryptoJS.lib.CipherParams.create({
          ciphertext: ciphertextHex,
        });
        decrypted = CryptoJS.DES.decrypt(ciphertextParams, keyHex, {
          mode: CryptoJS.mode.ECB,
          padding: CryptoJS.pad[padding],
        });
      } else {
        decrypted = CryptoJS.DES.decrypt(ciphertext, keyHex, {
          mode: CryptoJS.mode.ECB,
          padding: CryptoJS.pad[padding],
        });
      }
    
      return decrypted.toString(CryptoJS.enc.Utf8);
    }
  • DESUtil.decryptCBC - decrypts ciphertext in CBC mode using CryptoJS.DES.decrypt with IV
    static decryptCBC(
      ciphertext: string,
      key: string,
      iv: string,
      padding: PaddingMode = "Pkcs7",
      inputFormat: OutputFormat = "base64"
    ): string {
      const keyHex = CryptoJS.enc.Utf8.parse(key);
      const ivHex = CryptoJS.enc.Utf8.parse(iv);
      let decrypted;
    
      if (inputFormat === "hex") {
        const ciphertextHex = CryptoJS.enc.Hex.parse(ciphertext);
        const ciphertextParams = CryptoJS.lib.CipherParams.create({
          ciphertext: ciphertextHex,
        });
        decrypted = CryptoJS.DES.decrypt(ciphertextParams, keyHex, {
          iv: ivHex,
          mode: CryptoJS.mode.CBC,
          padding: CryptoJS.pad[padding],
        });
      } else {
        decrypted = CryptoJS.DES.decrypt(ciphertext, keyHex, {
          iv: ivHex,
          mode: CryptoJS.mode.CBC,
          padding: CryptoJS.pad[padding],
        });
      }
    
      return decrypted.toString(CryptoJS.enc.Utf8);
    }
  • DESUtil.decryptCFB - decrypts ciphertext in CFB mode using CryptoJS.DES.decrypt with IV
    static decryptCFB(
      ciphertext: string,
      key: string,
      iv: string,
      padding: PaddingMode = "Pkcs7",
      inputFormat: OutputFormat = "base64"
    ): string {
      const keyHex = CryptoJS.enc.Utf8.parse(key);
      const ivHex = CryptoJS.enc.Utf8.parse(iv);
      let decrypted;
    
      if (inputFormat === "hex") {
        const ciphertextHex = CryptoJS.enc.Hex.parse(ciphertext);
        const ciphertextParams = CryptoJS.lib.CipherParams.create({
          ciphertext: ciphertextHex,
        });
        decrypted = CryptoJS.DES.decrypt(ciphertextParams, keyHex, {
          iv: ivHex,
          mode: CryptoJS.mode.CFB,
          padding: CryptoJS.pad[padding],
        });
      } else {
        decrypted = CryptoJS.DES.decrypt(ciphertext, keyHex, {
          iv: ivHex,
          mode: CryptoJS.mode.CFB,
          padding: CryptoJS.pad[padding],
        });
      }
    
      return decrypted.toString(CryptoJS.enc.Utf8);
    }
  • DESUtil.decryptOFB - decrypts ciphertext in OFB mode using CryptoJS.DES.decrypt with IV
    static decryptOFB(
      ciphertext: string,
      key: string,
      iv: string,
      padding: PaddingMode = "Pkcs7",
      inputFormat: OutputFormat = "base64"
    ): string {
      const keyHex = CryptoJS.enc.Utf8.parse(key);
      const ivHex = CryptoJS.enc.Utf8.parse(iv);
      let decrypted;
    
      if (inputFormat === "hex") {
        const ciphertextHex = CryptoJS.enc.Hex.parse(ciphertext);
        const ciphertextParams = CryptoJS.lib.CipherParams.create({
          ciphertext: ciphertextHex,
        });
        decrypted = CryptoJS.DES.decrypt(ciphertextParams, keyHex, {
          iv: ivHex,
          mode: CryptoJS.mode.OFB,
          padding: CryptoJS.pad[padding],
        });
      } else {
        decrypted = CryptoJS.DES.decrypt(ciphertext, keyHex, {
          iv: ivHex,
          mode: CryptoJS.mode.OFB,
          padding: CryptoJS.pad[padding],
        });
      }
    
      return decrypted.toString(CryptoJS.enc.Utf8);
    }
  • DESUtil.decryptCTR - decrypts ciphertext in CTR mode using CryptoJS.DES.decrypt with IV
    static decryptCTR(
      ciphertext: string,
      key: string,
      iv: string,
      padding: PaddingMode = "Pkcs7",
      inputFormat: OutputFormat = "base64"
    ): string {
      const keyHex = CryptoJS.enc.Utf8.parse(key);
      const ivHex = CryptoJS.enc.Utf8.parse(iv);
      let decrypted;
    
      if (inputFormat === "hex") {
        const ciphertextHex = CryptoJS.enc.Hex.parse(ciphertext);
        const ciphertextParams = CryptoJS.lib.CipherParams.create({
          ciphertext: ciphertextHex,
        });
        decrypted = CryptoJS.DES.decrypt(ciphertextParams, keyHex, {
          iv: ivHex,
          mode: CryptoJS.mode.CTR,
          padding: CryptoJS.pad[padding],
        });
      } else {
        decrypted = CryptoJS.DES.decrypt(ciphertext, keyHex, {
          iv: ivHex,
          mode: CryptoJS.mode.CTR,
          padding: CryptoJS.pad[padding],
        });
      }
    
      return decrypted.toString(CryptoJS.enc.Utf8);
    }
Behavior2/5

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

No annotations provided; the description does not disclose behavioral traits such as side effects, error handling, key requirements, or reversibility. Merely states the operation.

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

Conciseness2/5

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

While short, the description is underspecified for a tool with 6 parameters and no annotations. Every sentence must earn its place; this one does not add value beyond the name.

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?

For a cryptographic tool with multiple modes, padding, and IV, the description lacks essential context. No output schema or behavioral hints provided; incomplete for safe use.

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 coverage is 100% with clear descriptions for each parameter. The tool description adds no additional parameter information, so baseline score applies.

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

Purpose3/5

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

Description 'decrypt text with des' states the verb and resource but is barely more than the tool name. It is not misleading, but it lacks specificity.

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 on when to use this tool over siblings like aes_decrypt or des_encrypt. No context on appropriate scenarios.

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