Hash Message Authentication Code is a standard that specifies an algorithm for an application to authenticate both source of a message and its integrity without the use of any additional mechanisms.
Message authentication is achieved by a message authentication code (MAC) and MAC based on hash functions are called HMACs.
The sender and receiver will decide on a key to use for the process.
The message sender will run a hashing function like MD5 or SHA and then run another mathematical calculation using the pre decided key. After the sender is done , he’ll send the original message and the computed hash and key calculation to the receiver.
msg = Aasdkjda
f(H(MSG), key) = message code.
The receiver will run the same calculations using the same key and will the use the same hash function used by the sender on the received original message. The receiver will then compare the computed hash on the original message with the hashed value it has received.
If the values match then the message integrity as been maintained and the receiver has also authenticated the sender as well.