Visual C++ Examples

ChilkatHOMEAndroid™ASPVisual BasicVB.NETC#iOS (IPhone)Objective-CC++CUnicode C++Unicode CMFCDelphi DLLDelphi ActiveXFoxProJavaPerlPHP ExtensionPHP ActiveXPythonPowerShellRubySQL ServerVBScript

C++ Examples

CkString
Byte Array
Bounced Mail
Bz2
Character Encoding
CSV
DH Key Exchange
DKIM/DomainKeys
Digital Certificates
Digital Signatures
DSA
Email
Email Object
Encryption
FTP
HTML Conversion
HTTP
IMAP
MHT / HTML Email
POP3
RSA
S/MIME
SMTP
Socket
Spider
SSH Key
SSH
SSH Tunnel
SFTP
Tar
Upload
XML
XMP
Zip Compression


More Examples...
Amazon S3
NTLM
FileAccess
RSS
Atom
Self-Extractor
Service
PPMD
Deflate
Bzip2
LZW

 

 

 

 

 

 

 

 

AES Encryption to Match PHP's Mcrypt Extension

Demonstrates how to match AES encryption results with PHP's mcrypt extension.

Please refer to this discussion about PHP AES Encryption. The code here matches the PHP mcrypt results on that page.

Downloads:

MS Windows Visual C/C++ Libraries
Linux/CentOS C/C++ Libraries
MAC OS X C/C++ Libraries
Solaris C/C++ Libraries
C++ Builder Libraries
FreeBSD C++ Libraries
HP-UX C++ Libraries
BlackBerry QNX C++ Libraries
#include <CkCrypt2.h>

void ChilkatSample(void)
    {
    CkCrypt2 crypt;

    bool success;
    success = crypt.UnlockComponent("Anything for 30-day trial");
    if (success != true) {
        printf("Crypt component unlock failed\n");
        return;
    }

    //  AES is also known as Rijndael.
    crypt.put_CryptAlgorithm("aes");

    //  CipherMode may be "ecb" or "cbc"
    crypt.put_CipherMode("cbc");

    //  KeyLength may be 128, 192, 256
    crypt.put_KeyLength(256);

    //  Pad with NULL bytes (PHP pads with NULL bytes)
    crypt.put_PaddingScheme(3);

    //  EncodingMode specifies the encoding of the output for
    //  encryption, and the input for decryption.
    //  It may be "hex", "url", "base64", or "quoted-printable".
    crypt.put_EncodingMode("hex");

    const char * ivAscii;
    ivAscii = "1234567890123456";
    crypt.SetEncodedIV(ivAscii,"ascii");

    //  The secret key must equal the size of the key.  For
    //  256-bit encryption, the binary secret key is 32 bytes.
    //  For 128-bit encryption, the binary secret key is 16 bytes.
    const char * keyAscii;
    keyAscii = "12345678901234561234567890123456";
    crypt.SetEncodedKey(keyAscii,"ascii");

    const char * plainText;
    plainText = "The quick brown fox jumped over the lazy dog";

    const char * cipherText;
    cipherText = crypt.encryptStringENC(plainText);
    printf("%s\n",cipherText);

    //  Do 128-bit AES encryption:
    crypt.put_KeyLength(128);
    keyAscii = "1234567890123456";
    crypt.SetEncodedKey(keyAscii,"ascii");

    cipherText = crypt.encryptStringENC(plainText);
    printf("%s\n",cipherText);

    //  -------
    //  Results
    //  -------
    //  You may use these as test vectors for testing your AES implementations...
    // 
    //  ------------------------
    //  256-bit key, CBC mode
    //  ------------------------
    //  IV = '1234567890123456' 
    //   (hex: 31323334353637383930313233343536)
    //  Key = '12345678901234561234567890123456' 
    //   (hex: 3132333435363738393031323334353631323334353637383930313233343536)
    //  PlainText:
    //   'The quick brown fox jumped over the lazy dog'
	// CipherText(hex):
    //   2fddc3abec692e1572d9b7d629172a05caf230bc7c8fd2d26ccfd65f9c54526984f7cb1c4326ef058cd7bee3967299e3

    // 
    //  ------------------------
    //  128-bit key, CBC mode
    //  ------------------------
    //  IV = '1234567890123456' 
    //   (hex: 31323334353637383930313233343536)
    //  Key = '1234567890123456' 
    //   (hex: 31323334353637383930313233343536)
    //  PlainText:
    //   'The quick brown fox jumped over the lazy dog'
	// CipherText(hex):
    //   f78176ae8dfe84578529208d30f446bbb29a64dc388b5c0b63140a4f316b3f341fe7d3b1a3cc5113c81ef8dd714a1c99

    }

© 2000-2013 Chilkat Software, Inc. All Rights Reserved.