Define "can not be viewed". Any file can be opened in a text editor ...
whether or not the contents mean anything is a result of the data in the
file and possible some sort of encryption applied. If you want to prevent
casual reading of the file -- you can't prevent editing and possibly
rendering the file useless -- perhaps this might do what you want...
http://vbnet.mvps.org/code/algorithms/rot39.htm

Signature
Randy Birch
MVP Visual Basic
http://vbnet.mvps.org/
Please respond only to the newsgroups so all can benefit.
Having read your article "Simple Algorithms to Obfuscate a String" at
http://vbnet.mvps.org/index.html?code/algorithms/obfuscatedstring.htm
I wondered what would happen if I replaced Rnd -4 in the ConvertData
sub-routine with Rnd -(Timer).
If I didn't miss something it appears that you get a different
encrypted e-mail address every time you do the encryption because the
Rnd value is always changing. Seems like that has a very beneficial
use in keeping people from decrypting it "more easily", since the
encrypted string is different each time a person clicks on the button.
Might make someone scratch their head, eh?

Signature
---
Allen
> Define "can not be viewed". Any file can be opened in a text editor ...
> whether or not the contents mean anything is a result of the data in the
[quoted text clipped - 7 lines]
> : Does anybody know how to write to a file so that the contents cannot be
> : viewed by a text editor?
Randy Birch - 30 Jun 2004 03:31 GMT
The routine relies on the repeatability of random numbers, so seeding
with -4 provides for predicable decoding when passing the string back
through the same routine. It falls apart when a truly random number is
generated for the encode and decode sequences preventing the decoding from
working. The reason it *appears* to work if you use your suggestion just
for this demo is that the Timer function seeds the number to the time of the
machine, and as the code executes very quickly both the encoding and
decoding are happening at the same Timer time. If you try this modification
to the Command1_Click routine to introduce a delay when your
suggested -(Timer) is used instead of -4, you'll see the results are not as
you'd expect. Restoring to -4 (or any other fixed number for that matter)
will work...
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Sub Command1_Click()
Me.AutoRedraw = True
Dim sEncodedEmail As String
Print
Print Command1.Caption
sEncodedEmail = ConvertData(sDummyEmail)
Print "encoded", sEncodedEmail
Refresh
Call Sleep(1000) 'wait 1 second before decoding
Print "decoded", ConvertData(sEncodedEmail)
End Sub

Signature
Randy Birch
MVP Visual Basic
http://vbnet.mvps.org/
Please respond only to the newsgroups so all can benefit.
: Having read your article "Simple Algorithms to Obfuscate a String" at
: http://vbnet.mvps.org/index.html?code/algorithms/obfuscatedstring.htm
[quoted text clipped - 23 lines]
: cannot be
: > : viewed by a text editor?