Home

About Us

Books

Free Stuff

Oh, So That's How It Works!

Fellow Magicians

Useful Links



WizardWrx Logo

MD5Digest
Dynamic Link Library for Computing MD5 Digest Strings

 

Name

MD5Digest

Synopsis

Dynamic link library to generate MD5 digest strings, also called MD5 hashes, for text strings and files.

Author

David A. Gray of P6 Consulting, Fort Worth, Texas, USA.

Copyright

2005, 2007, Simple Soft Services, Inc., d/b/a WizardWrx, North Richland Hills, Texas, USA. All rights reserved world wide.

Revision History

Date

Version

Who

Description

2005/06/08

1, 0, 0, 1

DAG

Replace C runtime functions for standard stream I/O and string functions with native Win32 code. This change allows us to remove headers files stdio.h and string.h and reducing the size of the library from 61 KB to 54 KB.

2005/06/15

1, 0, 0, 3

DAG

Substitute LIBCTINY.LIB for the C run-time library that ships with Microsoft Visual Studio 6.0, This yields a further (substantial) decrease, to 15 KB.

2005/07/13

1, 0, 0, 4

DAG

1.      Change name of library from MD5DLL.DLL to the more descriptive MD5Digest.DLL.

2.      Add preprocessor directives to suppress duplicate definitions caused by duplicate inclusions of corresponding header file MD5Digest.h, similar to the ones used in the include files that ship with the Microsoft  Platform SDK.

2007/03/11

1, 0, 0, 5

DAG

  1. Change the FILE0S resource value from VOS_NT_WINDOWS32 to VOS__WINDOWS32. Although this change affects the entire library, it is noted only in module MD5Digest.c, to avoid disturbing the work of Dr. Rivest in module md5c.c.
  2. Augment code that sets dwLastError with calls to SetLastError, so that the usual Win32 API function for getting result codes from calls into standard Windows DLLs can be used with this library.
  3. Change string argument prototypes from LPSTR to LPCTSTR, to cause the compiler to enforce their intended treatment as immutable values.
  4. Add Visual Basic wrapper functions MD5String_VB and MD5File_VB.
  5. Change CRT from LIBCTINY.LIB to MSVCRT.LIB.
  6. Fix crash caused by incorrect test for failure of the file open in function MD5File.
  7. Review and improve all error trapping in function MD5File.

Additional Documentation

For the sake of simplicity, the majority of the documentation of the Software is embedded as comments within C header file MD5Digest.h.

Except for the next paragraph, most of the foregoing material is addressed to Visual Basic programmers.

Thread Safety. This library was built and tested against a single threaded version of the standard C run-time library, and is not thread safe. Since static buffers are used for file I/O and to hold the MD5 digests, it cannot be made thread safe without making substantial modifications to most, if not all, of its modules. For normal VB projects, this should not be an issue, because, without considerable effort, and calls into the Windows API, VB programs are single threaded applications.

Visual Basic (VB) and Visual Basic for Applications (VBA)

The following supplemental notes are intended for the benefit of Visual Basic programmers.

¨      To use library MD5Digest.dll in your Visual Basic projects, do the following.

¨      Copy MD5Digest.dll into one of the following locations.

¨      Your project directory.

¨       Your Windows System directory, , usually either C:\Windows\System or C:\WinNT\System.

¨       Declare one or both of the VB wrapper functions, MD5String, alias MD5String_VB, and MD5File, alias MD5File_VB, with appropriate scope, in at least one module of your project. You may need to adjust the path in the LIB clause of your Declare statements, depending on where you install the library. Be aware that hard coded paths have no place in your finished program, as the application will fail unless the dynamic link library is in the exact location named in the LIBclause.

¨        Archive TestHarness_VB.zip contains a complete Visual Basic program that demonstrates the use of the two functions that are intended for use with the Microsoft Visual Basic (VB) and Visual Basic for Applications (VBA) programming languages. You should unzip the archive into its own directory, which may be a subdirectory of the directory into which you extract this package.

       File Project1.vbp is the Visual Basic project file. When you open this file in the Visual Basic 6 editor, you can explore the form, frmMain.frm.

       All the code lives behind form frmMain.frm, and the most interesting bits are in the cmdDoTest_Click event procedure.

       Warning! Before you can run the sample application in the IDE, you must do one of two things.

¨       Copy library MD5Digest.dll into your Windows System directory, usually either C:\Windows\System or C:\WinNT\System.

¨       Add the fully qualified name of the directory containing the project, and a trailing backslash, to the LIB clause of the two Declare statements at the top of the class module. For example, if you install the project into directory C:\MD5Digest\TestHarness_VB, change Lib "MD5Digest.dll" to Lib " C:\MD5Digest\TestHarness_VB \MD5Digest.dll" in both Delcare statements.

¨       There are two functions that you can use with your Visual Basic (VB) or Visual Basic for Applications (VBA) programs.

¨       MD5String, alias MD5String_VB takes a Basic string containing text to digest, and returns a Basic string containing its MD5 digest.

¨       MD5File, alias MD5File_VB, takes a Basic string containing the name of a file to digest, and returns a Basic string containing its MD5 digest.

¨       Although the VB example was created using Microsoft Visual Basic, version 6, the library works with any version of Visual Basic that supports Basic Strings, also called OLE Strings. So far as I am aware, this includes Visual Basic 5 and Visual Basic for Applications (VBA) versions 5 and 6, which is included with various versions of Microsoft Office, beginning with Office 97. I have tested similar VB wrapper functions against Microsoft Word 2000, Word XP, and other programs in the Office 2000 and Office XP systems.

¨       All MD5 digest strings are 32 byte strings of hexadecimal characters. This is the standard format in which MD5 digests are reported on bulletin boards. Therefore, the native Basic Len() function always returns a length of 32 for these strings, and they never contain spaces or nulls.

C and C++

The following supplemental notes are for the benefit of C and C++ programmers.

¨       There is a separate pair of standard WINAPI functions that you can use in your C programs, as shown in sample program MD5DLL_TestHarness.c, which is part of archive TestHarness.zip, which should be installed into its own directory, which may be below the directory into which you installed this package. In order to use the library in your C code, do the following.

¨       Copy header file MD5Digest.h into a directory that is in your list of INCLUDE directories.

¨       Copy link library file MD5Digest.lib into a directory that is in your list of LIBPATH directories.

¨       Copy dynamic link library MD5Digest.dll into a directory where your application can find it.

License

This package is licensed under the GNU Lesser General Public License. Consequently, this package contains the entire library, in both source and object form.

Portions of the code, which are included intact, are Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All rights reserved. Those portions contain license terms which appear to be consistent with their incorporation into this package. Your use of those portions of the package, consisting of the following source files, is subject to those terms, which are set forth in the body of source files md5c.c and md5.h.

¨      md5c.c

¨       global.h

¨       md5.h

The remaining source files, all of the object files, and this documentation, are my own work product, and are subject to the terms of the GNU Lesser General Public License.

Warranty

This Software, in both source and object form, is provided to you without any warranty, whatsoever, including, but not limited to, a warranty of merchantability or fitness for a particular use.

Although the Software is supplied to you as is, I have done my best to ensure that it is robust and reliable, that it performs correctly, and is accurately documented.

Support

Although the accompanying software is free, and is supplied without warranty, I shall endeavor to answer technical questions about it, on a best efforts basis. You may contact me by email, using this form, or by telephone, on +1 (817) 812-3041.


Availability

The latest version of this package is aleays available here.

Package Contents

The following table lists the contents of this package.

File Name

Description

Notes

MD5Digest.dll

This is a standard Windows dynamic link library.

1

MD5Digest.h

This is a standard C header file. Since it’s a text file, you can view it using any text editor, such as Windows Notepad.

2

MD5Digest.lib

This is the library file, against which compiled programs, mostly those written in C and C++, must link.

3

MD5Digest_ReadMe.PDF

This is the supplementary documentation.

 

MD5Digest_Source.zip

This is the complete Visual C++ project from which the library was created.

4, 5

MD5LIST.WBT

This is a sample WinBatch script that uses the C interface to the library.

6

TestHarness.zip

This is the C language test harness project and demonstration, and the two test data files.

4, 5

TestHarness_VB.zip

This is the Visual Basic test harness project and demonstration, and the two test data files..

4, 7

Notes

1

This library was built using Microsoft Visual C++, version 6.0, and linked against MSVCRT.LIB. It can be used on any 32 bit version of Microsoft Windows. C run-time functions are expected to be provided by MSVCRT.DLL, which is installed on most versions of Microsoft Windows, and is available for all such versions, back to Windows 95.

All functions use the WINAPI (_stdcall) calling convention, and can be called by any program that can call into the Windows API. This includes, but is not limited to, C, C++, WinBatch, Delphi, and even Perl!

2

In addition to containing most of the documentation for the library, you need this file in order to use this library in your C and C++ code. Copy it into one of your INCLUDE directories.

3

This is the standard link library file, for use with your favorite linkage editor, such as LINK.EXE, which ships with Microsoft Visual Studio. Copy it into one of LIBPATH directories.

4

This archive should be expanded into a new directory. You may create the new directory beneath the directory into which you installed the package of which it is a part.

5

This archive contains a project that was built using Microsoft Visual C++, version 6.0.

6

This is a sample script that I created using WnBatch, version 2005. I used it to test the library against WinBatch, and left it as an example. Although I could easily do so, I have not added a WnBatch Extender interface to this library.

7

This archive contains a project that was built using Microsoft Visual Basic, version 6.0.

Publisher Information

The publisher of this software is Simple Soft Services, Inc., d/b/a WizardWrx.

Address:

5006 Cloyce Court

North Richland Hills, TX  76180-6944

Phone:

+1 (817) 812-3041

Email:

support at wizardwrx.com

WWW:

www.wizardwrx.com


P6C Contact Info

Copyright and Legal Notice