Sample code for 30+ languages & platforms
C++

Workaround for the deprecated Crypt2.OpaqueSignBytes method

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

Chilkat C++ Downloads

C++
#include <CkCrypt2.h>
#include <CkCert.h>
#include <CkByteData.h>
#include <CkBinData.h>

void ChilkatSample(void)
    {
    bool success = false;

    CkCrypt2 crypt;

    CkCert cert;
    //  ...
    //  Load the cert from a source such as a .pfx/.p12 file, smart card, USB token, Apple keychain, Windows certificate store, etc.
    //  
    success = crypt.SetSigningCert(cert);

    //  ...
    //  ...
    //  ...

    const char *path = "c:/someDir/example.dat";

    //  ------------------------------------------------------------------------
    //  The OpaqueSignBytes method is deprecated:

    CkByteData inData;
    inData.loadFile(path);

    CkByteData outData;

    success = crypt.OpaqueSignBytes(inData,outData);

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

    CkBinData bd;
    bd.LoadFile(path);

    //  If successful, the contents of bd are replaced with the PKCS#7 signed-data.
    success = crypt.OpaqueSignBd(bd);
    }