473,659 Members | 2,680 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 7155
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_Y OU?" <us**@domain.co m> wrote in message
news:%2******** *******@TK2MSFT NGP12.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_YO U,
You could use the System.Security .Cryptography.C ryptoStream 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(fi le, ...)
Dim reader as New StreamReader(cr ypto, ...)

Dim writer as New StreamWriter(cr ypto, ...)

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_Y OU?" <us**@domain.co m> wrote in message
news:%2******** *******@TK2MSFT NGP12.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
39357
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
10471
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
4928
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 any solid reasons to prefer text files over binary files files?
3
3479
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 possible to change the behavior of operator << so it will stream numeric values as their actual values when an ofstream is in binary mode. I did not, however, find any information on how this can be accomplished. What is involved in getting this...
8
9512
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 contains the following three floating-point numbers: 1.0 2.0 3.0
50
4931
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 -- the character input is a different matter, at least if I want to remain within the bounds of the standard library.
12
5876
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: <gibberish>file//g:\pathtofile1<gibberish>file//g:\pathtofile2<gibberish> etc. I want to remove the "g:\" from the file paths. I wrote a console app that successfully reads the file and writes a duplicate of it, but fails for some reason to do the "replacing" of the "g:\". The code...
10
3637
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 binary mode. according to me, notepad opens files and each byte of the file read, it converts that byte from ascii to its correct character and displays
4
9540
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 code that processes all text files in a directory but leaves binary files alone. -- http://www.florencesoft.com
7
3094
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 assumptions are, well, least unportable. In particular, do anyone know if there are real-life systems where the text file assumptions below don't hold? For text mode FILE*s,
0
8332
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8851
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8746
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8627
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7356
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6179
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2750
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.