Generate a test HMAC for a fictional webhook message

Use the HMAC Generator with a dummy key and message, select a hash algorithm, and validate the resulting hexadecimal MAC.

By DevSphere Editorial · · 5 min read

Open Hash & Crypto

Understand what a keyed digest does

An HMAC combines a message, a secret key, and a hash algorithm to produce a message authentication code. It can help a receiver who already shares the key detect changes and confirm that a message was created by someone who knows that key. It is not encryption: the message remains visible, and the output does not conceal its contents. This exercise uses a fictional payload and a disposable demonstration key. Never paste an active production signing key into a browser tool or shared environment, and do not reuse the sample key as a real credential.

Open Hash & Crypto and select HMAC Generator. The Message text area holds the exact data being authenticated, Secret Key is a separate field, and Algorithm offers HMAC-SHA1, HMAC-SHA256, HMAC-SHA384, and HMAC-SHA512. Enter the sample values below, keep SHA-256 selected, and press Generate HMAC. The HMAC Result panel displays a hexadecimal value. Because a small difference in either the message or key changes the result, preserve the bytes and whitespace exactly for meaningful comparisons.

Message: event=demo;status=queued
Secret Key: training-only-key
Algorithm: HMAC-SHA256
Expected HMAC: 8de942079bbec1ee558638189f95233d87970d9ca45067173658929a1d1d8774

Generate and inspect the result

The tool encodes both Message and Secret Key as UTF-8 text, imports the key for HMAC, and signs the message using the selected hash. After Generate HMAC, confirm that the result is nonempty and has the expected hexadecimal format for the algorithm. SHA-256 produces a 256-bit result represented as 64 hex characters. The tutorial does not provide a fixed digest because any exact output depends on the precise sample characters and should be produced by the interface; copy it only after confirming the labels and algorithm.

The result is produced on button press rather than continuously as the fields change. If you edit Message or Secret Key afterward, generate again before using the displayed output; otherwise it may correspond to prior inputs. The UI provides a copy button next to a nonempty result. For a reproducible test, record the exact message, dummy key, chosen algorithm, and resulting MAC as a single test tuple. Keep those ingredients together in private test materials only when appropriate, because an HMAC key is sensitive even if the message is harmless.

Test sensitivity without using real credentials

Change only `queued` to `ready`, click Generate HMAC again, and observe that the MAC changes. Restore the original message and change one character in the demo key; the result should change again. These experiments show that the output depends on both inputs. They do not prove that an implementation elsewhere uses the same canonicalization, encoding, or key bytes. Avoid testing with a real webhook secret: a tutorial should not require sharing a secret to establish that HMAC works.

A frequent integration mismatch is signing a different representation than the receiver verifies. For example, whitespace normalization, JSON key ordering, line endings, or character encoding can alter the message bytes. This UI signs the text as entered, not a parsed JSON object or a raw HTTP request body. If your production protocol signs raw bytes, use the protocol's official client and verification library and preserve the body exactly. Treat this page as a learning and controlled text experiment, not as the production signing service.

Separate authentication from confidentiality

HMAC authenticates integrity relative to a shared secret, but anyone with the key can generate valid MACs. It does not identify a particular person when a key is shared, and it does not prevent replay of an old message. Replay protection typically requires a protocol-level timestamp, nonce, or unique identifier plus receiver-side rules. Confidentiality requires a separate encryption design, and the component does not offer AES encryption despite descriptions elsewhere that may mention it. Do not present an HMAC as an encrypted payload.

The selected algorithm must match the receiving system's contract exactly. A SHA-256 HMAC cannot be substituted for an HMAC-SHA1 verifier merely because both are HMACs. SHA-1 can appear for legacy compatibility, but new integrations should follow current protocol guidance and generally choose a modern option such as SHA-256. Do not send the algorithm name with the MAC unless the protocol defines that field; protocol formatting is not automatically generated by the page.

Troubleshoot an unexpected MAC

If a verifier rejects the value, first compare the message byte-for-byte, including final newline, punctuation, and spaces. Then confirm that both sides use the same key characters, character encoding, and HMAC algorithm. Verify that the receiver expects hexadecimal rather than Base64 output and that it is not comparing a URL-safe or prefixed string. A local result from this page cannot establish that the receiver's implementation is correct or that the secret was provisioned consistently.

If Generate HMAC returns no value, check that both Message and Secret Key contain non-whitespace text. The component exits early for empty or whitespace-only values. Browser Web Crypto support is also required; a returned error is not an authentication tag. Avoid pasting secrets into screenshots, browser logs, or notes shared outside your controlled test environment. Clear the fields when finished and use the sample key only for this demonstration.

Use a verification design in real systems

A proper integration test should create a known fictional message and key in a test environment, compute the HMAC with the same protocol library used by the sender, and verify it with the receiver's independent implementation. Include negative cases where one message character or key byte changes, and ensure the receiver rejects a stale or replayed message if its protocol requires freshness. Compare bytes using a constant-time verification function in the receiver rather than hand-written string logic. The browser output is useful for a learning check, not a replacement for those controls.

For this page, finish by restoring the original dummy values, generating once more, and confirming that the result returns to the same value as the initial run. HMAC is deterministic for identical key, message, and algorithm. This repeatability is a useful sanity check. Document that the generated result authenticates a message but does not hide it, and that production signing keys must remain in a managed secret store or trusted runtime rather than being pasted into a general-purpose web interface.

Browse all tutorials