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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With