# HMAC Generator API

> HMAC Generator creates Hash-based Message Authentication Codes for data integrity and authentication. Supports SHA-256, SHA-384, SHA-512, SHA-1, and MD5 algorithms.

**Endpoint:** `POST https://api.apiverve.com/v1/hmac`  
**Category:** Security  
**Cost:** 1 credit per call  
**Canonical page:** https://apiverve.com/marketplace/hmac

## Overview

Returns the HMAC signature in hex or base64 encoding. Use for signing API requests, validating webhooks, or any scenario requiring message authentication.

## Authentication

Every call carries your key in an `x-api-key` header. The same key works across the whole
APIVerve catalog — there are no per-API subscriptions. Responses always use the same three
top-level keys: `status`, `error`, and `data`.

## Example request

```bash
curl -X POST "https://api.apiverve.com/v1/hmac" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"message":"Hello World","secret":"my-secret-key","algorithm":"sha256","encoding":"hex","secretEncoding":"value","signature":"value"}'
```

## Parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `message` | string | Yes | The message to sign |
| `secret` | string | Yes | The secret key for HMAC generation |
| `algorithm` | string | No | Hash algorithm to use. default sha256. One of: sha256, sha384, sha512, sha1, md5 |
| `encoding` | string | No | Output encoding format. default hex. One of: hex, base64 |
| `secretEncoding` | string | No | How the secret is encoded. Use base64 for Svix / Standard Webhooks keys (a leading whsec_ is stripped) and hex for binary keys such as chained AWS SigV4 keys. Stripe and GitHub secrets are plain utf8, whsec_ prefix included. default utf8. One of: utf8, hex, base64 |
| `signature` | string | No | Optional signature received with a webhook. When sent, the response adds matches (timing-safe compare in the chosen encoding). Prefixes like sha256=, v1, and Svix space-separated lists are accepted |

## Response fields

- `hmac` — string · Generated HMAC signature in specified encoding format
- `algorithm` — string · Hash algorithm used for HMAC generation
- `encoding` — string · Output encoding format applied to the signature

## Sample response

```json
{
  "status": "ok",
  "error": null,
  "data": {
    "hmac": "2cd7c25025198d4458002ceb064ad37ccfbbe46650876d693f5e080bd954e449",
    "algorithm": "sha256",
    "encoding": "hex"
  }
}
```

## Use cases

- **API Authentication** — Sign API requests to prove authenticity
- **Webhook Verification** — Validate incoming webhooks from services like Stripe, GitHub
- **Data Integrity** — Ensure messages haven't been tampered with
- **JWT Signing** — Generate signatures for JSON Web Tokens

## SDKs

- **npm** — `npm install @apiverve/hmac` (https://www.npmjs.com/package/@apiverve/hmac)
- **NuGet** — `dotnet add package APIVerve.API.HMACGenerator` (https://www.nuget.org/packages/APIVerve.API.HMACGenerator)
- **Source** — https://github.com/apiverve/hmac-api

## More

- Full reference: https://docs.apiverve.com/ref/hmac
- Get an API key: https://dashboard.apiverve.com
- Full catalog: https://apiverve.com/marketplace
