Skip to main content
Glama

hashData

Generate secure hashes from input data using specified algorithms like MD5, SHA1, SHA256, or SHA512, with output in hex or base64 encoding. Ideal for data integrity and security applications.

Instructions

Hash input data using Node.js crypto module

Input Schema

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

Implementation Reference

  • The asynchronous handler function that executes the hashing logic using Node.js crypto.createHash, taking input data, algorithm, and encoding parameters.
    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'}`); } }
  • The inputSchema defining the parameters for the hashData tool: input (required string), algorithm (enum with default sha256), encoding (enum with default hex).
    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:27-33 (registration)
    Registration of securityTools (including hashData) by spreading into the allTools object used by MCP server handlers for tool listing and execution.
    const allTools: ToolKit = { ...encodingTools, ...geoTools, ...generatorTools, ...dateTimeTools, ...securityTools };
  • Type definition for HashAlgorithm used in the hashData input schema and handler.
    export type HashAlgorithm = 'md5' | 'sha1' | 'sha256' | 'sha512';

Other Tools

Related 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/MissionSquad/mcp-helper-tools'

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