RSA MD5 Message Digest

Summary
This is a Visual 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.


Screenshot of MD5 Test Program

MD5 Checksum Test Program

Download
The download consists of two Visual C++ V6 projects, the executable program itself, test data files and documentation.

Download from this site has been suspended for security reasons. It may still be downloaded from the codeguru site here. (The version at codeguru does not include the performance test).

Download Contents

MD5 Library Source Code (MD5.dsw)
This Visual C++ project builds a static library that provides the MD5 calculation routines. The source code will unzip to a folder named 'Code'. The library will build to 'Release' or 'Debug' subfolders. Do not change this folder configuration if you wish to build the MD5 Test Program (see below).

MD5 Test Program Source Code (MD5ChecksumTest.dsw)
This Visual C++ project builds an executable program that uses the MD5 library to calculate checksums. The source code will unzip to a folder named 'Test'. The executable will build to 'Release' or 'Debug' subfolders. The MD5 Library is a dependent subproject and so will build automatically before the test program. The MD5 library source code must be held in a folder named 'Code' which should be at the same level as the 'Test' folder. This is the default folder configuration created by the zip file.

MD5 Test Program Executable  (MD5ChecksumTest.exe)
This is the executable program built by the MD5 Test Program Source Code (see screenshot above). It can be used to calculate the MD5 checksum for manually entered strings or for individual files.

Test Data
Several test data files are included within the test program source code and executable zip files. These test files will unzip to a folder named 'TestData'. The MD5 Test program uses these files to perform an automatic self verification. It expects to find them within the TestData subfolder.

Documentation
A copy of this web page is included in the download. The majority of the projects' documentation is in the form of commented source code.

Further Details - MD5 Library
The MD5 message digest algorithm is wrapped in a C++ class named CMD5Checksum. This exports three public functions:-

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

All three 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 as a file. The class CMD5Checksum is held within the MD5 library source code. Building this project creates the static library MD5.lib.

Further Details - MD5 Test Program
A demonstration and test environment is provided in the MD5 test program. This allows the user to:-

●  Type a string and see its checksum calculated in real time
●  Select a file and calculate its checksum
●  Perform an automatic self verification
●  Get performance figures

The user may type into the "Enter a string" edit box; the corresponding checksum will be calculated and displayed in real time. The test program source code download includes test data files. The user may browse and choose a file for checksum in the "Select a file" edit box; the file's checksum is then displayed. The checksums for the smaller test files may be verified by typing the contents directly into the "Enter a string" edit box. Obviously, the checksums obtained by both methods 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 verifies the results. Finally, a "Performance Test" is provided. This displays and records statistics that indicate the execution speed of the checksum calculation. Thus, the performance implications of any modifications to the implementation can be assessed.

Public Domain
This implementation of the RSA MD5 algorithm was developed by Langfine Ltd and has been placed in the public domain for free use. However, wherever it is used, the RSA copyright notices must be adhered to, as described within the code and the test application's "About" box. Also, Langfine must be credited. If the code is modified in any way, this should be mentioned. Source code should clearly distinguish between Langfine's original code and the modifications. 

Version History
V1.2    Performance indicators added.
V1.1    Performance improved by making some functions inline.
V1.0    First release.

Disclaimer
This download is provided free of charge by Langfine Ltd. All use is at your own risk. No liability of any kind whatsoever is accepted by Langfine Ltd. See Disclaimers.

Comments
If you improve the implementation in any way, we will be happy to update our code and make your changes available here.

 

© 2004 Langfine Ltd