92. Computing file hashes

File hashes are often used to ensure the integrity of content, such as in the case of downloading a file from the web. Although implementations of the SHA1 and MD5 hashing functions can be found in a variety of libraries, we will again use the Crypto++ library. If you did not follow the previous problem and its solution, Validating user credentials, you should do so before continuing with this one, because the general information about the Crypto++ library that was given there will not be repeated here.

Computing a hash for a file is relatively simple using the Crypto++ library. The following code uses several components:

  • FileSource, which allows reading data from a file using a BufferedTransformation. By default, ...

Get The Modern C++ Challenge now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.