One of the most famous types of a Mac of a message something authentication code is the H Mac, the hashed message authentication code. In an H Mac, you're running a hash function as Sha 256 over the data and a shared secret key and a symmetric key that was generated before. Now this is very similar, if you remember from my first course to digital signatures, where a certificate authority hashes the payload the certificate and then encrypts it using its private key. But in H Mac, we use a symmetric key nothing asymmetric symmetric key. So let's see how that works. So let's generate a quick h mag of some plain text.
Let's use the echo command. And the text will be the attack will start, don't. Alright, let's wrap it into open SSL. And now we'll use the SHA 256. As our hash function we can use also MD five, you can use just about any hash function out there. And then we'll use the H Mac command and we'll type a key cryptid key or x and there we got it.
That's our h Mac, Mr. h Mac. And any men in the middle who tamper with the data, and would not have the shared secret key would not generate the same hash value, as seen here. So to recap, h max or any other hash message authentication code, we can take our message and hash it encrypted and send it over the network to the other side. If we want to reduce bandwidth, we can encrypt only the hash code of the message and concatenate it with the message itself.