Hi w,

I suspect it has to with your usage of the library. Try the following.

Jeff

#include <iostream>
#include <string>

using std::string;
using std::cout;
using std::endl;

#include "default.h"
#include "filters.h"

using CryptoPP::DefaultEncryptorWithMAC;
using CryptoPP::DefaultDecryptorWithMAC;
using CryptoPP::StringSink;
using CryptoPP::StringSource;

int main(int argc, char* argv[])
{
    string message = "secret message";
    string password = "password";
    string encrypted, recovered;

    StringSource(
        message,
        true,
        new DefaultEncryptorWithMAC(
            password.c_str(),
            new StringSink( encrypted )
        ) // DefaultEncryptorWithMAC
    ); // StringSource

    StringSource(
        encrypted,
        true,
        new DefaultDecryptorWithMAC(
            password.c_str(),
            new StringSink( recovered )
        ) // DefaultDecryptorWithMAC
    ); // StringSource

    cout << "Recovered Text:" << endl;
    cout << "  " << recovered << endl;

    return 0;
}

On 2/22/08, whatazor <[EMAIL PROTECTED]> wrote:
>
> Hi All,
> I use crypto 5.4 and I notice a strange problem using an automated
> test for testing a wrapping class of StringSource I have. This
> wrapping class only call StringSource, but the problems is that
> sometimes (not regularly) StringSource throw an exception even if this
> automated test use always the same string to crypt and then decrypt,
> and the same passphrase
>
> try
>  {
>    StringSink *ssink = new StringSink(out);
>    DefaultEncryptorWithMAC  * mac =    new
> DefaultEncryptorWithMAC(passPhrase, ssink);
>
>    StringSource s((const byte *)in, len, true, mac);
>  }
>  catch (...)
>  {
>    result = false;
>  }
>
> where is the problem?
>
> thx you very much
> w

--~--~---------~--~----~------------~-------~--~----~
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