Sample code for 30+ languages & platforms
Delphi DLL Requires Chilkat v11.0.0+

Workaround for the deprecated Crypt2.HashBytesENC method

Shows how to replace the deprecated HashBytesENC method. (Chilkat is moving away from the use of CkByteData.)

Chilkat Delphi DLL Downloads

Delphi DLL
var
crypt: HCkCrypt2;
path: PWideChar;
inData: HCkByteData;
base64_hash: PWideChar;
bdIn: HCkBinData;

begin
crypt := CkCrypt2_Create();

CkCrypt2_putHashAlgorithm(crypt,'sha256');
CkCrypt2_putEncodingMode(crypt,'base64');

path := 'c:/someDir/example.dat';

//  ------------------------------------------------------------------------
//  The HashBytes method is deprecated:

inData := CkByteData_Create();
CkByteData_loadFile(inData,path);

base64_hash := CkCrypt2__hashBytesENC(crypt,inData);

//  ------------------------------------------------------------------------
//  Workaround.
//  (Chilkat is moving away from using CkByteData)

bdIn := CkBinData_Create();
CkBinData_LoadFile(bdIn,path);

base64_hash := CkCrypt2__hashBdENC(crypt,bdIn);

CkCrypt2_Dispose(crypt);
CkByteData_Dispose(inData);
CkBinData_Dispose(bdIn);