views:

180

answers:

6

I need to programatically encrypt a directory of files, like in a .zip or whatever. Preferably password protected obviously.

How can I accomplish this, and WHAT IS the BEST encryption way to do it, if applicable?

Programming language doesn't matter. I am dictioned in all syntax.

+1  A: 

I still say 7-zip is the answer. It hasn't been "cracked".

Dean Harding
Now he is asking for a programatic way. Is there a 7zip api available?
jjnguy
There is an SDK for 7-zip (http://7-zip.org/sdk.html), but I don't know if it includes encryption support out-of-the box. It wouldn't be hard to just zip the files and then run your own encryption on them, of course.
Dean Harding
API or not, there is a command line interface.
Vulcan Eager
+1  A: 

The OpenSSL library has a variety of block cipher implementations including the well-known AES. It has both a function-call interface (for use with languages like C/C++) and a program-call interface (for use in shell scripts). http://www.openssl.org/

Will
+1  A: 

Use AES. You'll find implementations in your favourite programming language by asking google for AES encryption + myfavouritelanguage.

ChristopheD
+3  A: 

How can I accomplish this, and WHAT IS the BEST encryption way to do it, if applicable?

  • tar and gzip the directory.
  • Generate a random bit stream of equal size to the file
  • Run bitwise XOR on the streams

Only truly secure method is a truly random one time pad.

Mimisbrunnr
The best way to encrypt data is to place the hard drive into a hydraulic press (as long as decryption is not a requirement).
Will
Before I recommend XOR ... I generally express a preference for double-ROT-13 (twice as secure, convenient, and fast, as the original ROT-13)!
Jim Dennis
If you are going to go for double rot you might as well go for triple rot 13 for even more security.
Mimisbrunnr
+2  A: 

4096-Bit (Open)PGP: 'Pretty Good' Privacy !

GnuPG is the GNU project's complete and free implementation of the OpenPGP standard as defined by RFC4880 . GnuPG allows to encrypt and sign your data and communication, features a versatile key managment system as well as access modules for all kind of public key directories. GnuPG, also known as GPG, is a command line tool with features for easy integration with other applications. A wealth of frontend applications and libraries are available. Version 2 of GnuPG also provides support for S/MIME.


libgcrypt:
http://www.gnupg.org/related_software/libraries.en.html

Edit:
BouncyCastle now has OpenPGP support.
http://www.bouncycastle.org/

Quandary
A: 

If you're using .NET, why not use a free compression framework (http://www.icsharpcode.net/OpenSource/SharpZipLib/) that supports Encryption?

Ian