473,385 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Text File / Binary File.

In my program I am using the notepad file to read/write data. I don't want
that someone should be able to delete/change the contents of that file by
opening that file in Notepad or other editor. Like there is a feature in
Word to put password to open your document. I want to do something like
that in Notepad file because I can't store the data in word file (in binary
format) because I am using stream reader/write object.

Is there any way that I read/write from my vb.net program in a text file and
still able to protect that file from end users to change its contents...
Nov 20 '05 #1
3 7142
you can open word documents and change the contents w/n any text editor...it
looks garbled because it is in word format. you'd have to come up w/ some
similar scheme or encryption to make your file garbled as well. the contents
can still be changed but just as in word, the end result of the edit will
most like corrupt the file. you can use md5 to has the file contents based
on a key that only your application knows. and, password protected or not,
you can delete any file.

fft,

steve

"I_AM_DON_AND_YOU?" <us**@domain.com> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
In my program I am using the notepad file to read/write data. I don't want
that someone should be able to delete/change the contents of that file by
opening that file in Notepad or other editor. Like there is a feature in
Word to put password to open your document. I want to do something like
that in Notepad file because I can't store the data in word file (in binary format) because I am using stream reader/write object.

Is there any way that I read/write from my vb.net program in a text file and still able to protect that file from end users to change its contents...

Nov 20 '05 #2
I_AM_DON_AND_YOU,
You could use the System.Security.Cryptography.CryptoStream to read & write
an encrypted stream. This encrypted stream could be a regular text file.

The user could still open the file in Notepad, however all they will see is
random letters & numbers in a binary format.

Basically you create the CryptoStream over your FileStream. You then open
your StreamReader & StreamWriter over your CryptoStream.

Dim file As New FileStream(...)
Dim crypto As New CryptoStream(file, ...)
Dim reader as New StreamReader(crypto, ...)

Dim writer as New StreamWriter(crypto, ...)

http://msdn.microsoft.com/library/de...yptingdata.asp

Just be certain to use a consistent & secure Key & IV so that you are able
to decrypt the data later.

I don't have samples handy, there is a way you could use a user supplied
password as part of the Key & IV.

Hope this helps
Jay
"I_AM_DON_AND_YOU?" <us**@domain.com> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
In my program I am using the notepad file to read/write data. I don't want
that someone should be able to delete/change the contents of that file by
opening that file in Notepad or other editor. Like there is a feature in
Word to put password to open your document. I want to do something like
that in Notepad file because I can't store the data in word file (in binary format) because I am using stream reader/write object.

Is there any way that I read/write from my vb.net program in a text file and still able to protect that file from end users to change its contents...

Nov 20 '05 #3
Hi Don,

One danger of any encrypted data approach is that if your users do open
the file and accidentally type something and accidentally save it (an unlikely
chain of events, perhaps, but..) then the data is kaput.

Another alternative is to store the data in a file which is hidden and
read-only. That will prevent casual and accidental tampering but not a
determined user.

And, of course, you could do both. ;-)

Regards,
Fergus
Nov 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: Sami Viitanen | last post by:
Hello, How can I check if a file is binary or text? There was some easy way but I forgot it.. Thanks in adv.
17
by: Guyon Morée | last post by:
what is the difference? if I open a text file in binary (rb) mode, it doesn't matter... the read() output is the same.
27
by: Eric | last post by:
Assume that disk space is not an issue (the files will be small < 5k in general for the purpose of storing preferences) Assume that transportation to another OS may never occur. Are there...
3
by: Tron Thomas | last post by:
What does binary mode for an ofstream object do anyway? Despite which mode the stream uses, operator << writes numeric value as their ASCII representation. I read on the Internet that it is...
8
by: Yeow | last post by:
hello, i was trying to use the fread function on SunOS and ran into some trouble. i made a simple test as follows: i'm trying to read in a binary file (generated from a fortran code) that...
50
by: Michael Mair | last post by:
Cheerio, I would appreciate opinions on the following: Given the task to read a _complete_ text file into a string: What is the "best" way to do it? Handling the buffer is not the problem...
12
by: Adam J. Schaff | last post by:
I am writing a quick program to edit a binary file that contains file paths (amongst other things). If I look at the files in notepad, they look like: ...
10
by: joelagnel | last post by:
hi friends, i've been having this confusion for about a year, i want to know the exact difference between text and binary files. using the fwrite function in c, i wrote 2 bytes of integers in...
4
by: Florence | last post by:
How can a binary file be distinguished from a text file on Windows? Obviously I want a way that is more sophisicated that just looking at the dot extention in the filename. I want to write...
7
by: Hallvard B Furuseth | last post by:
I'm trying to clean up a program which does arithmetic on text file positions, and also reads text files in binary mode. I can't easily get rid of it all, so I'm wondering which of the following...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.