sha256
Calculate a cryptographic hash of any input string to verify data integrity. Produces a fixed-size output for secure comparisons.
Instructions
Calculate SHA-256 hash of a string
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| input | Yes | The input string to hash |
Implementation Reference
- src/service/digest.ts:31-34 (handler)The sha256 static method on DigestUtil class. Uses CryptoJS.SHA256 to compute the hash and returns its string representation.
static sha256(input: string): string { const hash = CryptoJS.SHA256(input); return hash.toString(); } - src/service/digest.ts:104-106 (schema)Zod schema for the sha256 tool input: requires a string 'input' parameter.
{ input: z.string().describe("The input string to hash"), }, - src/service/digest.ts:100-113 (registration)Registration of the 'sha256' tool on the McpServer. Calls DigestUtil.sha256 and returns the hash as text content.
// Register SHA-256 tool server.tool( "sha256", "Calculate SHA-256 hash of a string", { input: z.string().describe("The input string to hash"), }, ({ input }) => { const hash = DigestUtil.sha256(input); return { content: [{ type: "text", text: hash }], }; } );