MD5 Message Digest Unit
|Date:||11 January 2014|
About the Unit
This unit contains an implementation of the MD5 message digest algorithm. A Delphi class named TPJMD5 provides overloaded methods for calculating the MD5 of
- Byte arrays.
- Strings: Unicode, ANSI and short strings are all supported.
- Untyped data buffers (useful for getting the MD5 of ordinal values).
Data types can be mixed and matched. Class methods provide quick shortcuts to taking the MD5 of a single file or single data item without having to create and free a TPJMD5 instance.
There is also an "advanced" record, TPJMD5Digest, that encapsulutes a MD5 digest. Operator overloads for assigning digests to and from strings and bytes arrays are provided. The digest can also be read in long words chunks.
The code was developed from scratch based on the algorithm presented in RFC 1321. Portions of the code are translated from the reference C code supplied in the RFC. However the code is not a literal translation into Pascal from the reference C code.
The algorithm and reference code are copyright © 1991-2, RSA Data Security, Inc. Created 1991. All rights reserved.
As of v1.1 the unit is compatible with both the 32 bit and 64 bit Delphi Windows compilers. It has not been tested with the OSX compiler.
The code can be used in applications using either the VCL or FireMonkey 2 framework.
The component is documented online. This documentation includes a "How-To" Guide containing a wide selection of demo code.
There is no help file.
DUnit tests for the unit are supplied in the download. The tests include all those specified in RFC 1321.
Feedback & Queries
If you find any bugs or want to suggest a new feature please report them using the Issue Tracker.
Click the Create Ticket button to create a ticket then complete the
form giving as much information as possible. Please note:
this issue tracker is shared among all the projects in the DelphiDabbler
Code Library, so please make sure you enter
md5 in the
Project edit box. You should also choose
Defect in the
Type drop down list to report a bug or
request a new feature.
If you have created a bug fix or have implemented a new feature please attach a zip file to your ticket that contains your source code.
Should you have any queries about using the components please read the documentation.
If you can't find an answer in the documentation then post a message in the discussion group.
So why write this code?
Well, I'd been searching for an up-to-date implementation of the MD5 algorithm that meets these criteria:
No dependency on
.objfiles or DLLs. I want pure Pascal code.
- Open source with a license compatible with the Mozilla Public License because I want to use it in an MPLd application of mine, so GPL-only code is ruled out.
- Compiles and works with the Unicode Delphi Compilers.
- Object oriented.
- Easy to get an MD5 digest from all sorts of data without messing about converting it and playing around with contexts etc.
I couldn't find anything that suited, so it seemed easier to start again. After a couple of false starts, this unit is the result.