Visual C++ Examples

ChilkatHOMEAndroid™ASPVisual BasicVB.NETC#iOS (IPhone)Objective-CC++CMFCDelphiFoxProJavaPerl
PHP 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

 

 

 

 

 

 

 

 

TwoFish ECB Encryption Matching Counterpane Test Vectors

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

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());
    }

 

 

 

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

Mail Component · .NET Mail Component · XML Parser