06-18-2006, 09:31 PM
For some reason, my program prints just one line, then quits. I'm thinking it may be because my encryption program is sticking an EOF character in on accident, but not sure...
Any ideas how to fix it?
Code:
Dim plaintxt As String
Dim filename As String
Dim pass As Integer
Dim xorchar As Integer
Dim encrypted As String
Dim ciphered As String
Dim outfile As String
Dim file1 As Integer
Dim file2 As Integer
Input "File to encrypt: ", filename
Input "Password (numeric): ", pass
Input "File to output to: ", outfile
file1 = FreeFile
Open filename For Input As #file1
file2 = FreeFile
Open outfile For Output As #file2
Randomize pass
While Not EOF(file1)
Line Input #file1, plaintxt
For i = 1 To Len(plaintxt)
xorchar = Int(Rnd(1) * 255 + 1)
encrypted += chr$(asc(mid$(plaintxt,i,1)) xor xorchar)
Next i
Print #file2, encrypted
Wend
Close #1
Close #2
Print "Done!"
Print
Print
'Try unencrypting
Input "File to cipher: ", filename
Input "Password (numeric): ", pass
Input "Output File: ", outfile
file1 = FreeFile
Open filename For Input As #file1
file2 = FreeFile
Open outfile For Output As #file2
Randomize pass
While Not Eof(file1)
Line Input #file1, encrypted
For i = 1 To Len(encrypted)
xorchar = Int(Rnd(1) * 255 + 1)
ciphered += chr$(asc(mid$(encrypted, i, 1)) xor xorchar)
Next i
Print #file2, ciphered
Wend
Close #1
Close #2
Print "Done!"
sleep
Any ideas how to fix it?