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

Workaround for the deprecated Crypt2.HashString method

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

Chilkat Delphi DLL Downloads

Delphi DLL
var
crypt: HCkCrypt2;
inputStr: PWideChar;
outData: HCkByteData;
hash_base64: PWideChar;

begin
crypt := CkCrypt2_Create();

CkCrypt2_putCharset(crypt,'utf-8');

CkCrypt2_putHashAlgorithm(crypt,'sha256');

inputStr := 'This is a test.';

//  ------------------------------------------------------------------------
//  The HashString method is deprecated:

outData := CkByteData_Create();

success := CkCrypt2_HashString(crypt,inputStr,outData);

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

CkCrypt2_putEncodingMode(crypt,'base64');
hash_base64 := CkCrypt2__hashStringENC(crypt,inputStr);

Memo1.Lines.Add(hash_base64);

CkCrypt2_Dispose(crypt);
CkByteData_Dispose(outData);