RSA MD5 Message Digest | CodeGuru

RSA MD5 Message Digest

This article was contributed by Nick Stone of Langfine Ltd. Overview This is a C++ implementation of the RSA MD5 message digest algorithm. The algorithm calculates a 16 byte checksum for any data sequence (e.g., array of bytes, a string or a file). Full details of the MD5 algorithm are provided within the code. Two […]

Written By
CodeGuru Staff
CodeGuru Staff
Oct 30, 2002
2 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

This article was contributed by Nick Stone of Langfine Ltd.

Overview

This is a C++ implementation of the RSA MD5 message digest algorithm. The algorithm calculates a 16 byte checksum for any data sequence (e.g., array of bytes, a string or a file). Full details of the MD5 algorithm are provided within the code.

Two projects are provided:

  • MD5.dsw—builds a library that provides the MD5 calculation routines.
  • MD5ChecksumTest.dsw—builds a modeless dialog test environment that demonstrates use of the MD5 library and provides a simple verification tool.

Important Notes

Wherever this implementation of the RSA MD5 algorithm is used, the RSA copyright notices etc. must be adhered to, as described within the code and the test application’s “About” box.

All use of this algorithm is at the users risk—no liability of any kind whatsoever is accepted by Nick Stone nor Langfine Ltd.

Further Details

The MD5 message digest algorithm is wrapped in a C++ class named CMD5Checksum.

Three public functions are exported:

CString GetMD5(BYTE* pBuf, UINT nLength);
CString GetMD5(CFile& File);
CString GetMD5(const CString& strFilePath);

All are implemented as static functions. The checksum calculated is returned as a 32 character hexadecimal number held in a CString. GetMD5 is overloaded to take data to be checksummed as either an array of bytes or a file.

The class CMD5Checksum is held within the MD5.dsw project. Building this project
creates MD5.lib.

A test environment is provided in the project MD5ChecksumTest.dsw. This allows the user to type a string and see its checksum calculated in real time and also to select a file for checksum. Data files are provided containing simple test data; get the checksum for these and then try typing the file’s contents into the first edit box and compare the two checksums thus obtained (they should be the same!) The test environment also includes a “Self Test” button. This checksums each of the supplied test data files in turn and checks the calculated checksum with the known correct value.

Advertisement

Downloads


Download source – 18 Kb

Download demo project – 46 Kb
CodeGuru Logo

CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.