i need to encrypt all the contents in a particular folder......
but not knowing how to read the contents of entire folder at a time...
i even need to encrypt folder so that even the folder shouldn't be accessed....
Printable View
i need to encrypt all the contents in a particular folder......
but not knowing how to read the contents of entire folder at a time...
i even need to encrypt folder so that even the folder shouldn't be accessed....
Operating systems (or file systems) typically let you set the access rights that various users have to various files and directories. Typically these are much more precise than "can access" vs "can't access". If your problem really is access control, then use the mechanism your file system or OS provides.
Encryption is something else. Encryption aims at making the file's contents unavailable to anyone who doesn't possess a suitable key. That is copies are as protected as their encrypted originals. There is a list of cryptographic file systems here: List of cryptographic file systems - Wikipedia, the free encyclopedia.
Finally an actual Java question: how would you visit all of the files and directories within a given directory? There is a code example of this at Java Developers Almanac. What they call process() is a method that you would implement to do the actual encryption.
When i read all files as byte stream, i can encrypt the files one by one so that they cant be opened...... Afterwards i need to even rename or encrypt the folder so tat even tat cant be opened.....Can u please suggest me how i can rename it or encrypt the folder so tat it cant be opened
I'm not sure why you are doing this, but Java can't encrypt a folder. A folder is part of the OS, and it contains no data. In addition, using Java to encrypt the contents of a file is easy, but automating that process, especially the decrypt part, is not.
i'm doin locking folders and files as a module in my project.... So, i'm thinking of encrypting a folder so that it wont be opened..... But i'm thinking a direct method for reading a folder would make it easier instead storing entire directory structure to get back files when decrypting....
I would look into using a zip/jar file in combination with Cipher(In/Out)putStreams if this were my project. It sounds fun. Good luck.