Reset method

Project: MD5 Message Digest Unit

Unit: PJMD5

Class: TPJMD5

Applies to: ~>1.0

procedure Reset;

Description

Resets the TPJMD5 object and discards the current digest ready to calculate a new hash. Calling this method sets the object to its newly created state.

The method sets the Finalized property to False.

Once the Digest property has been read or the Finalize method has been called Reset must be called to create a new hash before calling Process or ProcessFile.

Example

Suppose you need two get two MD5 hashes using the same TPJMD5 instance. The following code will do it:

var
  MD5: TPJMD5;
begin
  MD5 := TPJMD5.Create;
  try
    MD5.Process('Foo', TEncoding.ASCII);
    ShowMessage(MD5.Digest);  // implicitly casts Digest to string
    MD5.Reset;
    MD5.Process('Bar', TEncoding.ASCII);
    ShowMessage(MD5.Digest);  // implicitly casts Digest to string
  finally
    MD5.Free;
  end;
end;