Can't figure this one out, it is giving me a headache. :)
I basically just have a function that wraps the example code that I
have seen on www.cryptopp.com and else where and returns. The code
works fine, as far as encrypting and decrypting, but as soon as I get
to the return, of the function, I get a 'Unhandled exception' window
breaking in the _CrtIsValidHeapPointer function of windows.
I am using crypto++523, VS2003 and the code is below. Everthing works
if I comment out the stfEncryptor.Put call, I mean I can return from
the function, but as soon as I put stfEncryptor.Put back it poof,
error. Does something have to be done with the 'new' that I see is
being used in StreamTransformationFilter object call?
MyClass::MyTest()
{
// Key and IV setup
//
byte key[ CryptoPP::AES::DEFAULT_KEYLENGTH ],
iv[ CryptoPP::AES::BLOCKSIZE ];
memset( key, 0x00, CryptoPP::AES::DEFAULT_KEYLENGTH );
memset( iv, 0x00, CryptoPP::AES::BLOCKSIZE );
//
// String and Sink setup
//
std::string plaintext = "Now is the time for all good men to come
to the aide...";
std::string ciphertext;
std::string decryptedtext;
//
// Dump Plain Text
//
std::cout << "Plain Text (" << plaintext.size() << " bytes)" <<
std::endl;
std::cout << plaintext;
std::cout << std::endl << std::endl;
//
// Create Cipher Text
//
CryptoPP::AES::Encryption aesEncryption(key,
CryptoPP::AES::DEFAULT_KEYLENGTH);
CryptoPP::CBC_Mode_ExternalCipher::Encryption
cbcEncryption( aesEncryption, iv );
CryptoPP::StreamTransformationFilter stfEncryptor(cbcEncryption,
new CryptoPP::StringSink( ciphertext ) );
stfEncryptor.Put( reinterpret_cast<const unsigned
char*>( plaintext.c_str() ), plaintext.length() + 1 );
stfEncryptor.MessageEnd();
....
}
Thanks
--~--~---------~--~----~------------~-------~--~----~
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.
-~----------~----~----~----~------~----~------~--~---