Welcome to the new DelphiDabbler Code Library Documentation.

This is a new site that's currently running on alpha code. There are going to be bugs. If you discover any, please report them on the site's issues page (GitHub account required). Thanks.

Warning: Many URLs are going to change. Refer to the README file to discover which library project's documentation has been completed.

TPJMD5 class

Project: MD5 Message Digest Unit

Unit: PJMD5

Applies to: ~>1.0

Description

This class implements the MD5 message digest algorithm. It produces a message digest (i.e. a 16 byte hash) from a sequence of octets (bytes).

TPJMD5 has been designed to make it easy to create MD5 hashes of different types of data. It does this by providing overloaded Process and Calculate methods that can each accept several different data types.

The MD5 hash is exposed as a record of type TPJMD5Digest that contains the hash in binary form. The record overloads various operators to make it easy to obtain a string representation of the hash and to access the hash itself either byte by byte or as a sequence of long words.

Methods

Method Description
Create Object constructor.
Calculate There are numerous overloaded versions of Calculate for several different data types. These are class methods that create an MD5 hash directly from data passed to them. Each method returns the resulting hash as a TPJMD5Digest record.
CalculateFile This class method is similar to the Calculate methods except that it calculates and returns the MD5 hash of the contents of a file.
Process Each of the numerous overloaded Process methods adds the data passed to it to the current MD5 hash. The method enable data to be added to the hash in chunks rather than all at once as is the case with v. The methods also enable data of different types to be combined in the same hash.
ProcessFile This method is similar to the Process method except that it adds the contents of a file to the current MD5 hash.
Reset Resets the object and discards the current digest ready to calculate a new hash.
Finalize Finalizes the current MD5 hash. Any attempt to add more data to the hash after calling this method raises an exception.

Properties

Property Description
Digest Read only property that finalizes and provides access to the MD5 hash as a TPJMD5Digest record.
ReadBufferSize Gets and sets the size of buffer used when reading data from files and streams.
Finalized Read only property that indicates if the MD5 hash has been finalized.

Events

TPJMD5 exposes no events.

Class Constants

Constant Description
DefReadBufferSize Default buffer size used when reading streams and files.