File protection file?

Do you guys know how I can protect my properties file so that only my program can modify it? I would not want anyone to read the properties file, if that was possible.

+4
source share
2 answers

I would recommend taking a look at

  Files.setPosixFilePermissions () 
or
  File.setReadOnly () 
if it needs to be done in Java.
+1
source

You ask the question in terms of absolutes, and there is no absolute way to do this. If your program can read and modify your file, then for another program or person there should be a way to do this too.

File permissions may help, but can you trust the root or admin user?

Even if permissions are right, can you trust other programs that run as your username?

Encrypting a file will make it difficult to read the file, but will not damage it. And a β€œcertain” person with access to your program will be able to find the decryption key (otherwise you would not be able to read it yourself).

In the end, you should ask yourself: "What are some reasonable steps I can take so that it’s not worth trying to access / read / modify the file?"

+10
source

Source: https://habr.com/ru/post/1482292/


All Articles