Delphi DLL
Delphi DLL
Workaround for the deprecated Crypt2.HashFile method
Shows how to replace the deprecated HashFile method. (Chilkat is moving away from the use of CkByteData.)Chilkat Delphi DLL Downloads
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, CkByteData, Crypt2;
...
procedure TForm1.Button1Click(Sender: TObject);
var
crypt: HCkCrypt2;
path: PWideChar;
outData: HCkByteData;
hex_hash: PWideChar;
begin
crypt := CkCrypt2_Create();
CkCrypt2_putHashAlgorithm(crypt,'sha256');
path := 'c:/someDir/example.dat';
// ------------------------------------------------------------------------
// The HashFile method is deprecated:
outData := CkByteData_Create();
success := CkCrypt2_HashFile(crypt,path,outData);
// ------------------------------------------------------------------------
// Workaround.
// (Chilkat is moving away from using CkByteData)
CkCrypt2_putEncodingMode(crypt,'hex_lower');
hex_hash := CkCrypt2__hashFileENC(crypt,path);
CkCrypt2_Dispose(crypt);
CkByteData_Dispose(outData);
end;