Skip to main content
Glama

hashData

Generate cryptographic hashes for data using algorithms like SHA256 or MD5 to verify integrity or create digital fingerprints.

Instructions

Hash input data using Node.js crypto module

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
inputYesData to hash
algorithmNoHash algorithm to usesha256
encodingNoOutput encodinghex

Implementation Reference

  • The core handler function for the 'hashData' tool. It hashes the provided input string using the specified algorithm (default: sha256) and encoding (default: hex) via Node.js 'crypto.createHash', then returns a structured JSON response containing the inputs and computed hash.
    handler: async ({ input, algorithm = 'sha256', encoding = 'hex' }: { input: string; algorithm?: HashAlgorithm; encoding?: 'hex' | 'base64' }) => { try { const hash = createHash(algorithm) .update(input) .digest(encoding); return { content: [{ type: 'text', text: JSON.stringify({ input, algorithm, encoding, hash }, null, 2) }] }; } catch (error) { throw new Error(`Hashing failed: ${error instanceof Error ? error.message : 'Unknown error'}`); } }
  • Input schema for the 'hashData' tool, defining required 'input' string, optional 'algorithm' enum (md5/sha1/sha256/sha512), and optional 'encoding' enum (hex/base64).
    inputSchema: { type: 'object', properties: { input: { type: 'string', description: 'Data to hash' }, algorithm: { type: 'string', description: 'Hash algorithm to use', enum: ['md5', 'sha1', 'sha256', 'sha512'], default: 'sha256' }, encoding: { type: 'string', description: 'Output encoding', enum: ['hex', 'base64'], default: 'hex' } }, required: ['input'] },
  • src/index.ts:10-10 (registration)
    Import statement that brings in the securityTools object, which defines and exports the 'hashData' tool.
    import { securityTools } from './tools/security.js';
  • src/index.ts:28-35 (registration)
    Merges 'securityTools' (containing 'hashData') into the central 'allTools' registry, making it available for MCP server tool listing and execution handlers.
    const allTools: ToolKit = { ...systemTools, ...networkTools, ...geoTools, ...generatorTools, ...dateTimeTools, ...securityTools };

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/cyanheads/toolkit-mcp-server'

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