Protecting a file
I have created a custom data file in java. It basically contains one long String that represents a data structure I need for my program. However, I want to make this file be safe and to have nobody be able to open it in Notepad or whatever, and read its contents (even if those contents are a bit scrambled).
I tried using a password, but what's the use if I can open the file with Notepad/Wordpad and read the raw data?
I tried doing a custom encryption scheme on the file. However, it turned out the operation took too long. I don't want to have to encrypt the whole file every time every time I save it. I want it to save fast, or at least fast enough that I don't have to wait for it to save.
So my question is.
-Is there a way to lock my file so that it cannot be opened by an external program, and can only be accessed from my program? This is my ideal solution.
-Alternatively, are there ways to encrypt the whole file that do not take long? (I am not familiar with Java classes for encryption. So far I have done my own custom encryption.)
You can't prevent editing or deleting a file. What you can do is use a database that requires a username and password to connect.
That still doesn't prevent the database itself being deleted.
If you are on Windows, and the filesystem is NTFS, you can hide your data in the alternate stream of an innocent-looking file. Search the net for NTFS alternate streams to know more. Still doesn't save the host file from deletion though.
You might get better suggestions if you can explain the nature of the sensitive data you're trying to protect.