Sample code for 30+ languages & platforms
C++

Example: Crypt2.EncryptSb method

Demonstrates how to call the EncryptSb method.

Chilkat C++ Downloads

C++
#include <CkCrypt2.h>
#include <CkBinData.h>
#include <CkStringBuilder.h>

void ChilkatSample(void)
    {
    bool success = false;

    CkCrypt2 crypt;

    CkBinData bdEncrypted;
    CkStringBuilder sbPlainText;

    sbPlainText.Append("Text to be encrypted");

    //  ...
    //  Set the secret key ...
    //  Set properties such as CryptAlgorithm, CipherMode, PaddingScheme, KeyLength
    //  Set the IV if needed ...
    //  ...

    crypt.put_Charset("utf-8");

    success = crypt.EncryptSb(sbPlainText,bdEncrypted);
    if (success == false) {
        std::cout << crypt.lastErrorText() << "\r\n";
        return;
    }
    }