-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
 
sebbo wrote:
> hi!
>
> how can i encrypt binary data using crypto++ and aes? i would like
> to encrypt picture and audio data but all my tries have failed. can
> you help me?
Wei has some really good MFC examples on CodeProject. There is an
example for file encryption using Crypto++ with MFC.

http://www.codeproject.com/KB/cpp/cryptest__mfc_style_.aspx

Alternatively, you can check the wiki. There is an example at the
bottom of the page:

http://www.cryptopp.com/wiki/AES#Encrypting_and_Decrypting_Using_AES

AutoSeededRandomPool rnd;

int keyLength = AES::DEFAULT_KEYLENGTH; // 16 bytes = 128 bit key
int defBlockSize = AES::BLOCKSIZE;

// Generate a random key
byte key[AES::DEFAULT_KEYLENGTH];
rnd.GenerateBlock(key, AES::DEFAULT_KEYLENGTH);

// Generate a random IV
byte iv[AES::BLOCKSIZE];
rnd.GenerateBlock(iv, AES::BLOCKSIZE);

char plainText[] = "Hello! How are you.";
int messageLen = (int)strlen(plainText) + 1;

//////////////////////////////////////////////////////////////////////////
// Encrypt

CFB_Mode<AES>::Encryption cfbEncryption(key, AES::DEFAULT_KEYLENGTH, iv);
cfbEncryption.ProcessData((byte*)plainText, (byte*)plainText, messageLen);

//////////////////////////////////////////////////////////////////////////
// Decrypt

CFB_Mode<AES>::Decryption cfbDecryption(key, AES::DEFAULT_KEYLENGTH, iv);
cfbDecryption.ProcessData((byte*)plainText, (byte*)plainText, messageLen);

Regards,

Dillon Beresford


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
 
iD8DBQFJot5hRnxC5lZRuuERAqGHAKDR4pWhcNTa+7Ry2GObZy321gAgUACgiGUs
ZqZtUi+pCKDzon1KLg9GF+g=
=3Emi
-----END PGP SIGNATURE-----


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the "Crypto++ Users" 
Google Group.
To unsubscribe, send an email to [email protected].
More information about Crypto++ and this group is available at 
http://www.cryptopp.com.
-~----------~----~----~----~------~----~------~--~---

Reply via email to