|
-
Sep 12th, 2000, 08:49 PM
#1
Thread Starter
Hyperactive Member
Decrypting a text file to a string variable, possible? (thread still opened!)
I have a small question.
Let me explain how my application works.
My application connects to an ftp and downloads Hello.txt. Hello.txt is encrypted using the code on the following thread: http://forums.vb-world.net/showthrea...threadid=21091
What I need to know is if there is a way to decrypt the text file, but in a variable or any other container of some sort? Because the content of the text file must remain unreadable to the user. Any idea?
-
Sep 12th, 2000, 09:02 PM
#2
Fanatic Member
ok, why not decryt it to a new file, then read in the file, then delete it.
[code]
Private Declare Function CopyFile Lib "kernel32" Alias "CopyFileA" (ByVal lpExistingFileName As String, ByVal lpNewFileName As String, ByVal bFailIfExists As Long) As Long
Private Declare Function GetTempFileName Lib "kernel32" Alias "GetTempFileNameA" (ByVal lpszPath As String, ByVal lpPrefixString As String, ByVal wUnique As Long, ByVal lpTempFileName As String) As Long
Private Declare Function GetTempPath Lib "kernel32" Alias "GetTempPathA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
Private Function GetDecrypted() As String
Dim MyTempPath As String
Dim FileStuff As String
MyTempPath = GetTemp
CopyFile "a:\myfile.txt", MyTempPath, False
DecryptFile MyTempPath, 44 'decrypt file
Open MyTempPath For Input As #1 ' open it
Do Until EOF(1)
Input #1, temp 'read and append new data to variable
FileStuff = FileStuff & temp
Loop
Close 1
Kill MyTempPath ' delete file
GetDecrypted = FileStuff 'return value
End Function
Private Sub Form_Load()
End Sub
Private Function GetTemp()
' Generate a temporary file (path)\api????.TMP, where (path)
' is Windows's temporary file directory and ???? is a randomly assigned unique value.
' Then display the name of the created file on the screen.
Dim temppath As String ' receives name of temporary file path
Dim tempfile As String ' receives name of temporary file
Dim slength As Long ' receives length of string returned for the path
Dim lastfour As Long ' receives hex value of the randomly assigned ????
' Get Windows's temporary file path
temppath = Space(255) ' initialize the buffer to receive the path
slength = GetTempPath(255, temppath) ' read the path name
temppath = Left(temppath, slength) ' extract data from the variable
' Get a uniquely assigned random file
tempfile = Space(255) ' initialize buffer to receive the filename
lastfour = GetTempFileName(temppath, "dec", 0, tempfile) ' get a unique temporary file name
' (Note that the file is also created for you in this case.)
tempfile = Left(tempfile, InStr(tempfile, vbNullChar) - 1) ' extract data from the variable
GetTemp = tempfile
End Function
GWDASH
[b]VB6, Perl, ASP, HTML, JavaScript, VBScript, SQL, C, C++, Linux , Java, PHP, MySQL, XML[b]
-
Sep 12th, 2000, 09:10 PM
#3
Thread Starter
Hyperactive Member
Actually, there was no problem for me to download the file, decrypt it, use its content and then delete it. The thing is i'm afraid the content could be seen (let's say a cracker/hacker that REALLY want to read the content).
I want to avoid this.. as a kind of security.
-
Sep 13th, 2000, 07:10 AM
#4
Fanatic Member
then modify the decrypting algorithm not to write to a file, but to return the data
Code Later
GWDASH
[b]VB6, Perl, ASP, HTML, JavaScript, VBScript, SQL, C, C++, Linux , Java, PHP, MySQL, XML[b]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|