{
  "openapi": "3.1.1",
  "info": {
    "title": "Hash & HMAC Calculator API",
    "version": "1.0.0",
    "summary": "MD5, SHA-2, SHA-3, BLAKE2, CRC32 and HMAC of text or files, with checksum compare.",
    "description": "Every endpoint performs the same calculation as the human page and returns inputs, result, units, assumptions, sources, warnings and computedAt. MCP endpoint: /mcp."
  },
  "servers": [
    {
      "url": "https://hashhmaccalculator.usefulweb.site"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "MD5, SHA-2, SHA-3, BLAKE2, CRC32 and HMAC of text or files, with checksum compare.",
        "description": "Computes MD5, SHA-1, SHA-224/256/384/512, SHA3-256/512, BLAKE2b-512, BLAKE2s-256 and CRC-32 of text or a file, or an HMAC with your key, in hex or Base64, and checks a published checksum against all of them. With JavaScript on, files and keys are hashed locally in your browser.\n\nMethodology:\n- The input bytes are the file as uploaded, or the text decoded as UTF-8, hex or Base64. Text is hashed exactly as entered: no newline is appended (unlike `echo` without `-n`).\n- Digests come from OpenSSL via Node.js crypto (MD5, SHA-1, SHA-2, SHA-3, BLAKE2b-512, BLAKE2s-256) and zlib (CRC-32, IEEE polynomial, shown big-endian as in `crc32`/`cksum -a crc32b`).\n- With a key, HMAC (RFC 2104) is computed for every selected hash; CRC-32 has no HMAC. SHA-3 HMACs use the SHA-3 rate as block size (NIST), BLAKE2 HMACs the BLAKE2 block size, as OpenSSL does.\n- The comparison accepts hex (any case, optional spaces or colons) or Base64 and reports which algorithm matches.\n- With JavaScript on, the browser computes everything locally: SHA-1/2 via WebCrypto, MD5, SHA-224, SHA-3, BLAKE2 and CRC-32 via small built-in JavaScript implementations. Files and keys never leave your device.\n\nMD5, SHA-1 and CRC-32 must not be used where an attacker could craft collisions. To store passwords use a password hash (Argon2id, scrypt, bcrypt), not a plain hash.",
        "tags": [
          "crypto"
        ],
        "x-mcp-tool": "hash_hmac_calculator",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/HashHmacCalculatorInput"
              },
              "examples": {
                "example1": {
                  "summary": "Hashes of \"hello world\"",
                  "value": {
                    "text": "hello world"
                  }
                },
                "example2": {
                  "summary": "HMAC-SHA256 (RFC 4231 test case 2)",
                  "value": {
                    "text": "what do ya want for nothing?",
                    "hmacKey": "Jefe",
                    "algorithms": [
                      "sha256",
                      "sha512"
                    ]
                  }
                },
                "example3": {
                  "summary": "Verify a SHA-256 checksum of a small file",
                  "value": {
                    "file": {
                      "filename": "readme.txt",
                      "contentType": "text/plain",
                      "contentBase64": "dXNlZnVsd2ViLnNpdGUgY2hlY2tzdW0gZGVtbwo="
                    },
                    "algorithms": [
                      "sha256",
                      "sha3-256",
                      "crc32"
                    ],
                    "expected": "CFA892AD DD30FF8C 6453D2F3 B44C88C3 63B38A3F B5113357 39A5067F 555BE6C0"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HashHmacCalculatorResult"
                }
              }
            }
          },
          "400": {
            "description": "Malformed JSON body.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "Invalid input (see errors[]).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded (see Retry-After).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tool": {
      "get": {
        "operationId": "getToolDefinition",
        "summary": "Inputs, output schema and examples for this tool",
        "responses": {
          "200": {
            "description": "Tool definition.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Problem": {
        "type": "object",
        "description": "RFC 9457 problem details. 422 responses include per-field `errors`.",
        "required": [
          "type",
          "title",
          "status",
          "detail"
        ],
        "properties": {
          "type": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "integer"
          },
          "detail": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "field",
                "message"
              ],
              "properties": {
                "field": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "HashHmacCalculatorInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "text": {
            "title": "Text",
            "description": "Hashed exactly as entered (no trailing newline is added). Leave empty when you choose a file.",
            "type": "string",
            "maxLength": 1000000
          },
          "textFormat": {
            "title": "Text is",
            "type": "string",
            "enum": [
              "utf8",
              "hex",
              "base64"
            ],
            "default": "utf8"
          },
          "file": {
            "title": "Or a file",
            "description": "Any file up to 100 MB. With JavaScript on it is hashed in your browser and never uploaded. Upload as {filename, contentType?, contentBase64}. Max 102400 KiB. Accepts */*.",
            "type": "object",
            "additionalProperties": false,
            "required": [
              "filename",
              "contentBase64"
            ],
            "properties": {
              "filename": {
                "type": "string"
              },
              "contentType": {
                "type": "string"
              },
              "contentBase64": {
                "type": "string"
              }
            }
          },
          "algorithms": {
            "title": "Algorithms",
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "md5",
                "sha1",
                "sha224",
                "sha256",
                "sha384",
                "sha512",
                "sha3-256",
                "sha3-512",
                "blake2b512",
                "blake2s256",
                "crc32"
              ]
            },
            "default": [
              "md5",
              "sha1",
              "sha256",
              "sha512",
              "sha3-256",
              "blake2b512",
              "crc32"
            ]
          },
          "hmacKey": {
            "title": "HMAC key (optional)",
            "description": "With a key, an HMAC (RFC 2104) is computed instead of a plain hash.",
            "type": "string",
            "maxLength": 4096
          },
          "hmacKeyFormat": {
            "title": "Key is",
            "type": "string",
            "enum": [
              "utf8",
              "hex",
              "base64"
            ],
            "default": "utf8"
          },
          "outputEncoding": {
            "title": "Output",
            "type": "string",
            "enum": [
              "hex",
              "base64"
            ],
            "default": "hex"
          },
          "expected": {
            "title": "Expected hash to compare (optional)",
            "description": "Paste a published checksum (hex or Base64); it is compared with every computed value.",
            "type": "string",
            "maxLength": 300
          }
        },
        "required": []
      },
      "HashHmacCalculatorResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "schemaVersion",
          "tool",
          "computedAt",
          "inputs",
          "summary",
          "result",
          "units",
          "assumptions",
          "sources",
          "warnings",
          "presentation",
          "links"
        ],
        "properties": {
          "schemaVersion": {
            "type": "string",
            "const": "1.0"
          },
          "tool": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "name",
              "version"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            }
          },
          "computedAt": {
            "type": "string",
            "format": "date-time"
          },
          "inputs": {
            "type": "object",
            "description": "Normalised inputs actually used, including applied defaults."
          },
          "summary": {
            "type": "string"
          },
          "result": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "source",
              "inputBytes",
              "mode",
              "encoding",
              "digests",
              "comparison"
            ],
            "properties": {
              "source": {
                "type": "string",
                "enum": [
                  "text",
                  "file"
                ]
              },
              "filename": {
                "type": "string"
              },
              "inputBytes": {
                "type": "integer"
              },
              "mode": {
                "type": "string",
                "enum": [
                  "hash",
                  "hmac"
                ]
              },
              "encoding": {
                "type": "string",
                "enum": [
                  "hex",
                  "base64"
                ]
              },
              "digests": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "algorithm",
                    "label",
                    "bits",
                    "hex",
                    "base64",
                    "note"
                  ],
                  "properties": {
                    "algorithm": {
                      "type": "string"
                    },
                    "label": {
                      "type": "string"
                    },
                    "bits": {
                      "type": "integer"
                    },
                    "hex": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "base64": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "note": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  }
                }
              },
              "comparison": {
                "type": [
                  "object",
                  "null"
                ],
                "additionalProperties": false,
                "required": [
                  "expected",
                  "format",
                  "matched"
                ],
                "properties": {
                  "expected": {
                    "type": "string"
                  },
                  "format": {
                    "type": "string"
                  },
                  "matched": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                }
              }
            }
          },
          "units": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "assumptions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "title"
              ],
              "properties": {
                "title": {
                  "type": "string"
                },
                "url": {
                  "type": "string"
                },
                "publisher": {
                  "type": "string"
                },
                "retrievedAt": {
                  "type": "string"
                },
                "note": {
                  "type": "string"
                }
              }
            }
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "presentation": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "Display blocks used by the human page (same data)."
          },
          "links": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "human",
              "api",
              "openapi",
              "methodology"
            ],
            "properties": {
              "human": {
                "type": "string",
                "format": "uri"
              },
              "api": {
                "type": "string",
                "format": "uri"
              },
              "openapi": {
                "type": "string",
                "format": "uri"
              },
              "methodology": {
                "type": "string",
                "format": "uri"
              }
            }
          }
        }
      }
    }
  }
}