Skip to content

Latest commit

 

History

History
46 lines (31 loc) · 1.38 KB

TPJMD5-Digest.md

File metadata and controls

46 lines (31 loc) · 1.38 KB

Digest property

Project: MD5 Message Digest Unit

Unit: PJMD5

Class: TPJMD5

Applies to: ~>1.0

property Digest: TPJMD5Digest;

Description

This read only property provides access to the current MD5 hash as a TPJMD5Digest record.

Once you have finished adding data to a hash with the Process and ProcessFile methods you should read Digest to get the required MD5 digest of the data.

Reading this property finalizes the hash so that no more data can be added to it. Digest calls Finalize internally and sets the Finalized property to True.

Note

The value of Digest can be assigned to another TPJMD5Digest record or to a Unicode string or TBytes array. This is because TPJMD5Digest overloads the Implicit operator for the string and TBytes types.

Example

Here's how to display the combined MD5 hash of two files:

var
  MD5: TPJMD5;
begin
  MD5 := TPJMD5.Create;
  try
    MD5.ProcessFile('MyFile1.txt');
    MD5.ProcessFile('MyFile2.txt');
    ShowMessage(MD5.Digest);
  finally
    MD5.Free;
  end;
end;

The ShowMessage call relies on the fact that Digest can be implicitly cast to a string.