Reputation: 31
Is it possible to encrypt entire folders with Java's JCE library. The folders will contain other folders/files if that is a problem. For those who don't know what JCE is, it stands for Java Cryptography Extension and it is used for encryption in Java.
Upvotes: 3
Views: 3119
Reputation: 11933
No. You can't encrypt entire folders with only Java's JCE library. It's not hard to zip it first though using a stream wrapper like ZipInputStream
and ZipOutputStream
. Since you don't care about file size reduction, you could also use jtar
. That will make it easy to tar up the folder after which it can be encrypted with JCE like any other file.
I would make a class called something like public class FolderEncrypter
with methods public byte[] encryptFolder(File folder)
and public File decryptFolder(public byte[])
. Then it is easy to reuse throughout your code whenever you need it.
Upvotes: 4