HMAC
A message authentication code built from a hash function and a secret key, specified in FIPS 198-1 and RFC 2104. It is used in TLS, JSON Web Tokens (HS256), API request signing, HKDF and PBKDF2. Grover's search would roughly halve its effective security, so 256-bit keys and outputs stay adequate.
In short
What a quantum computer changes.
- Quantum effect
- Weakened by Grover's search
- Family
- SymmetricRests on hash function security.
- What it means
- Grover's algorithm searches an unstructured space in roughly the square root of the usual number of steps. Against a symmetric key or a hash preimage, that roughly halves the effective security in bits: a 128-bit key gives about 64 bits of security against it. In practice the answer is size, not replacement. Keys and outputs of 256 bits stay adequate. Grover's search also needs a long, sequential run on a fault-tolerant machine and does not split well across many machines, so the effect is a smaller margin, not a break.
This describes the family, not any project that uses it.
55 in the catalogue
Packages that provide it
| Package | Provides |
|---|---|
| @noble/hashesnpm | Pure TypeScript hash, MAC and KDF library: SHA-1, SHA-2, SHA-3 and Keccak, BLAKE2 and BLAKE3, RIPEMD-160, HMAC, HKDF, PBKDF2, scrypt and Argon2. |
| hash-wasmnpm | Hash and password-hashing functions compiled to WebAssembly, including SHA-1, SHA-2, SHA-3, Keccak, BLAKE2, BLAKE3, RIPEMD-160, HMAC, PBKDF2, scrypt, bcrypt and Argon2. |
| hash.jsnpm | Pure JavaScript SHA-1, SHA-2 and RIPEMD-160 hashes with HMAC, for Node.js and browsers. |
| js-sha256npm | Pure JavaScript SHA-256 and SHA-224 hash functions with HMAC. |
| crypto-jsnpm | Pure JavaScript library of hashes, HMAC, PBKDF2 and ciphers: MD5, SHA-1, SHA-2, a Keccak function it calls SHA3, RIPEMD-160, AES, TripleDES, RC4 and Rabbit. |
| sjclnpm | Stanford JavaScript Crypto Library; the default npm build provides AES in CCM, OCB2 and GCM modes, SHA-256, HMAC, PBKDF2 and a Fortuna-style random generator. |
| libsodium-wrappersnpm | libsodium compiled to WebAssembly and JavaScript with generated wrappers: X25519, Ed25519, XSalsa20-Poly1305 and ChaCha20-Poly1305 encryption, BLAKE2b, SHA-2, SHA-3, HMAC, Argon2 password hashing, ML-KEM-768 and the X-Wing hybrid KEM. |
| libsodium-wrappers-sumonpm | The sumo build of libsodium.js: everything in libsodium-wrappers plus scrypt password hashing and lower-level functions. |
| sodium-nativenpm | Low-level native Node.js bindings to libsodium: X25519, Ed25519, XSalsa20-Poly1305 and ChaCha20-Poly1305 encryption, BLAKE2b, SHA-2, HMAC, Argon2 and scrypt, plus a PBKDF2-SHA512 extension. |
| node-forgenpm | Pure JavaScript cryptography and PKI toolkit: RSA signing and encryption, Ed25519, AES (including GCM), DES and RC2, SHA-1, SHA-2, MD5, HMAC, PBKDF2, a Fortuna-based random generator, X.509, PKCS formats and a TLS implementation. |
| jsrsasignnpm | Pure JavaScript library for RSA, RSA-PSS, ECDSA and DSA signatures, hashes and HMAC, PKCS key formats, X.509 certificates, CRL, OCSP, CMS and JWS/JWT. |
| @peculiar/webcryptonpm | WebCrypto API implementation for Node.js on top of the built-in crypto module, adding curves such as secp256k1, brainpool, Ed448 and X448 and non-standard mechanisms such as DES and RSAES-PKCS1-v1_5. |
| crypto-browserifynpm | Browser port of the Node.js crypto module that re-exports the browserify packages for hashes, HMAC, PBKDF2, AES, Diffie-Hellman, ECDH, RSA and ECDSA signing and RSA encryption. |
| create-hmacnpm | Node-style createHmac for browsers that computes HMAC over SHA-1, SHA-2, RIPEMD-160 or MD5, and uses the built-in crypto module in Node.js. |
| jsonwebtokennpm | JSON Web Token signing and verification with HMAC-SHA-2, RSA PKCS#1 v1.5, RSA-PSS and ECDSA on P-256, P-384 and P-521, computed by the Node.js crypto module. |
| jwsnpm | JSON Web Signature creation and verification with HMAC-SHA-2, RSA PKCS#1 v1.5, RSA-PSS and ECDSA on P-256, P-384 and P-521. |
| jwanpm | JSON Web Algorithms signing and verification for JWS: HMAC-SHA-2, RSA PKCS#1 v1.5, RSA-PSS and ECDSA on P-256, P-384 and P-521. |
| josenpm | JWS, JWE, JWT and JWK for Node.js, browsers and other WebCrypto runtimes, with RSA, ECDSA, Ed25519 and ML-DSA signatures, HMAC, RSA-OAEP, ECDH-ES and AES key management, AES-GCM and AES-CBC-HMAC content encryption and PBES2. |
| node-josenpm | JOSE (JWS, JWE, JWK) implementation from Cisco with RSA, ECDSA and ECDH on the NIST P curves, HMAC, AES (GCM, CBC-HMAC and key wrap), HKDF and PBES2. |
| ssh2npm | SSH2 client and server in JavaScript for Node.js, with Curve25519, ECDH and finite-field Diffie-Hellman key exchange, Ed25519, ECDSA, RSA and DSA host keys, AES-GCM, AES-CTR, AES-CBC and ChaCha20-Poly1305 ciphers, and HMAC. |
| otplibnpm | HMAC-based (HOTP, RFC 4226) and time-based (TOTP, RFC 6238) one-time password generation and verification. |
| otpauthnpm | HMAC-based (HOTP, RFC 4226) and time-based (TOTP, RFC 6238) one-time password generation and validation for Node.js, Deno, Bun and browsers. |
| ethersnpm | Ethereum library with secp256k1 signing, recovery and ECDH, Keccak-256, SHA-2, RIPEMD-160, HMAC, PBKDF2 and scrypt helpers, BIP-39 and BIP-32 wallets, and encrypted JSON keystores. |
| @ethersproject/hdnodenpm | The ethers v5 sub-package for BIP-32 key derivation and BIP-39 mnemonics over secp256k1. |
| @metamask/key-treenpm | MetaMask interface over BIP-39, BIP-32, BIP-44 and SLIP-10 key derivation for secp256k1 and Ed25519 keys. |
| bip32npm | BIP-32 hierarchical deterministic keys over secp256k1, using HMAC-SHA512 for derivation and Hash160 for fingerprints, with ECDSA and Schnorr signing through an injected secp256k1 library. |
| @scure/bip32npm | BIP-32 hierarchical deterministic wallets over secp256k1, with HMAC-SHA512 derivation, Hash160 fingerprints and ECDSA signing. |
| hdkeynpm | BIP-32 hierarchical deterministic keys with HMAC-SHA512 derivation and secp256k1 signing and verification. |
| ed25519-hd-keynpm | SLIP-0010 hierarchical key derivation for Ed25519 using HMAC-SHA512. |
| @polkadot/util-cryptonpm | Polkadot crypto utilities: sr25519, Ed25519 and secp256k1 keys and signatures, BLAKE2, Keccak, SHA-2, HMAC, PBKDF2, scrypt, NaCl secretbox and encrypted JSON. |
| @polkadot/wasm-cryptonpm | WebAssembly build of the Rust primitives behind @polkadot/util-crypto: sr25519, Ed25519, secp256k1, BLAKE2b, Keccak, SHA-2, HMAC, PBKDF2, scrypt and BIP-39. |
| @cosmjs/cryptonpm | CosmJS cryptography: secp256k1 and Ed25519 signing, SHA-2, Keccak-256, RIPEMD-160, HMAC, BIP-39, SLIP-10, Argon2id and XChaCha20-Poly1305. |
| @libp2p/cryptonpm | libp2p key and crypto primitives: Ed25519, secp256k1, ECDSA P-256, P-384 and P-521, and RSA keys, ephemeral ECDH, AES-GCM, HMAC and PBKDF2. |
| @ton/cryptonpm | TON crypto primitives: SHA-256, SHA-512, HMAC-SHA-512, PBKDF2-SHA-512, TON mnemonics, Ed25519 signing, NaCl secret boxes and SLIP-10 Ed25519 HD keys. |
| ringcrates.io | Cryptographic library largely derived from BoringSSL, offering ECDSA P-256 and P-384, Ed25519, RSA signatures, X25519 and ECDH, AES-GCM, ChaCha20-Poly1305, SHA-1 and SHA-2, HMAC, HKDF, PBKDF2 and a system random generator. |
| aws-lc-rscrates.io | ring-compatible Rust API over the AWS-LC C library, adding ML-KEM, ML-DSA, RSA encryption, raw AES modes and an optional FIPS build. |
| aws-lc-syscrates.io | Low-level generated FFI bindings to the AWS-LC C cryptography library, which aws-lc-rs wraps. |
| opensslcrates.io | Rust bindings to OpenSSL covering TLS, X.509, RSA, DSA, Diffie-Hellman, elliptic curve and Edwards curve keys, symmetric ciphers, hashes, MACs and key derivation. |
| openssl-syscrates.io | Raw FFI declarations for the OpenSSL C library, used by the openssl crate. |
| boringcrates.io | Rust bindings to BoringSSL with TLS support, RSA, DSA, Diffie-Hellman, ECDSA and ECDH, Ed25519 and X25519, ML-KEM, ML-DSA, HPKE, AEAD ciphers, hashes, HMAC and key derivation. |
| mbedtlscrates.io | Rust wrapper for Mbed TLS covering TLS, X.509, RSA, ECDSA, ECDH, Diffie-Hellman, AES and ChaCha20-Poly1305, hashes, HMAC, HKDF, PBKDF2 and DRBG random generators. |
| botancrates.io | Rust wrapper for the Botan C++ library, exposing ciphers, hashes, MACs, KDFs, password hashing, random generators, X.509 and classical and post-quantum public key algorithms. |
| libcruxcrates.io | Re-export crate for the libcrux library of formally verified implementations, including ML-KEM, ML-DSA, X25519, P-256 ECDSA and ECDH, Ed25519, RSA-PSS, AES-GCM, ChaCha20-Poly1305, SHA-2, SHA-3, BLAKE2, HMAC, HKDF and HPKE. |
| orioncrates.io | Pure Rust library offering ML-KEM, ML-DSA, X-Wing, HPKE, X25519, (X)ChaCha20-Poly1305, BLAKE2b, BLAKE3, SHA-2, SHA-3, HMAC, HKDF, PBKDF2, Argon2 and scrypt. |
| dryoccrates.io | Pure Rust libsodium-compatible library with crypto_box, secretbox, Ed25519 signatures, BLAKE2b, SHA-2, SHA-3, HMAC, HKDF, Argon2 password hashing, ML-KEM-768, X-Wing and HPKE sealed boxes. |
| sodiumoxidecrates.io | Rust bindings to libsodium: X25519 crypto_box, XSalsa20-Poly1305 secretbox, Ed25519 signatures, ChaCha20-Poly1305 and AES-256-GCM AEADs, SHA-2, BLAKE2b, HMAC, Argon2 and scrypt password hashing. |
| libsodium-syscrates.io | Raw FFI bindings to the libsodium C library, used by sodiumoxide. |
| hmac-sha256crates.io | Small self-contained SHA-256, HMAC-SHA256 and HKDF-SHA256 in pure Rust. |
| hmaccrates.io | Generic HMAC (hash-based message authentication code) over any RustCrypto hash function. |
| rustlscrates.io | TLS 1.2 and TLS 1.3 library in Rust whose cryptography comes from a pluggable provider, aws-lc-rs by default or ring. |
| agecrates.io | Library for the age file encryption format, with X25519, hybrid ML-KEM-768 plus X25519, P-256 tag, SSH key and scrypt passphrase recipients and ChaCha20-Poly1305 payload encryption. |
| jsonwebtokencrates.io | JSON Web Token encoding and validation with HS256 to HS512, RS256 to RS512, PS256 to PS512, ES256, ES384 and EdDSA. |
| josekitcrates.io | JOSE library (JWT, JWS, JWE, JWK) with HMAC, RSA, ECDSA, EdDSA, ECDH-ES, AES key wrap, AES-GCM and PBES2, backed by OpenSSL, AWS-LC or pure Rust crates. |
| bitcoin_hashescrates.io | The hash functions used by rust-bitcoin: SHA-1, SHA-256 (plain, double and tagged), SHA-384, SHA-512, SHA3-256, RIPEMD-160 and HASH160, plus HMAC, HKDF and SipHash. |
| bip32crates.io | BIP32 hierarchical deterministic key derivation over secp256k1 using HMAC-SHA512, with k256 or libsecp256k1 key backends and optional BIP39 mnemonic seeds. |
2 listed
Sources
- FIPS 198-1: The Keyed-Hash Message Authentication Code (HMAC)csrc.nist.govRetrieved 3 December 2026
- RFC 2104: HMAC: Keyed-Hashing for Message Authenticationrfc-editor.orgRetrieved 3 December 2026
Full record
- Identifier
- hmac
- Kind
- mac
- Family
- Symmetric
- Rests on
- hash function security
- Quantum effect
- Weakened by Grover's search
Standards
- FIPS 198-1The Keyed-Hash Message Authentication Code (HMAC)NIST, final, published 16 July 2008Checked 3 December 2026
- RFC 2104HMAC: Keyed-Hashing for Message AuthenticationIETF, informational, published 1 February 1997Checked 3 December 2026