Visual C++ Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript

Visual C++ Examples

CkString
Byte Array
Bounced Mail
Character Encoding
Digital Certificates
Digital Signatures
Email
Encryption
FTP
HTML-to-XML
HTTP
IMAP
MHT / HTML Email
RSA Encryption
S/MIME
Socket
Spider
Tar
Upload
XML
XMP
Zip Compression


More Examples...
Email Object
POP3
SMTP
RSS
Atom
Self-Extractor

Unreleased...
Service
PPMD
Deflate
Bzip2
LZW
Bz2
DH Key Exchange
DSA
Icon

 

 

 

 

 

 

 

 

C++ Blowfish CBC Encryption Matching Published Test Vectors

Download Chilkat C/C++ Libraries for VC++ 9.0 / Win32

Download Chilkat C/C++ Libraries for VC++ 8.0 / Win32

Download Chilkat C/C++ 64-bit Libraries for VC++ 8.0 / x64

Download Chilkat Visual Studio 2005 C/C++ Libs for Windows Mobile, Pocket PC, SmartPhone, WinCE

Download Chilkat C/C++ Libraries for VC++ 7.0 / Win32

Download Chilkat C/C++ Libraries for VC++ 6.0 / Win32

Download Chilkat C/C++ Libraries for VC++ 6.0, Win 95/98/NT4 Compatible

C++ example program for Blowfish in CBC mode.

/*
chaining mode test data
key[16]   = 0123456789ABCDEFF0E1D2C3B4A59687
iv[8]     = FEDCBA9876543210
data[29]  = "7654321 Now is the time for " (includes trailing '\0')
data[29]  = 
37363534333231204E6F77206973207468652074696D6520666F722000
cipher[32]= 
6B77B4D63006DEE605B156E27403979358DEB9E7154616D959F1652BD5FF92CC

  */
void BlowfishCBC(void)
    {
    CkCrypt2 crypt;
    crypt.UnlockComponent("anything for 30-day trial");

    const char *key = "0123456789ABCDEFF0E1D2C3B4A59687";
    const char *iv = "FEDCBA9876543210";

    const char *data = "37363534333231204E6F77206973207468652074696D6520666F722000";

    crypt.SetEncodedIV(iv,"hex");
    crypt.SetEncodedKey(key,"hex");

    // Decode the clear-text from a hex string to binary data.
    crypt.put_CryptAlgorithm("none");
    crypt.put_EncodingMode("hex");
    CkByteData dataBytes;
    crypt.DecryptBytesENC(data,dataBytes);

    // Set the encryption algorithm and key length.
    crypt.put_CryptAlgorithm("blowfish2");
    crypt.put_KeyLength(128);
    
    // Padding Schemes:
    // 0((RFC2630) Each padding byte is the pad count (16 extra added if size is already a multiple of 16)
    // 1(Random bytes except the last is the pad count (16 extra added if size is already multiple of 16)
    // 2(Pad with random data. (If already a multiple of 16, no padding is added).
    // 3(Pad with NULLs. (If already a multiple of 16, no padding is added).
    // 4(Pad with SPACE chars(0x20). (If already a multiple of 16, no padding is added).
	
    // To match the test vector output, we need to pad with NULL bytes.
    crypt.put_PaddingScheme(3);

    // Encrypt dataBytes, returning the encrypted data as a hex string.
    CkString strEncrypted;
    crypt.EncryptBytesENC(dataBytes,strEncrypted);

    // Should print: 6B77B4D63006DEE605B156E27403979358DEB9E7154616D959F1652BD5FF92CC
    printf("%s\n",strEncrypted.getString());

    }

 

 

 

Need a specific example? Send a request to support@chilkatsoft.com

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

Mail Component · .NET Mail Component · XML Parser