Skip to main content
Glama

aes_decrypt

Decrypt AES-encrypted text with customizable key, padding, IV, and mode. Supports base64 or hex input formats for flexible data recovery.

Instructions

decrypt text with aes

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentYestext to encrypt and decrypt
keyNodecrypt key, default is your-key-0123456
paddingNopadding mode, default is Pkcs7Pkcs7
inputFormatNoinput format, default is base64base64
ivNoiv, default is your-iv-01234567
modeNomode, default is ECBECB

Implementation Reference

  • Registration of the 'aes_decrypt' tool via server.tool() with its Zod schema (content, key, padding, inputFormat, iv, mode) and handler async function.
    server.tool(
      "aes_decrypt",
      "decrypt text with aes",
      {
        content: z.string().describe("text to encrypt and decrypt"),
        key: z
          .string()
          .optional()
          .describe("decrypt key, default is your-key-0123456"),
        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"),
        iv: z.string().optional().describe("iv, default is your-iv-01234567"),
        mode: z
          .enum(["ECB", "CBC", "CFB", "OFB", "CTR"])
          .optional()
          .describe("mode, default is ECB")
          .default("ECB"),
      },
      async ({ content, key, padding, inputFormat, iv, mode }) => {
        let result = "";
        if (mode === "ECB") {
          result = AESUtil.decryptECB(content, key ?? "your-key-0123456");
        } else if (mode === "CBC") {
          result = AESUtil.decryptCBC(
            content,
            key ?? "your-key-0123456",
            iv ?? "your-iv-01234567",
            (padding ?? "Pkcs7") as PaddingMode,
            (inputFormat ?? "base64") as OutputFormat
          );
        } else if (mode === "CFB") {
          result = AESUtil.decryptCFB(
            content,
            key ?? "your-key-0123456",
            iv ?? "your-iv-01234567",
            (padding ?? "Pkcs7") as PaddingMode,
            (inputFormat ?? "base64") as OutputFormat
          );
        } else if (mode === "OFB") {
          result = AESUtil.decryptOFB(
            content,
            key ?? "your-key-0123456",
            iv ?? "your-iv-01234567",
            (padding ?? "Pkcs7") as PaddingMode,
            (inputFormat ?? "base64") as OutputFormat
          );
        } else if (mode === "CTR") {
          result = AESUtil.decryptCTR(
            content,
            key ?? "your-key-0123456",
            iv ?? "your-iv-01234567",
            (padding ?? "Pkcs7") as PaddingMode,
            (inputFormat ?? "base64") as OutputFormat
          );
        }
        return {
          content: [
            {
              type: "text",
              text: result,
            },
          ],
        };
      }
    );
  • Handler logic for aes_decrypt: dispatches to AESUtil.decryptECB, decryptCBC, decryptCFB, decryptOFB, or decryptCTR based on the 'mode' parameter.
    async ({ content, key, padding, inputFormat, iv, mode }) => {
      let result = "";
      if (mode === "ECB") {
        result = AESUtil.decryptECB(content, key ?? "your-key-0123456");
      } else if (mode === "CBC") {
        result = AESUtil.decryptCBC(
          content,
          key ?? "your-key-0123456",
          iv ?? "your-iv-01234567",
          (padding ?? "Pkcs7") as PaddingMode,
          (inputFormat ?? "base64") as OutputFormat
        );
      } else if (mode === "CFB") {
        result = AESUtil.decryptCFB(
          content,
          key ?? "your-key-0123456",
          iv ?? "your-iv-01234567",
          (padding ?? "Pkcs7") as PaddingMode,
          (inputFormat ?? "base64") as OutputFormat
        );
      } else if (mode === "OFB") {
        result = AESUtil.decryptOFB(
          content,
          key ?? "your-key-0123456",
          iv ?? "your-iv-01234567",
          (padding ?? "Pkcs7") as PaddingMode,
          (inputFormat ?? "base64") as OutputFormat
        );
      } else if (mode === "CTR") {
        result = AESUtil.decryptCTR(
          content,
          key ?? "your-key-0123456",
          iv ?? "your-iv-01234567",
          (padding ?? "Pkcs7") as PaddingMode,
          (inputFormat ?? "base64") as OutputFormat
        );
      }
      return {
        content: [
          {
            type: "text",
            text: result,
          },
        ],
      };
    }
  • Zod schema definitions for aes_decrypt input parameters: content (string), key (optional string), padding (enum Pkcs7/Iso97971/etc), inputFormat (enum base64/hex), iv (optional string), mode (enum ECB/CBC/CFB/OFB/CTR).
    {
      content: z.string().describe("text to encrypt and decrypt"),
      key: z
        .string()
        .optional()
        .describe("decrypt key, default is your-key-0123456"),
      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"),
      iv: z.string().optional().describe("iv, default is your-iv-01234567"),
      mode: z
        .enum(["ECB", "CBC", "CFB", "OFB", "CTR"])
        .optional()
        .describe("mode, default is ECB")
        .default("ECB"),
    },
  • AESUtil.decryptECB helper - decrypts ciphertext in ECB mode, supports hex and base64 input formats.
    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.AES.decrypt(ciphertextParams, keyHex, {
          mode: CryptoJS.mode.ECB,
          padding: CryptoJS.pad[padding],
        });
      } else {
        decrypted = CryptoJS.AES.decrypt(ciphertext, keyHex, {
          mode: CryptoJS.mode.ECB,
          padding: CryptoJS.pad[padding],
        });
      }
    
      return decrypted.toString(CryptoJS.enc.Utf8);
    }
  • AESUtil.decryptCBC helper - decrypts ciphertext in CBC mode with IV, supports hex and base64 input formats.
    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.AES.decrypt(ciphertextParams, keyHex, {
          iv: ivHex,
          mode: CryptoJS.mode.CBC,
          padding: CryptoJS.pad[padding],
        });
      } else {
        decrypted = CryptoJS.AES.decrypt(ciphertext, keyHex, {
          iv: ivHex,
          mode: CryptoJS.mode.CBC,
          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?

With no annotations, the description carries the full burden. It only says 'decrypt text with aes,' failing to disclose important behavioral traits such as default values, error handling, or required input formats (e.g., ciphertext expected in base64 or hex as per schema). The description adds minimal value beyond the tool name.

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?

The description is a single short sentence, which is under-specified for a tool with 6 parameters and 3 enums. It lacks essential details and is not front-loaded with key information.

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

Completeness1/5

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

Given the complexity (6 parameters, multiple enums, no output schema, no annotations) and sibling tools, the description is extremely incomplete. It does not mention that this tool likely pairs with aes_encrypt, nor does it explain the output format or default behaviors.

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 schema already documents all parameters. The description does not add any additional meaning to parameters like key, iv, mode, or padding beyond what is in the schema.

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?

The description states the tool decrypts text with AES, which is a specific verb and resource, but it does not distinguish this tool from siblings like aes_encrypt or des_decrypt. The purpose is clear but lacks differentiation.

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?

The description provides no guidance on when to use this tool versus alternatives like aes_encrypt, des_decrypt, or others. There is no mention of prerequisites or typical use cases.

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