My program creates temp files...Which is ok...Until you have over 400 of them on your hardrive. My program uses encryption to encrypt and decrypt passwords in an *.ini file.
I didnt create this encryption or decryption code so I wouldnt know how it works.
Does the code below cause the creation of hundreds of *.ini files?
Encrypt Code:
VB Code:
Private Sub cmdencrypt_Click() On Error GoTo handler2 cmdencrypt.Enabled = False cmddecrypt.Enabled = False cmdexit.Enabled = False Dim full, full2, temp, lin As String temp = "" If txtname.Text = "" Then cmdencrypt.Enabled = True cmddecrypt.Enabled = True cmdexit.Enabled = True Exit Sub End If If (UCase(Right(txtname.Text, 3)) <> "TXT") And (UCase(Right(txtname.Text, 3)) <> "INI") And (UCase(Right(txtname.Text, 3)) <> "VBS") And (UCase(Right(txtname.Text, 3)) <> "INF") And (UCase(Right(txtname.Text, 3)) <> "BAT") Then cmdencrypt.Enabled = True cmddecrypt.Enabled = True cmdexit.Enabled = True Exit Sub End If If Right(Dir1.Path, 1) = "\" Then full = txtname.Text full2 = App.Path & "\temp.tmp" Else full = txtname.Text full2 = App.Path & "\temp.tmp" End If Open full For Input As #3 Line Input #3, emp Close #3 If emp = "" Then cmdencrypt.Enabled = True cmddecrypt.Enabled = True cmdexit.Enabled = True Exit Sub End If chksum = "[§Encrypted§]" Open full For Input As #1 Line Input #1, chks Close #1 If (chks = chksum) Then cmdencrypt.Enabled = True cmddecrypt.Enabled = True cmdexit.Enabled = True Exit Sub End If StatusBar1.SimpleText = " Status: Encryption in progress...." Open full2 For Output As #3 Print #3, chksum Close #3 Open full For Input As #1 While Not EOF(1) Line Input #1, lin Open full2 For Append As #3 rev = reverse(lin) For I = 1 To Len(lin) encryptfactor = Len(lin) Mod 10 If encryptfactor = 0 Then encryptfactor = Int(Len(lin) / 10) End If A = Mid(rev, I, 1) B = Asc(A) + encryptfactor If B > 255 Then B = 255 End If temp = temp & Chr(B) Next Print #3, temp temp = "" Close #3 Wend Close #1 Kill (full) FileCopy full2, full Kill (full2) StatusBar1.SimpleText = " Status: Encryption completed !" cmdencrypt.Enabled = True cmddecrypt.Enabled = True cmdexit.Enabled = True StatusBar1.SimpleText = " Status: Ready" Exit Sub handler2: s = MsgBox(Err.Description, vbExclamation, "Error !") g = Dir(full2) If g <> "" Then Kill (full2) End If cmdencrypt.Enabled = True cmddecrypt.Enabled = True cmdexit.Enabled = True End Sub
And Here is the decrypt code:
VB Code:
Private Sub cmddecrypt_Click() On Error GoTo handler cmdencrypt.Enabled = False cmddecrypt.Enabled = False cmdexit.Enabled = False If txtname.Text = "" Then cmdencrypt.Enabled = True cmddecrypt.Enabled = True cmdexit.Enabled = True Exit Sub End If If (UCase(Right(txtname.Text, 3)) <> "TXT") And (UCase(Right(txtname.Text, 3)) <> "INI") And (UCase(Right(txtname.Text, 3)) <> "VBS") And (UCase(Right(txtname.Text, 3)) <> "INF") And (UCase(Right(txtname.Text, 3)) <> "BAT") Then cmdencrypt.Enabled = True cmddecrypt.Enabled = True cmdexit.Enabled = True Exit Sub End If If Right(Dir1.Path, 1) = "\" Then full = txtname.Text full2 = App.Path & "\temp.tmp" Else full = txtname.Text full2 = App.Path & "\temp.tmp" End If Open full For Input As #4 Line Input #4, chk Close #4 If (chk <> "[§Encrypted§]") Then cmdencrypt.Enabled = True cmddecrypt.Enabled = True cmdexit.Enabled = True Exit Sub End If StatusBar1.SimpleText = " Status: Decryption in progress...." Open full For Input As #1 Line Input #1, k While Not EOF(1) Line Input #1, lin Open full2 For Append As #3 rev = reverse(lin) For I = 1 To Len(lin) decryptfactor = Len(lin) Mod 10 If decryptfactor = 0 Then decryptfactor = Int(Len(lin) / 10) End If A = Mid(rev, I, 1) B = Asc(A) - decryptfactor temp = temp & Chr(B) Next Print #3, temp temp = "" Close #3 Wend Close #1 Kill (full) FileCopy full2, full Kill (full2) StatusBar1.SimpleText = " Status: Decryption completed !" cmdencrypt.Enabled = True cmddecrypt.Enabled = True cmdexit.Enabled = True StatusBar1.SimpleText = " Status: Ready" Exit Sub handler: s = MsgBox(Err.Description, vbExclamation, "Error !") g = Dir(full2) If g <> "" Then Kill (full2) End If cmdencrypt.Enabled = True cmddecrypt.Enabled = True cmdexit.Enabled = True End Sub
The part of this code that bothers me is:
VB Code:
full = app.path & "\temp.tmp"





Reply With Quote