A hash of a text or other string of bytes is an associated, statistically unique, fixed-length value. In some documents, a hash of a text is also called a digest; however, in this documentation the term hash will always be used. CryptoAPI functions provide a means to create a hash for any text or other string of bytes. That hash, then, can be used as a unique identifier of its associated data.
To ensure the integrity of a text, a hash of a text can be sent to accompany the text. The receiver can then compute a hash on the data received and compare the hash computed with the hash received. If the two match, the data received must be the same as the data from which the received hash was created.
After the last block of data is added to the hash, the CryptGetHashParam function is used to obtain the hash value of the data.
Better security is provided by destroying the hash object with CryptDestroyHash as soon as the hash value has been obtained.