What is a message digest?

A messagedigest is a sortof a fingerprint for a chunk of data. If only one bit of that data has changed, the message digest algorithm would generate a different fingerprint. This allows you to determine if, for example during network transmission of data, that data has changed. You cannot deduce the original contents of a message from a message digest.

A common example is the use of a password system, where passwords are stored as messagedigests. When you logon to the system, it will compute a messagedigest of the password you’ve typed in and compare it with the messagedigest that is stored in the username/password file.

There are two popular types of message digest algorithms: MD5 and SHA.

For example, the MD5 message digest for the plaintext The sun is green and the grass shines is (in hex) 470DB3B23F9D445446DFCE291C9F17AB.

For information on how to generate a messagedigest in Java, look at this answer.