Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I programatically encrypt a flat file using Visual Basic?

Status
Not open for further replies.

gwward

Programmer
Dec 5, 2003
11
0
0
US
How do I programatically encrypt a flat file using Visual Basic? Then code a GUI to Decrypt the file. The user would
then be asked to enter the name of the encrypted file then press a button to Decrypt the file?

FYI: The file will be Encrypted on the server. From time
to time the Encryped file will be sent to a user who will
have the Decryption program to reverse the process so
they can load the file to an Access or SQL database.

Here's the code that I am currently using to format and
write the text file. Thanks a bunch for your help.

'-- FORMAT DATA STRING

MessageText = Request("name") & "|"
MessageText = MessageText & Request("ssn") & "|"
MessageText = MessageText & Request("housing_plans") & "|"
MessageText = MessageText & Request("custody") & "|"
MessageText = MessageText & Request("custody_ages") & "|"

'-- SEND DATA TO FILE


dim filesys, filetxt
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set filesys = CreateObject("Scripting.FileSystemObject")
Set filetxt = filesys.OpenTextFile (Server.MapPath "export/gradapp.txt"), ForAppending, True)
filetxt.WriteLine(MessageText)
filetxt.Close
 
Hello

You would need to write an encryption algorithm. Obviously the strength of the algorithm and length of the key will determine how strong it is.

I have written a reasonably secure algorithm in Access VBA, available from the Tek-Tips database at my site, Not being much of a student of cryptography I can't say how secure or otherwise it is, but it is secure enough for my needs. Unless you are storing military or government level sensitive data, or medical information it should be more than adequate.

The trouble comes when encrypting it on the server - you would need to write the encryption algorithm as a stored function in the database.

John
 
You may be safer to use the Windows Encription & Decription API. Details (and sample are available from:

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top