DevKits

HMAC-SHA256 Generator — Sign & Verify Webhooks and API Requests Online

Compute HMAC-SHA256 signatures with any secret key. Outputs hex, base64, and base64url encodings. Verify a signature against an expected value in one click. Used by AWS SigV4, JWT HS256, Stripe / GitHub / Slack webhooks. 100% local via Web Crypto API.

Last updated:

The secret never leaves your browser — HMAC runs locally via Web Crypto API.

Hex64 chars · 256 bits
(enter a message and secret)
Base64Standard
(enter a message and secret)
Base64 URLURL-safe, no padding
(enter a message and secret)

Need a different HMAC algorithm?

Enter a message and secret to get the HMAC-SHA256 signature in hex, base64, and base64url formats. Paste an expected signature into the Verify field to check webhook authenticity. Runs 100% locally via the Web Crypto API — the secret never leaves your browser.

What is HMAC-SHA256?

HMAC-SHA256 is the workhorse of modern web-service signing. AWS Signature Version 4 uses it. JWT's HS256 alt uses it. Stripe, GitHub, Slack, Discord, Twilio, and virtually every REST-webhook provider signs their outbound requests with HMAC-SHA256 so you can verify they're really from them. This tool computes and verifies HMAC-SHA256 signatures locally, showing the three encodings that different vendors use interchangeably (hex is most common in AWS / Stripe; base64 in JWT and some others; base64url is JWT-style). The Verify field accepts all three, so you don't need to know which encoding your vendor picked.

How to compute or verify HMAC-SHA256 online

  1. 1Paste the exact message bytes you want to sign — for webhooks, this is the raw request body, not a re-serialized version.
  2. 2Enter the shared secret (from the webhook config or API key management).
  3. 3The tool computes the signature in hex, base64, and base64url instantly.
  4. 4To verify an incoming webhook: paste its signature header into the Verify field — a green checkmark means it matches, red means it doesn't (secret wrong, body altered, or encoding mismatch).

Use Cases

Verify a Stripe / GitHub / Slack webhook

Every major webhook provider signs outbound requests with HMAC-SHA256. Paste the request body and secret; paste the signature header; get instant verify.

Debug AWS SigV4 signatures

AWS SigV4 nests multiple HMAC-SHA256 calls (date → region → service → aws4_request). Test each layer here to isolate where your implementation diverges from AWS's expected value.

Compute JWT HS256 signatures

The HS256 alg in JWT is exactly HMAC-SHA256 over the header.body string, base64url-encoded. Confirm your signing math before shipping a JWT library.

Sign outbound API requests

When integrating with a partner API that requires HMAC-signed requests (custom schemes are common), test signing here before writing library code.

Code Examples

HMAC-SHA256 in Node.js

import { createHmac } from "crypto";
const sig = createHmac("sha256", secret)
  .update(rawBody)
  .digest("hex");

HMAC-SHA256 in Python

import hmac, hashlib
sig = hmac.new(secret.encode(), raw_body, hashlib.sha256).hexdigest()

HMAC-SHA256 in Go

import (
    "crypto/hmac"
    "crypto/sha256"
    "encoding/hex"
)
mac := hmac.New(sha256.New, []byte(secret))
mac.Write(rawBody)
sig := hex.EncodeToString(mac.Sum(nil))

Key Concepts

HMAC construction
HMAC(key, msg) = H((K ⊕ opad) ‖ H((K ⊕ ipad) ‖ msg)). The nested hash resists length-extension attacks that would break a naive H(key ‖ msg).
Base64 vs base64url
Base64 uses +, /, and = padding. Base64url replaces + with -, / with _, and drops padding. JWT signatures use base64url; most REST APIs use standard base64 or hex.

Tips & Best Practices

  • Sign the raw bytes of the request body — never a re-serialized JSON. Frameworks that auto-parse JSON often break signatures by dropping insignificant whitespace or reordering keys.
  • Use constant-time comparison (`crypto.timingSafeEqual` in Node, `hmac.compare_digest` in Python) when verifying — never `===` or `==`. Timing side-channels are real.
  • When comparing hex, be case-insensitive. When comparing base64, be exact (no whitespace, no padding drift).
  • Never log the secret. Never bake it into client-side code — HMAC-SHA256 is a server-side operation.

Frequently Asked Questions

What is HMAC-SHA256 used for?

HMAC-SHA256 is the industry-standard message authentication code. AWS SigV4, JWT HS256, Stripe / GitHub / Slack webhook signatures, and most modern REST API signing schemes use it. It proves both integrity (message wasn't tampered) and authenticity (only someone with the shared secret could produce it).

How long is an HMAC-SHA256 signature?

256 bits — 64 hex chars, or 44 characters in base64 (with padding). The tool shows all three common encodings side-by-side.

How do I verify a webhook signature?

Compute HMAC-SHA256 of the raw payload (bytes, not the parsed JSON) using the shared secret from the webhook config. Compare the result against the signature in the request header. Paste the header value in the Verify field for a one-click check.

Why does my signature not match?

The three most common causes: (1) the message you signed is subtly different from what the sender signed — check trailing newlines and whitespace, (2) wrong encoding — the sender uses base64 but you compare hex, (3) wrong secret. This tool's Verify panel accepts hex, base64, and base64url so encoding mismatches are handled automatically.

Is my secret sent anywhere?

No. HMAC-SHA256 is computed locally via the browser's Web Crypto API. Nothing leaves your device.

Related Tools