Prevent users from reading application generated files

M

Mohit

Hi Experts,
I am working on a windows application that generates few text
files and saves it onto the disk. Now I want that only my application
can read the files i.e. I don't want the user to open and read
application generated file from windows explorer. My main purpose is
that file should not be viewable to user.
Encryption of files is one way to achieve it but as it increases
overhead so I am less interested in this approach.
I am looking for some other approach like - Can I password protect/
lock my files so that only application can read it?
Please suggest some way to do this.
Thanks in advance
 
P

Peter Duniho

Hi Experts,
I am working on a windows application that generates few text
files and saves it onto the disk. Now I want that only my application
can read the files i.e. I don't want the user to open and read
application generated file from windows explorer. My main purpose is
that file should not be viewable to user.
Encryption of files is one way to achieve it but as it increases
overhead so I am less interested in this approach.

Encryption is the only way. Depending on your needs, the encryption
doesn't necessarily need to be sophisticated.
I am looking for some other approach like - Can I password protect/
lock my files so that only application can read it?

There's no OS file system support for locking a user out of their own
data. You'll have to write the data to the file in some format that they
can't read.

It's not clear why your file shouldn't be readable by the user --
generally speaking, impeding the user from having full access to their own
data is not very nice -- but assuming you really need to do that, IMHO the
simplest approach would be to just run the output data through the
GzipStream class to compress it. A user could easily decompress the file
of course, if they figure out what the format is. But otherwise, the file
will be unreadable and you get the added advantage of much smaller file
sizes. In fact, it's likely that the i/o speed improvement dealing with
the smaller file will more than offset the additional overhead of
compressing and decompressing the data.

If that's not sufficient, you'll need a more elaborate encryption scheme.
There are cryptography classes in .NET that can help with that.

Pete
 
M

Mohit

Thanks a lot Peter for your prompt reply!!
It's not clear why your file shouldn't be readable by the user --
generally speaking, impeding the user from having full access to their own
data is not very nice

You are absolutely right. But I want to remove any possibility of
changing appl generated file by user.
I will probably go for some simple encryption scheme.

Thanks once again.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top