Wednesday, November 3, 2021

Difference between Hash Function and MAC

Hash Function

In hash function H accepts a variable length block of input data called as ‘M’ and produces the fixed size hash value can be represented as h = M(H).

Figure: Block diagram of Hash Function

When hash function provides security, this is called cryptographic hash functions. Hash function protects the integrity of the message. If encryption process is applying on message with hash function, it is also providing authentication and confidentiality.

A hash function provides a property that has function applied on variable amount of data (M) and then it produces the fixed amount of output data. If any bit or bits changes in the data, then whole hash function output data will also change. Cryptographic has function is one-way function, which is practically infeasible to invert. The most popular hashing algorithm is MD5 and SHA.


Message authentication is a mechanism or service used to verify the integrity of a message. Message authentication guarantees that the sender of the message is authentic.


Figure: Block diagram of MAC

A MAC algorithm, sometimes called a keyed hash function accepts as input a secret key an arbitrary-length message to be authenticated, and outputs a MAC. MAC value protects both a message’s data integrity as well as its authenticity, by allowing verifies to detect any changes. The MAC is a small fixed-size block of data that is generated based on a message M of variable length using secret key K as follows. MAC is also called cryptographic checksum.

MAC = C (K, M)

Difference between Hash Function and Message Authentication Code (MAC)

To learn more about Difference between hash function and MAC, Click here

   Watch more videos click here.

No comments:

Post a Comment