Hashes/Cripto
HMAC Generator
Calcula el HMAC (Hash-based Message Authentication Code) de un texto o archivo con una clave secreta — con ocho algoritmos a la vez: MD5, SHA-1, SHA-256, SHA-384, SHA-512, SHA3-256, SHA3-512, RIPEMD-160.
HMAC (Hash-based Message Authentication Code) is a hash computed together with a secret key, proving a message hasn't changed and was sent by someone who knows that key. Unlike a plain hash, an HMAC can't be forged without knowing the secret.
How to use it
- Enter text or a file and a secret key — the HMAC is computed instantly with eight algorithms at once (MD5, SHA-1, SHA-2, SHA3, RIPEMD-160).
- Copy the variant you need to verify a signature or compare against an expected value.
- The same input and key always produce the same HMAC — handy for checking against a signature received from another system.
Common uses
- Verifying a webhook signature from a payment service or API (most sign the payload with HMAC-SHA256).
- Generating a request signature for an API that requires HMAC authentication.
- Debugging a mismatched signature — checking the key, input encoding, and algorithm one at a time.
Things to keep in mind
HMAC protects against tampering and confirms the sender's authenticity, but it doesn't encrypt the message itself — the content stays readable.
A mismatched HMAC is most often caused by different data encoding (e.g. JSON field order) or a stray whitespace or line break, not by a bug in the algorithm itself.
Artículo sobre esta herramienta: HMAC: en qué se diferencia un hash con clave de un hash normal
Preguntas frecuentes
¿Cuál es la diferencia entre HMAC y un hash normal?
Un hash normal solo demuestra que los datos no fueron alterados; HMAC además usa una clave secreta, por lo que demuestra tanto la integridad como que el emisor conocía el secreto compartido — sin la clave nadie puede producir un HMAC válido aunque conozca el algoritmo.
¿Qué algoritmo de hash debería elegir para HMAC?
HMAC-SHA256 es una opción moderna sólida por defecto. Opciones más antiguas como HMAC-MD5 o HMAC-SHA1 aún no están rotas como HMAC específicamente, pero se recomienda SHA-256 o más fuerte para sistemas nuevos.
¿Se envía mi clave secreta a algún sitio?
No. El HMAC se calcula enteramente en tu navegador mediante la Web Crypto API — la clave y el mensaje nunca salen de tu dispositivo.
¿Por qué no se puede comparar un HMAC con el operador de igualdad normal?
Una comparación de cadenas normal se detiene en la primera discrepancia, y el tiempo de ejecución revela al atacante cuántos caracteres iniciales adivinó correctamente (timing attack). Se necesitan funciones de comparación en tiempo constante, como hash_equals en PHP.
¿Se puede usar la misma clave para varios propósitos distintos?
No se recomienda. Si la misma clave secreta se usa tanto para firmar webhooks como para otro fin, comprometer un sistema compromete automáticamente el otro — conviene generar una clave independiente para cada propósito.