On Sat, Jul 13, 2013 at 9:53 PM, Stefano Mtangoo <[email protected]>wrote:

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

Sorry about that the test should work on ubuntu fine but you would need the
superproject installed (see
https://github.com/maidsafe/MaidSafe/wiki/Build-Instructions) and that may
be too much hassle. We use boost::filesystem to read / write files as it's
just a little more cross platform. If you start with a string encrypt
decrypt then add reading from file instead of stream you will find it
easier. In cryptopp use filestream instead of stringstream if you want to
stick to that lib for file operations.

Now perhaps even better for you is to look in test.cpp which is shipped
with cryptopp and at near line 500 you will find what your looking for
exactly I think.

Make sure to read up on the various modes and be careful of ECB etc. they
are not as secure as you think. There is no choice but to do a lot of
research when messing with these algorithms, every system is designed to be
secure only in very particular situations, so a strong algorithm in the
wrong place is very weak.

Anyway I hope this helps.

(here is line 500 of test.cpp just in case)

void AES_CTR_Encrypt(const char *hexKey, const char *hexIV, const char
*infile, const char *outfile)
{
SecByteBlock key = HexDecodeString(hexKey);
SecByteBlock iv = HexDecodeString(hexIV);
CTR_Mode<AES>::Encryption aes(key, key.size(), iv);
FileSource(infile, true, new StreamTransformationFilter(aes, new
FileSink(outfile)));
}

Best Regards
David Irvine

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