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.

Finalize method

Project: MD5 Message Digest Unit

Unit: PJMD5

Class: TPJMD5

Applies to: ~>1.0

procedure Finalize;

Description

Finalizes the current MD5 hash and sets the Finalized property to True.

Any attempt to add more data to the hash after calling this method raises an EPJMD5 exception.

Finalize is called internally when the Digest property is read. This means that there is rarely any need to call Finalize explicitly.

Calling this method more than once has no effect - the digest is finalized only once. This ensures that calling Finalize before reading Digest, or reading Digest more than once, is safe.

Example

var
  MD5: TPJMD5;
begin
  MD5 := TPJMD5.Create;
  try
    MD5.Process('Foo', TEncoding.ASCII);
    ShowMessage(BoolToStr(MD5.Finalized, True)); // will display "False"
    MD5.Finalize;
    // Further calls to MD5.Process will raise exception now
    ShowMessage(BoolToStr(MD5.Finalized, True)); // will display "True"
    ShowMessage(MD5.Digest);  // Digest implicitly cast to string
  finally
    MD5.Free;
  end;
end;