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

 

 

 

 

 

 

 

 

Blowfish Encrypt a string returning an encrypted string.

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

This sample program demonstrates how to encrypt a string using 128-bit Blowfish encryption.

// The Chilkat Encryption library is also available as an ActiveX component
// or .NET class with the identical set of methods and properties.

// Blowfish Encrypt a string returning an encrypted string.
void CryptExample(void)
    {
    CkCrypt2 crypt;
    
    // Any string passed to UnlockComponent automatically begins the 30-day trial.
    crypt.UnlockComponent("30-day trial");

    // Use Blowfish encryption.
    crypt.put_CryptAlgorithm("blowfish2");
    
    // Use 128-bit Blowfish encryption.
    crypt.put_KeyLength(128);

    // Create a binary secret key from a password string.
    CkByteData secretKey;
    crypt.GenerateSecretKey("myPassword",secretKey);
    crypt.put_SecretKey(secretKey);

    // Note: we could just as well set the binary secret key directly.
    // We need a binary key of 16 bytes (16 bytes * 8 bits/byte = 128 bits)
    // Example:
    // int i;
    // unsigned char sKey[16];
    // for (i=0; i<16; i++) sKey[i] = i;
    // secretKey.append(sKey,16);

    // Tell the component what string-encoding to use for the encrypted output.
    // Encrypted data is binary, and will not be a printable string.  If you want
    // a printable string, it must be encoded using Base64, Hex, Quoted-Printable, etc.
    crypt.put_EncodingMode("hex");

    // Encrypt a string:
    // Note: Hex encoding increases the output length by
    // 2 times (2 characters per byte).
    CkString strEncrypted;
    crypt.EncryptStringENC("This is a test",strEncrypted);
    printf("strEncrypted = [%s]\n",strEncrypted.getString());

    // Now decrypt it:
    CkString strDecrypted;
    crypt.DecryptStringENC(strEncrypted.getString(),strDecrypted);
    printf("strDecrypted = [%s]\n",strDecrypted.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