Hi Jeff,

On Thursday, July 18, 2013 10:37:07 PM UTC+3, Jeffrey Walton wrote:
>
>
>
> On Friday, July 12, 2013 5:14:29 PM UTC-4, Stefano Mtangoo wrote:
>>
>> ... 
>
> Code:
>>
>> wxString DecryptString(const wxString& instr, const wxString& passPhrase)
>> {
>>     std::string outstr;
>>     const char* charToDecrypt = instr.ToStdString().c_str();
>>     const char* pass = passPhrase.ToStdString().c_str();
>>
>>     try
>>     {
>>         CryptoPP::HexDecoder decryptor(new 
>> CryptoPP::DefaultDecryptorWithMAC(pass, new CryptoPP::StringSink(outstr)));
>>         decryptor.Put((byte *)charToDecrypt, strlen(charToDecrypt));
>>         decryptor.MessageEnd();
>>     }
>>     catch (CryptoPP::Exception& e)
>>     {
>>         wxPuts(e.what());
>>     }
>>
>>     return wxString(outstr);
>> }
>>
>
>     const char* charToDecrypt = instr.ToStdString().c_str();
>     const char* pass = passPhrase.ToStdString().c_str();
>
> With all things being equal, there's likely an embedded NULL in the 
> charToDecrypt c-string. Don't convert it to a c-style string.
>
> I've never worked with WX, but the following would probably be a step in 
> the right direction:
>
>     const std:string& encrypted = instr.ToStdString();
>     const std:string& pass = passPhrase.ToStdString();
>
> And then, perhaps something like:
>
>     // 
> http://www.cryptopp.com/docs/ref/class_default_decryptor_with_m_a_c.html
>     CryptoPP::DefaultDecryptorWithMAC decryptor(pass.data(), pass.size(), 
> new CryptoPP::StringSink(outstr)));
>     decryptor.Put((byte *)encrypted.data(), encrypted.size());
>     decryptor.MessageEnd();
>
> Or:
>
>     StringSource ss(
>         encrypted, true,
>         new DefaultDecryptorWithMAC decryptor(
>             pass.data(), pass.size(),
>             new CryptoPP::StringSink(outstr)
>         )
>     );
>
>
I have tried both solutions does not work. I have tried all I could with no 
avail. Can you try to decrypt this string below and see if it works? I want 
to confirm its not something funny with the encryption nor password!

String: 
C53ED32B2F20C2C19786F507671D9BA6AE80298C1C6C04583037498F4A910A3255FD02E53664118AEA315A577A80FCEF
Password: password 

I have just encrypted with:


CryptoPP::StringSource ss(
        charToEncrypt, true,
        new CryptoPP::DefaultEncryptorWithMAC(
            (byte*)pass.data(), pass.size(),
            new CryptoPP::HexEncoder(
                new CryptoPP::StringSink(outstr)
            )
        )
    );


Jeff
>
>

-- 
-- 
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.
--- 
You received this message because you are subscribed to the Google Groups 
"Crypto++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to