HMAC Generator

Compute HMAC signatures with SHA-1, SHA-256, SHA-384 or SHA-512 — paste your message and secret key to get hex, Base64 and Base64url output instantly.

Signature
Enter a message and a secret key to compute the HMAC signature.

What Is HMAC and Why Use It?

HMAC (Hash-based Message Authentication Code) is a cryptographic technique that combines a secret key with a hash function to produce a short authentication tag. Unlike a plain hash (SHA-256, MD5…), an HMAC can only be verified by someone who holds the secret key — making it suitable for API authentication, webhook signature validation, JWT signing, and data integrity checks.

The construction is standardised in RFC 2104: HMAC(K, m) = H((K' ⊕ opad) ∥ H((K' ⊕ ipad) ∥ m)). The key is XOR-mixed with inner and outer padding before hashing, which prevents length-extension attacks that affect plain hash constructions. All modern security standards — OAuth 2.0 signatures, AWS Signature v4, JWT HS256/HS384/HS512 — rely on HMAC internally.

HMAC Algorithms Compared

This HMAC calculator supports four algorithm variants. The choice of hash function determines the output size and security level:

AlgorithmOutput sizeSecurity levelCommon use
HMAC-SHA1160 bits (40 hex chars)≥ 80 bitsLegacy systems, Git
HMAC-SHA256256 bits (64 hex chars)128 bitsJWT HS256, webhooks, AWS
HMAC-SHA384384 bits (96 hex chars)192 bitsJWT HS384, TLS PRF
HMAC-SHA512512 bits (128 hex chars)256 bitsJWT HS512, high-security APIs

For most modern use cases HMAC-SHA256 is the right default: it is fast, widely supported, and offers ample security margin. Choose HMAC-SHA512 when the output length matters (e.g., deriving symmetric keys) or when operating in a high-assurance environment.

How to Use the HMAC Generator

  1. Select your algorithm (HMAC-SHA256 is selected by default).
  2. Choose the message encoding: UTF-8 text for plain strings, Hex bytes if your message is binary data expressed as hex pairs.
  3. Choose the key encoding the same way.
  4. Type or paste your message in the left textarea.
  5. Type or paste your secret key in the key field.
  6. The signature appears instantly in hex, Base64, and Base64url formats.

The output updates live as you type. All computation is performed locally in your browser using the Web Crypto API — no data is sent to any server.

Hex Input Format

When "Hex bytes" encoding is selected, enter pairs of hexadecimal digits separated by optional whitespace. Example: 48 65 6c 6c 6f or 48656c6c6f (both represent the ASCII string "Hello"). This is useful when your message or key contains binary data, null bytes, or arbitrary byte sequences that cannot be expressed as printable text.

Output Formats

Three output representations are provided simultaneously:

Practical Examples

Webhook Signature Verification (GitHub-style)

GitHub computes HMAC-SHA256(webhook_secret, payload_body) and sends the result in the X-Hub-Signature-256 header. Your server can re-compute this value and compare it to reject tampered payloads.

Algorithm : HMAC-SHA256
Key       : mysecretkey
Message   : {"action":"opened","number":42}

Expected header value: sha256=<hex output from this tool>

JWT Signature (HS256)

The JWT specification (RFC 7519) signs tokens using HMAC. The signed data is base64url(header) + "." + base64url(payload) and the algorithm is HMAC-SHA256. The Base64url output from this tool is the token's signature component.

Algorithm : HMAC-SHA256
Key       : your-jwt-secret
Message   : eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0In0

Signature → use Base64url output as the third JWT segment

AWS Signature Version 4

AWS SigV4 uses a chain of HMAC-SHA256 operations to derive a signing key. Each step feeds the result of the previous HMAC as the new key, with UTF-8 date strings and service names as messages. This tool lets you trace any individual step of that chain.

Step 1 – DateKey:
  Algorithm : HMAC-SHA256
  Key       : AWS4 + SecretAccessKey  (UTF-8)
  Message   : 20260516              (date YYYYMMDD)

Step 2 – DateRegionKey:
  Key    : Hex output from step 1  (Hex encoding)
  Message: us-east-1

Frequently Asked Questions

All computation happens entirely in your browser using the built-in Web Crypto API. No data leaves your machine. That said, you should always treat secret keys with care — avoid pasting production secrets into any online tool, including this one, unless you are on a trusted, private machine.

A plain hash (SHA-256, MD5…) is a one-way fingerprint of data. Anyone can compute it. An HMAC adds a secret key, so only parties who share the key can produce or verify the tag. HMAC also resists length-extension attacks, which affect plain SHA-256 and SHA-512 constructions.

HMAC operates on raw bytes, not characters. When you enter 48656c6c6f in Hex mode, the tool treats it as 5 bytes (the ASCII word "Hello"). In UTF-8 mode, the same string is 10 bytes (the characters '4', '8', '6', '5'…). The underlying bytes are different, so the HMAC values differ.

Base64url is a variant of Base64 that replaces + with -, / with _, and omits the trailing = padding. This makes the output safe to embed in URLs and HTTP headers without percent-encoding. JWT uses Base64url for all three of its segments (header, payload, signature).

Use HMAC-SHA256 for the vast majority of new applications — it offers 128-bit security, is supported everywhere, and is mandated by most modern security specifications. HMAC-SHA1 should only be used for backward compatibility with legacy systems. HMAC-SHA512 is appropriate when you need a longer output (e.g., key derivation) or when operating under strict security policies that require 256-bit equivalent security.

Yes. Enter the same message, key, algorithm, and encoding settings. If the computed hex or Base64 output matches the signature you received, the message is authentic and has not been tampered with. Comparison must be done carefully to avoid timing attacks in production code — use a constant-time comparison function in your server-side implementation.

JWT tokens signed with the HS256, HS384, or HS512 algorithm use HMAC internally. The token header specifies the algorithm, and the signature is HMAC(secret, base64url(header) + "." + base64url(payload)). The Base64url output of this tool is the exact signature segment used in those tokens — you can use this tool to verify or understand any HMAC-signed JWT.

HMAC-SHA1 remains computationally secure — the known SHA-1 collision attacks do not break the HMAC construction. However, it produces a smaller 160-bit output and is considered legacy. New systems should prefer HMAC-SHA256 or higher. Some standards (e.g., OAuth 1.0) mandate HMAC-SHA1 for compatibility, but modern OAuth 2.0 and OpenID Connect use HMAC-SHA256 or RSA instead.