Delphi DLL Requires Chilkat v11.0.0+
Delphi DLL
Workaround for the deprecated Crypt2.SignString method
Shows how to replace the deprecated SignString method. (Chilkat is moving away from the use of CkByteData.)Chilkat Delphi DLL Downloads
var
success: Boolean;
crypt: HCkCrypt2;
cert: HCkCert;
textToSign: PWideChar;
outData: HCkByteData;
base64_sig: PWideChar;
bdSig: HCkBinData;
begin
success := False;
crypt := CkCrypt2_Create();
cert := CkCert_Create();
// ...
// Load the cert from a source such as a .pfx/.p12 file, smart card, USB token, Apple keychain, Windows certificate store, etc.
//
success := CkCrypt2_SetSigningCert(crypt,cert);
// Sign the utf-8 byte representation of the text.
CkCrypt2_putCharset(crypt,'utf-8');
textToSign := 'This is the text to sign';
// ------------------------------------------------------------------------
// The SignString method is deprecated:
outData := CkByteData_Create();
success := CkCrypt2_SignString(crypt,textToSign,outData);
// ------------------------------------------------------------------------
// Workaround.
// (Chilkat is moving away from using CkByteData)
CkCrypt2_putEncodingMode(crypt,'base64');
base64_sig := CkCrypt2__signStringENC(crypt,textToSign);
// If you want the binary bytes of the signature decoded from base64.
bdSig := CkBinData_Create();
CkBinData_AppendEncoded(bdSig,base64_sig,'base64');
CkCrypt2_Dispose(crypt);
CkCert_Dispose(cert);
CkByteData_Dispose(outData);
CkBinData_Dispose(bdSig);