![]() |
Chilkat HOME Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi DLL Go Java Node.js Objective-C PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(C) Workaround for the deprecated Crypt2.OpaqueSignString methodShows how to replace the deprecated OpaqueSignString method. (Chilkat is moving away from the use of CkByteData.) Note: This example requires Chilkat v11.0.0 or greater.
#include <C_CkCrypt2.h> #include <C_CkCert.h> #include <C_CkByteData.h> #include <C_CkBinData.h> void ChilkatSample(void) { HCkCrypt2 crypt; HCkCert cert; BOOL success; const char *textToSign; HCkByteData outData; const char *base64_sig; HCkBinData bd; 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 OpaqueSignString method is deprecated: outData = CkByteData_Create(); success = CkCrypt2_OpaqueSignString(crypt,textToSign,outData); // ------------------------------------------------------------------------ // Workaround. // (Chilkat is moving away from using CkByteData) CkCrypt2_putEncodingMode(crypt,"base64"); base64_sig = CkCrypt2_opaqueSignStringENC(crypt,textToSign); bd = CkBinData_Create(); CkBinData_AppendEncoded(bd,base64_sig,"base64"); // Access the raw bytes from bd. CkCrypt2_Dispose(crypt); CkCert_Dispose(cert); CkByteData_Dispose(outData); CkBinData_Dispose(bd); } |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.