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

 

 

 

 

 

 

 

 

TwoFish ECB Encryption Matching Counterpane Test Vectors

Demonstrates Twofish 128-bit ECB encryption that matches the test vectors published by Counterpane Systems.

/*

  
=========================

FILENAME:  "ecb_vk.txt"

Electronic Codebook (ECB) Mode
Variable Key Known Answer Tests

Algorithm Name:       TWOFISH
Principal Submitter:  Bruce Schneier, Counterpane Systems

==========

KEYSIZE=128

PT=00000000000000000000000000000000
   11223344556677881122334455667788
I=1
KEY=80000000000000000000000000000000
CT=6BFD32804A1C3206C4BF85EB11241F89

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

    crypt2.put_CryptAlgorithm("twofish");
    crypt2.put_CipherMode("ecb");
    crypt2.put_KeyLength(128);
    crypt2.put_EncodingMode("hex");

    unsigned char key[16];
    unsigned char plainText[16];
    int i;
    for (i=0; i<16; i++)
	{
	plainText[i] = '\0';
	key[i] = '\0';
	}
    key[0] = 0x80;

    CkByteData keyData;
    keyData.append(key,16);
    crypt2.put_SecretKey(keyData);

    CkByteData unencryptedData;
    unencryptedData.append(plainText,16);
    CkString encryptOut;
    crypt2.EncryptBytesENC(unencryptedData,encryptOut);

    // The Chilkat component pads to a multiple of 16 bytes.
    // The default padding scheme is to pad with a byte value
    // equaling the number of padding bytes.  If the input
    // is an exact multiple of 16 bytes, as in this case,
    // an extra 16 bytes of padding (padding byte = 0x10) is 
    // added.  
    // We must drop the 16 bytes of padding to match the 
    // test vector output.  Each byte is represented in hex
    // as two characters, so we shorten the hexidecimal output
    // string by 32 characters.
    encryptOut.shorten(32);

    // The output of this program matches the twofish test vector exactly...

    printf("%s\n",encryptOut.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