What is a Message Authentication Code?

Mary McMahon
Mary McMahon

A message authentication code (MAC) is a small block of data attached to a message that is used by the recipient to verify the integrity of the message. One could think of it as akin to the wax seals that used to be placed on letters and formal correspondence to verify the identify of the sender and confirm that the message had not been opened. Such codes are used when certain types of encrypted or secured data are sent so the sender can check to confirm that the message has not been compromised. Message authentication codes can appear on messages such as electronic funds transfers and emails.

Man climbing a rope
Man climbing a rope

When a message is generated, the MAC is created at the same time. The message is sent to the recipient, and when the recipient opens it, the contents of the message are run through an algorithm to create a new message authentication code. This new code is compared with the code sent along with the original message. If the codes are the same, the message is authenticated. If there is a difference, it indicates that something about the message changed between sender and recipient.

The process of generating and comparing MACs usually happens behind the scenes. The sender and recipient rely on the encryption programs they use to handle the MAC. The program that generates the message authentication code is written by a programmer familiar with cryptography needs. Custom applications may be written for high security situations, or people can use generic programs that are readily available.

Several different methods can be used to create a MAC, including a stream cipher, a hash function, or a block cipher. Also known as a checksum, the MAC can be one among several layers of security that are designed to keep prying eyes away from messages and to ensure that messages are not manipulated or altered without alerting the recipient. When a recipient opens a message that has been compromised, an alert will display to tell the user that the message authentication code does not match and that there is a problem with the message.

Cryptography is a constantly evolving process. As new techniques are developed, new methods for cracking them are also created. People interested in data security must think several steps ahead to predict methods for breaking cryptography so they can build strong security systems. The development of supercomputers has assisted with this process by allowing cryptographers to develop and experiment with highly advanced encryption methods.

Mary McMahon
Mary McMahon

Ever since she began contributing to the site several years ago, Mary has embraced the exciting challenge of being a wiseGEEK researcher and writer. Mary has a liberal arts degree from Goddard College and spends her free time reading, cooking, and exploring the great outdoors.

You might also Like

Readers Also Love

Discussion Comments


@ysmina-- I think anyone who has the expertise to do so can create and use a MAC. I wouldn't worry about law enforcement not having access to it because as far as I'm aware, they have all the expertise necessary to break any type of encryption.

But creating a MAC is not easy to do. My brother does it sometimes for emails but he studied Computer Science in college. It's definitely not something that just about anyone can do. It requires technical knowledge which I definitely don't have.


Great article! Things make so much more sense to me now! I've been receiving messages from my email host about an 'incorrect message authentication code' for weeks and have been so confused about what that means.

I didn't even know that such a thing existed. Interestingly, I have another email account with another host and never receive these messages from there. So I guess some email hosts have an embedded message authentication code in place and others don't.

I'm not really sure if there is an actual error with my email host constantly sending these messages or if someone really has access to my emails. It's kind of scary to think about that actually. I'm being more careful about my emails now than ever. I want to avoid including any important information in there like ID numbers, passwords or bank account information. Who knows who is reading them.


The message authentication code sounds like a great way to secure data that's being emailed. But I have two questions about the use of it. First of all, can anyone (who has the expertise and means) use a message authentication code? Are there any laws that prevent just about anyone to use one?

I'm wondering about this because I know that the government keeps an eye on the internet to make sure than nothing potentially dangerous to national security is happening. Even though I agree that people have a right to confirm and secure authentication of their messages, if these codes were to be widely used by public users, it might be a problem for law enforcement.

The other thing I'm wondering about is what happens next when a user realizes that the message has been compromised? Does this system also give information about when and by whom the message was read?

Post your comments
Forgot password?