|
-
Jun 6th, 2001, 02:30 PM
#1
Thread Starter
Fanatic Member
File decryption
I have a program the encrypts text files so they aren't readbale and then i need a different program to open the file and decrypt it. Below is the decrypt code and open code all as one. It gives me and error with this code:
decrypted$ = decrypted$ & newstr which is part of below code
it highlights the second decrypted$
Type-declaration charcter does not match declared data type
any help on why this is happening and what to do about it?
Sub frmMainFileOpenAs(Optional ByVal sFile As String)
On Error GoTo Exit_Sub
If Len(sFile) Then GoTo OpenFile
With frmMain
With .CommonDialog1
.CancelError = True
.DialogTitle = "File Save"
.Filter = "EDF(*.EDF)|*.EDF"
.ShowOpen
End With
If Len(.CommonDialog1.FileName) = 0 Then Exit Sub
sFile = .CommonDialog1.FileName
End With
OpenFile:
With frmMain
.listURL.Clear
.bDisableClickEvent = True
Open sFile For Input As #1
Dim strLine As String
Dim i As Long
Dim tmpstr As String
Dim pass$
Dim letter
Dim encstr
Dim newstr
Dim decrypted
Do While Not EOF(1)
Line Input #1, strLine
.Text1 = strLine
pass$ = Len(frmMain.password.Text) 'this is the exact same For the Encrypt Function
tmpstr = Len(frmMain.Text1.Text) 'the only difference is that instead of adding the lenght of password.text
'it is subtracted
If tmpstr = "0" Then
MsgBox ("You must first Type In something To Decrypt")
Exit Sub
End If
For i = 1 To tmpstr
letter = mID$(frmMain.Text1.Text, i, 1)
encstr = Asc(letter) - pass$
newstr = Chr$(encstr)
decrypted$ = decrypted$ & newstr
Next i
frmMain.Text1.Text = decrypted$
frmMain.Text1 = strLine
If i = 0 Then
.txtSavePath = Trim(strLine)
Else
.listURL.AddItem Trim(strLine)
.ListName.AddItem mID(strLine, InStrRev(strLine, "/") + 1)
End If
i = i + 1
Loop
Close_File:
Close #1
.bDisableClickEvent = False
.ShowSatus
.ChangeSaveFileName
Exit_Sub:
End With
End Subdecrypted$ = decrypted$ & newstr
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
|