MockReal Logo
Home
BlogPricing
For Employers →
  1. Home
  2. Questions
  3. How does HMAC work?

How does HMAC work?

TechnicalSecurity Operations EngineerCryptography EngineerNetwork Security Engineer

HMAC, or Hash-based Message Authentication Code, is a mechanism that combines a cryptographic hash function with a secret key to ensure data integrity and authenticity. It works by taking the message and the key, processing them through the hash function, and producing a fixed-size hash output. The key is crucial because it ensures that only parties who possess the secret can generate or verify the HMAC.

To create an HMAC, the process involves two main steps: first, the key is combined with the message, and then the result is hashed. This dual hashing approach provides resistance against certain attacks, such as length extension attacks, which can compromise simpler hash functions. A practical example is using HMAC in API authentication, where the server and client share a secret key. The client sends requests with an HMAC of the payload, allowing the server to verify that the request hasn’t been altered.

When comparing HMAC to digital signatures, HMAC is faster and simpler but relies on a shared secret, making it less suitable for scenarios requiring non-repudiation. In contrast, digital signatures use asymmetric cryptography, allowing verification without sharing a secret key, but they are computationally more intensive. Choosing between them depends on the specific security requirements of the application.

More Questions

  • Describe the difference between synchronous and asynchronous encryption.
  • What is Perfect Forward Secrecy?
  • What’s the difference between Diffie-Hellman and RSA?
  • Describe HTTPs and how it is used.
  • Describe SSL handshake.
  • Describe the hardening measures you've put on your home network.
  • Explain TCP/IP concepts.
  • Explain the differences between TCP and UDP protocols.
  • Explain what information is added to a packet at each stop of the 7 layer OSI model.
  • Explain what traceroute is.
MockReal Logo

Spoken interview practice for technical professionals

Product

  • Pricing
  • Questions
  • Positions
  • Resumes
  • For Employers →

Company

  • Careers
  • About Us
  • Contact
  • Blog

Legal

  • Privacy Policy
  • Terms of Service
  • Cookie Policy

© 2025 MockReal. Spoken interview practice. All rights reserved.