Sample code for 30+ languages & platforms
Unicode C++

Example: Crypt2.DecryptStringENC method

Demonstrates how to call the DecryptStringENC method.

Chilkat Unicode C++ Downloads

Unicode C++
#include <CkCrypt2W.h>

void ChilkatSample(void)
    {
    //  This example requires the Chilkat API to have been previously unlocked.
    //  See Global Unlock Sample for sample code.

    CkCrypt2W crypt;

    crypt.put_CryptAlgorithm(L"aes");
    crypt.put_CipherMode(L"cbc");
    crypt.put_KeyLength(128);
    crypt.SetEncodedKey(L"000102030405060708090A0B0C0D0E0F",L"hex");
    crypt.SetEncodedIV(L"000102030405060708090A0B0C0D0E0F",L"hex");
    crypt.put_EncodingMode(L"base64");

    //  Return the base64 encoded encrypted bytes
    const wchar_t *encodedEncrypted = crypt.encryptStringENC(L"Hello World!");
    wprintf(L"Encrypted: %s\n",encodedEncrypted);

    //  Output:
    //  Encrypted: qiq+IFhcjTkEIkZyf31V/g==

    //  Decrypt
    const wchar_t *originalText = crypt.decryptStringENC(encodedEncrypted);

    wprintf(L"Decrypted: %s\n",originalText);

    //  Output:
    //  Decrypted: Hello World!
    }