Hi,
I wanted to Encrypt my file so I checked the Test and the decrypt functions there does not work or at least I cannot get them work.
First I tried the EncryptFile and it works fine but decryptfile fails. And then I tried encryptString and works fine but the counterpart does not!
They all fail with error: "DefaultDecryptor: cannot decrypt message with this passphrase"
I use the same passphrase (#define PASS "SomePassword"
I'm stucked!
I am rushing about just now, but there are some good examples here https://github.com/maidsafe/MaidSafe-Common/blob/master/src/maidsafe/common/crypto.cc
the code is great but its a bit complex for a newbie like me. I need just a simple encrypt/decrypt function. That is I can encrypt a file and then be able to read the contents(decrypt it). The test seems so much simple but its not working. I don't know why
I use Ubuntu!
...
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);
}
Jeff
...
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
Jeff
Jeff
On Monday, July 22, 2013 12:11:33 PM UTC+3, Stefano Mtangoo wrote:
On Monday, July 22, 2013 9:47:59 AM UTC+3, Jeffrey Walton wrote:
I have tried both solutions does not work. I have tried all I could with no avail.
Don't know why but this works
CryptoPP::HexDecoder decryptor(new CryptoPP::DefaultDecryptorWithMAC(passPhrase.ToStdString().c_str(), new CryptoPP::StringSink(outstr)));
decryptor.Put((byte *)instr.ToStdString().data(), instr.ToStdString().size());
decryptor.MessageEnd();
--
Jeff
--
You received this message because you are subscribed to the "Crypto++ Users" Google Group.
To unsubscribe, send an email to cryptopp-user...@googlegroups.com.
More information about Crypto++ and this group is available at http://www.cryptopp.com.
---
You received this message because you are subscribed to a topic in the Google Groups "Crypto++ Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cryptopp-users/16U0M2B_V7Y/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cryptopp-user...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.