What is Message and Message Digest in Cryptography?

A Message is any information that flows via the network, such as files, emails, and financial transactions, from one device to another or from a set of devices. When a message is sent over a network, it must be secure to ensure that it is safe from anybody sitting in the middle listening to the conversation and having the ability to access, alter, or modify the message.

What is a Message Digest or Hash Value?

A message digest or hash value is a numeric string generated using the cryptographic hash function. The message string is passed to the hash function. Hash function computes a unique hash value for the provided message and this hash value acts as digital fingerprint of the message.

The cryptographic function creates the message digest, which may then be encrypted to give a second layer of security. This function is one-way; it can only be used to generate the message digest from the message, not the other way around. If the message digest is created using a symmetric key then it is known as MAC or Message Authentication Code. Encrypted message digests work as digital fingerprints and the receiver needs to decrypt the digests first to compare them.

Properties of a Message Digest

  • The message digest is always a unique numeric hash value. It cannot be the same for two or more messages. Once the message digest value is generated for a message, it’s only associated with that message.
  • The size of the hash value is fixed. For any length of message a fixed length hash value is generated and that depends on the implementation of the hash function.
  • If you use the hash function multiple times for the same function again and again, then you only get the same digest value each time. For example, if you send “hii” to the hash function the generated message digest value will be the same each time when you pass “hii” to the hash function. It’s not going to change.
  • We cannot generate the message by passing the message digest value to the hash function. A hash function is a one-way function.

How Does a Message Digest Work?

Message digest works as a digital fingerprint for the message. In the communication channel, the sender and receiver communicate with each other so both must receive the right message. to ensure the integrity of the message digest is sent by the sender to the receiver along with the message. The receiver receives the message and the message digest value and the receiver uses the same hash function to generate a new message for the message he/she received. once generated receiver compares both the message digest values to verify that the message is received without any modifications and corrections. If both digest values are the same, it proves that the message has not been modified in the network by any person. Different digest values indicate that the received message is not the actual message send by the sender. This way we could check and verify the integrity of the message using message digest. For more clarity refer to the below example:

For example, if Alice wants to send a message to Bob, first of all, the message will be sent to the hash function, which will create the message digest. The created message digest is a unique string that cannot be converted back into a message. Alice will send this message digest and message to Bob over the communication channel. To ensure that Bob received the correct message digest, he will use the same hash function on the message and generate a new digest. Bob will compare the digest values; if they match, the message is original; otherwise, it has been modified.

Message Digests and Integrity Protection

The message digest is sent with the message. The receiver may generate a digest for the message and compare it to the sender’s. If both message digests are the same, the message’s integrity has been verified. Any modification of the message during transmission probably generates a different message digest.

So With the help of message digests, we can check the integrity of the messages, which means we can confirm whether the message is an original message or a modified message through the comparison of the message digests generated at different places. The message digest value for a particular message will always be the same whether it’s generated multiple times, so it ensures that every message has a unique digest and identifies a single message. 

The message digest can be encrypted using cryptographic symmetric or asymmetric algorithms. The encrypted message digest acts as a digital fingerprint of the message. when the sender sends the message and encrypted message digest, the sender also sends the secret key by which the message digest is encrypted along with them. The receiver receives the message, the message digest, and the key and the receiver decrypts the digest with the key and compares both the digest values to check the integrity of the message.

Encryption ensures that only authorized persons can access the digest value and decrypt it. Malicious attackers and middle men can not decrypt the digest without knowing the secret key and the secret key is only known to the sender and receiver.

Conclusion

In conclusion, it is important to understand that any piece of data sent via any communication channel can be intercepted or altered unless other proper measures are put in place hence there is a need to ensure data integrity using what we call a message digest that gives the digital fingerprint for any given message or information.

Frequently Asked Questions on Message and Message Digest in Cryptography – FAQs

Is it possible to get message back from the message digest?

No, we can not get the orignal message back from the message digest because it is generated using the one-way function.

Which hash functions are widely used to generate message digests?

SHA-1, SHA-256, SHA-3, and MD5.

In what ways are message digests distinct from encryption?

Message digests check for integrity. Encryption requires a key if you wish to decrypt a message, unlike digests which do not require keys and are one-way.


Contact Us