Message authentication code (MAC) provides a way to verify both the integrity and authenticity of a message. It is sometimes also called an authentication tag.

A MAC allows the recipient to ensure that a message has not been altered and that it truly originates from the expected sender.

With MAC, both the sender and the receiver share a secret key , which is used to compute the MAC of the message . It can be expressed as the function: The sender generates the MAC and sends it along with the message. The receiver recalculates the MAC based on the received message and then checks whether it matches the received MAC. image from wikipedia

There are multiple ways to generate a MAC, with the most common one being HMACS (hash-based message authentication code).

Subtopics