(Unicode C++) Example: Crypt2.EncryptEncoded method
Demonstrates how to call the EncryptEncoded method.
#include <CkCrypt2W.h>
void ChilkatSample(void)
{
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");
// Encrypt the bytes 0x00, 0x01, 0x02, ... 0x0A
// and return the encrypted bytes using the lowercase hex encoding.
crypt.put_EncodingMode(L"hex_lower");
const wchar_t *encrypted = crypt.encryptEncoded(L"000102030405060708090a");
wprintf(L"%s\n",encrypted);
// Output:
// 9da2ae71a5378487114b430e5e230378
const wchar_t *decrypted = crypt.decryptEncoded(encrypted);
wprintf(L"%s\n",decrypted);
// Output:
// 000102030405060708090a
}
|