Home › Developer Tools › HMAC Generator

HMAC Generator

Enter a message and a secret key to create an HMAC signature with SHA-256, SHA-512, SHA-384, SHA-1 or MD5. Switch to Verify to check a signature you received, for example from a webhook. Everything runs locally in your browser.

Last updated:

HMAC-SHA256 –

All algorithms

Advertisement

How to use the HMAC Generator

  1. Type or paste the message you want to sign. Choose Hex or Base64 if your payload is binary.
  2. Enter the secret key and pick its encoding: plain text, hex or Base64 (many APIs give Base64 secrets).
  3. Choose the algorithm and output format, for example HMAC-SHA256 in hex for most webhooks, or Base64URL for JWT signatures.
  4. Press Generate HMAC (it also updates as you type) and copy the result. The table shows every algorithm at once.
  5. To check a signature, open Verify signature, paste the value you received and press Verify Signature.

HMAC test vector you can check

The classic example uses the key key and the message The quick brown fox jumps over the lazy dog (both as UTF-8 text). Enter them above and you should get exactly these values:

AlgorithmHMAC (hex)
HMAC-MD580070713463e7749b90c2dc24911e275
HMAC-SHA1de7c9b85b8b78aa6bc8a7a36f70a90701c9db4d9
HMAC-SHA256f7bc83f430538424b13298e6aa6fb143ef4d59a14946175997479dbc2d1a3cd8

Algorithms, block sizes and output lengths

AlgorithmBlock sizeOutputHex lengthBase64 lengthTypical use
HMAC-MD564 bytes128 bits3224Legacy APIs, RADIUS
HMAC-SHA164 bytes160 bits4028OAuth 1.0, TOTP/HOTP codes, older webhooks
HMAC-SHA25664 bytes256 bits6444Webhooks (GitHub, Stripe, Shopify), AWS SigV4, JWT HS256
HMAC-SHA384128 bytes384 bits9664JWT HS384, TLS
HMAC-SHA512128 bytes512 bits12888JWT HS512, high-security signing

Computing HMAC-SHA256 in code

Once you have checked a value here, you can produce the same signature in your application:

LanguageCode
Pythonhmac.new(key.encode(), msg.encode(), hashlib.sha256).hexdigest()
Node.jscrypto.createHmac('sha256', key).update(msg).digest('hex')
PHPhash_hmac('sha256', $msg, $key)
Command lineprintf '%s' "$msg" | openssl dgst -sha256 -hmac "$key"

When verifying in code, compare signatures with a constant-time function such as hmac.compare_digest in Python or crypto.timingSafeEqual in Node.js to avoid timing attacks.

Frequently asked questions

What is an HMAC?

HMAC (hash-based message authentication code) combines a secret key with a hash function such as SHA-256 to produce a signature for a message. Anyone with the same key can recompute it to confirm the message was not changed and came from someone who knows the key.

How is HMAC calculated?

HMAC(K, m) = H((K′ ⊕ opad) ‖ H((K′ ⊕ ipad) ‖ m)), where K′ is the key padded to the hash block size (64 bytes for MD5, SHA-1 and SHA-256, 128 bytes for SHA-384 and SHA-512), ipad is the byte 0x36 repeated and opad is 0x5c repeated. Keys longer than the block size are hashed first.

How do I verify a webhook signature?

Use the raw request body exactly as received as the message, your webhook secret as the key and the algorithm the provider documents (usually HMAC-SHA256). Compare the result with the signature header. In the Verify tab you can paste the header value directly, including prefixes such as sha256=.

Why does my HMAC not match?

The most common causes are a different key encoding (a Base64 secret typed as text), extra whitespace or a different line ending in the message, a JSON body that was re-formatted before signing, or the wrong algorithm. Check each of these and compare byte counts.

Is HMAC-MD5 or HMAC-SHA1 still secure?

HMAC is much more robust than the plain hash, and HMAC-SHA1 and HMAC-MD5 have no practical forgery attacks today. Still, use HMAC-SHA256 or stronger for anything new; MD5 and SHA-1 are provided for compatibility with older systems.

What is the difference between Base64 and Base64URL output?

Base64URL replaces + with - and / with _ and drops the = padding, so the value can be used safely in URLs and HTTP headers. JSON Web Tokens (JWT) use Base64URL for their HS256 signatures.

Is my secret key sent anywhere?

No. The HMAC is computed in your browser with the Web Crypto API and a local MD5 routine. Nothing is uploaded or stored.

Are all the tools on FreeToolCabin tested for quality and accuracy?

Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.

Related tools

Hash GeneratorGenerate MD5, SHA-1, SHA-256 and SHA-512 hashes of text or files.SHA-256 Hash GeneratorSHA-256 and HMAC-SHA256 hashes of text, lines or files, in hex or Base64.MD5 Hash GeneratorGenerate MD5 hashes of text, lines or files and verify checksums.Bcrypt Hash Generator & CheckerCreate bcrypt password hashes and check a password against a hash.API Key GeneratorCreate secure API keys and secrets with prefixes, checksums and SHA-256 hashes for storage.JWT GeneratorCreate and sign HS256, HS384 or HS512 JSON Web Tokens in your browser and verify them.PBKDF2 Hash GeneratorDerive PBKDF2 keys from a password, salt and iteration count with SHA-1, SHA-256 or SHA-512.PGP Encrypt / DecryptEncrypt, decrypt, sign and verify PGP messages with your armored keys, entirely offline.Password GeneratorCreate strong passwords and passphrases.Base64 Encoder DecoderEncode or decode Base64 text and files, and make data URIs.URL Encoder DecoderPercent-encode or decode URLs, query strings and form data.HTML Entity Encoder / DecoderEscape and unescape HTML entities, named or numeric.Binary TranslatorConvert text to binary, hex, octal and back.CRC32 Checksum CalculatorCalculate CRC-32, CRC-32C, CRC-16 and Adler-32 checksums of text or large files.JWT DecoderDecode JSON Web Tokens, read the claims and expiry, and verify HS256 signatures.Password Strength CheckerSee how strong a password really is, how long it takes to crack and how to improve it.Caesar CipherEncode and decode Caesar shift ciphers and crack unknown shifts with a ranked brute force.Vigenère CipherEncrypt and decrypt Vigenère and Autokey ciphers, and crack unknown keys with frequency analysis.Atbash CipherEncode and decode Atbash ciphers (A↔Z, B↔Y) in Latin or Hebrew, with a live letter mapping table.ASCII TableFull ASCII code chart 0–255 in decimal, hex, octal, binary and HTML, with search and copy.Unicode Character LookupFind Unicode characters by name or code point and copy them with UTF-8, HTML and code escapes.Punycode ConverterConvert international domain names, emails and URLs between Unicode and xn-- Punycode, in bulk.JSON Escape / UnescapeEscape text for a JSON string, unescape \n and \" back to text, or stringify a whole object.Binary to HexConvert binary to hex instantly with steps and signed mode.Hex to BinaryConvert hex to binary instantly with steps and signed mode.Binary CalculatorAdd, subtract, multiply, divide, AND, OR, XOR and shift binary numbers with decimal values.Hex CalculatorHexadecimal + − × ÷ and AND, OR, XOR, NOT, shifts with decimal and binary equivalents.Base32 Encoder / DecoderEncode and decode Base32 (RFC 4648), Base32hex, Crockford and z-base-32 from text, hex or files.Base58 Encoder / DecoderEncode and decode Base58 and Base58Check (Bitcoin alphabet) from text or hex, with checksum verification.Unicode Escape / UnescapeConvert text to \uXXXX, \u{...}, \x, &#...; or CSS escapes and decode them back.File Hash CheckerGet MD5, SHA-1, SHA-256 and SHA-512 checksums of files and verify them against a hash.TOTP GeneratorGenerate 2FA one-time codes from a secret key, create otpauth QR codes and verify codes.SSL Certificate DecoderDecode PEM SSL/X.509 certificates: subject, issuer, expiry, SANs, key and fingerprints.Text Encryption ToolEncrypt and decrypt text with a password using AES-256-GCM, entirely in your browser.Argon2 Hash GeneratorHash passwords with Argon2id, Argon2i or Argon2d and verify them against an encoded hash.Base64 to PDFDecode a Base64 string to a PDF with preview and download, or encode a PDF to Base64.Bitwise CalculatorCalculate AND, OR, XOR, NOT and bit shifts at 8–64 bits with a bit grid and all bases.CSR GeneratorCreate a certificate signing request (CSR) and private key with SANs, RSA or ECDSA, in your browser.Base64 to FileDecode Base64 or a data URI to a downloadable file; detects the real file type and previews it.File Encryption ToolEncrypt and decrypt any file with a password using AES-256-GCM, entirely in your browser.Passphrase GeneratorMake strong, memorable diceware passphrases from a 7,776-word list, with entropy in bits.CSR DecoderDecode a PEM certificate signing request: subject, SANs, key size, signature and CA readiness checks.Enigma Machine SimulatorEncrypt and decrypt with a virtual Enigma I, M3 or M4: rotors, rings, plugboard and lampboard.Hex Opacity CalculatorConvert opacity percent to a 2-digit HEX alpha code and full #RRGGBBAA color, with a 0-100% table.Playfair CipherEncrypt and decrypt Playfair ciphers from a keyword, with the 5x5 key square and every digraph step.Pwned Password CheckerCheck if a password appeared in data breaches; only 5 characters of its SHA-1 hash are sent.RSA Encryption ToolEncrypt text with an RSA public key and decrypt it with the private key using RSA-OAEP in your browser.SAML DecoderDecode SAMLRequest and SAMLResponse messages to readable XML, attributes and validity times.SSL Certificate ConverterConvert SSL certificates and keys between PEM, DER, PFX/P12 and P7B in your browser.Checksum CalculatorCompute 8-bit sum, two's complement LRC, XOR/BCC, NMEA, Fletcher and Internet checksums of bytes.Protobuf DecoderDecode raw Protocol Buffers hex or Base64 without a schema, or add a .proto for field names.XML Escape / UnescapeEscape & < > " ' for XML text and attributes, unescape entities back, or wrap text in CDATA.Binary Search Tree VisualizerInsert, delete and find in BST, AVL and red-black trees with animated rotations and traversals.MongoDB ObjectId to TimestampDecode a MongoDB ObjectId to its creation date, or build ObjectIds from dates for range queries.PGP Key GeneratorGenerate an OpenPGP key pair (Curve25519, NIST ECC or RSA) with passphrase and expiry, offline.Quoted-Printable Encoder / DecoderEncode or decode quoted-printable email text (MIME) with UTF-8 and 76-character soft line breaks.Self-Signed Certificate GeneratorCreate a self-signed SSL certificate and key for localhost or dev servers, as PEM or PFX.SHA-512 Hash GeneratorSHA-512 and SHA-384 hashes of text or files in hex or Base64, HMAC and hash verification.SRI Hash GeneratorCreate Subresource Integrity hashes (sha256/384/512) and ready <script> or <link> tags.SSH Key GeneratorGenerate Ed25519 or RSA SSH key pairs in your browser: OpenSSH public key plus private key.String Escape / UnescapeEscape or unescape strings for JavaScript, Java, C#, Python, C, SQL, regex, CSV and shell.UTF-8 Encoder / DecoderConvert text to UTF-8 bytes in hex, decimal, binary, \x or % and decode bytes back to text.UUID Decoder & ValidatorDecode any UUID: version, variant, v1/v6/v7 timestamp and MAC node, plus bulk validation.
See all 65 Encoders, Hashes & Crypto →