-
I'm developing an application which will read information from a text file. There will be no writing to the file, just reading..
I don't want the end user to be able to read the information in the text file directly.. I had heard that it is possible to somehow decrypt the text and at the same time, my application can still read the text file...
What is the easiest way to accomplish this? Any help or guidance to the right resources would be appreciated..
Dan
-
To Encrypt The File:
Code:
code = InputBox("Enter Encryption Code", , 1)
If code = "" Then Exit Sub 'if Cancel chosen, exit sub
charsInFile% = Len(txtNote.Text) 'find string length
Open CommonDialog1.FileName For Output As #1 'open file
For i% = 1 To charsInFile% 'for each character in file
letter$ = Mid(txtNote.Text, i%, 1) 'read next char
'convert to number w/ Asc, then use Xor to encrypt
Print #1, Asc(letter$) Xor code; 'and save in file
Next i%
Close #1 'close file when finished
To Decrypt It:
Code:
code = InputBox("Enter encryption code", , 1)
If code = "" Then Exit Sub 'if Cancel chosen, exit sub
Open CommonDialog1.FileName For Input As #1 'open
decrypt$ = "" 'initialize string for decryption
Do Until EOF(1) 'until end of file reached
Input #1, Number& 'read encrypted numbers
e$ = Chr$(Number& Xor code) 'convert with Xor
decrypt$ = decrypt$ & e$ 'and build string
Loop
txtNote.Text = decrypt$
End If
There May Be Some Mistakes But This are the basics.