i need to read a text file per 4 chars
the file is coded with a simpel Xor.
file:
127712771266120012071185119012031212
it should be something like this:
[VB]
decoded(0) = 1277
decoded(1) = 1277
decoded(2) = 1266
decoded(3) = 1200
decoded(4) = 1207
...
[/VB]
then they have to be decoded so:
[VB]
Dim password as Integer = 1234
decoded(0) = chr(decoded(0) Xor password) decoded(0) = "/"
decoded(1) = chr(decoded(1) Xor password) decoded(1) = "/"
decoded(2) = chr(decoded(2) Xor password) decoded(2) = " "
decoded(3) = chr(decoded(3) Xor password) decoded(3) = "b"
decoded(4) = chr(decoded(4) Xor password) decoded(4) = "e"
...
[/VB]
This is my code at the moment:
[VB]
Dim password as Integer = 1234
Dim file As String = OpenFileDialog1.FileName
Dim objLeesBestand As New System.IO.StreamReader(file)
Dim i, a As Integer
Dim lengteBestand As Long = objLeesBestand.BaseStream.Length
For i = 0 To i = (lengteBestand / 4) Step 4
ReDim Preserve strBlok(i + 4)
objLeesBestand.Read(strBlok, i, 4)
ReDim Preserve decoded(a)
decoded(a) = strBlok(i) & strBlok(i + 1) & strBlok(i + 2) & strBlok(i + 3)
decoded(a) = decoded(a) Xor password
TextBox2.Text &= Chr(decoded(a))
a += 1
Next
objLeesBestand.Close()
objLeesBestand = Nothing
[/VB]
The problem is:
Textbox2.Text contains only the first decoded char and the arrays only have 1 value.
For some reason this For Next isnt completed.
Does Anybody has an idea what went wrong?
the file is coded with a simpel Xor.
file:
127712771266120012071185119012031212
it should be something like this:
[VB]
decoded(0) = 1277
decoded(1) = 1277
decoded(2) = 1266
decoded(3) = 1200
decoded(4) = 1207
...
[/VB]
then they have to be decoded so:
[VB]
Dim password as Integer = 1234
decoded(0) = chr(decoded(0) Xor password) decoded(0) = "/"
decoded(1) = chr(decoded(1) Xor password) decoded(1) = "/"
decoded(2) = chr(decoded(2) Xor password) decoded(2) = " "
decoded(3) = chr(decoded(3) Xor password) decoded(3) = "b"
decoded(4) = chr(decoded(4) Xor password) decoded(4) = "e"
...
[/VB]
This is my code at the moment:
[VB]
Dim password as Integer = 1234
Dim file As String = OpenFileDialog1.FileName
Dim objLeesBestand As New System.IO.StreamReader(file)
Dim i, a As Integer
Dim lengteBestand As Long = objLeesBestand.BaseStream.Length
For i = 0 To i = (lengteBestand / 4) Step 4
ReDim Preserve strBlok(i + 4)
objLeesBestand.Read(strBlok, i, 4)
ReDim Preserve decoded(a)
decoded(a) = strBlok(i) & strBlok(i + 1) & strBlok(i + 2) & strBlok(i + 3)
decoded(a) = decoded(a) Xor password
TextBox2.Text &= Chr(decoded(a))
a += 1
Next
objLeesBestand.Close()
objLeesBestand = Nothing
[/VB]
The problem is:
Textbox2.Text contains only the first decoded char and the arrays only have 1 value.
For some reason this For Next isnt completed.
Does Anybody has an idea what went wrong?
Last edited by a moderator: