Hi,
I recently started using Basic4Android and have been trying to port a simple vb.net XOR encryption program. I have thoroughly read the topic about VB to Basic4Android however it only covers basic stuff.
The VB.net code i'm trying to port is:
Currently i've got this as the Basic4Android code:
It will load the file but it won't decrypt it.
Any help would be great and very much appreciated.
I recently started using Basic4Android and have been trying to port a simple vb.net XOR encryption program. I have thoroughly read the topic about VB to Basic4Android however it only covers basic stuff.
The VB.net code i'm trying to port is:
B4X:
Dim ch As Char
Dim strCode As String
Dim Code, Number As Short
Dim Decrypt As String = ""
OpenFileDialog1.Filter = "MN SecuPad Files (*.mnsec)|*.mnsec"
OpenFileDialog1.ShowDialog()
If OpenFileDialog1.FileName <> "" Then
Try
strCode = InputBox("Encryption Key:")
If strCode = "" Then Exit Sub
Code = CShort(strCode)
FileOpen(1, OpenFileDialog1.FileName, OpenMode.Input)
Do Until EOF(1)
Input(1, Number)
ch = Chr(Number Xor Code)
Decrypt = Decrypt & ch
Loop
RichTextBox1.Text = Decrypt
RichTextBox1.Select(1, 0)
' MenuItem4.Enabled = False
Catch ex As Exception
MsgBox("Incorrect Encryption Key. Access Denied!!")
Finally
FileClose(1)
End Try
End If
Currently i've got this as the Basic4Android code:
B4X:
Dim encfile As InputDialog
Dim fd As FileDialog
Dim readable As String
Dim inputcode1 As String
Dim inputc1 As Short
fd.FastScroll = True
fd.FilePath = File.DirInternal
fd.FileFilter = ".mnsec"
ret = fd.Show("Select A File:", "OK", "Cancel", "", Null)
If ret = -3 OR fd.ChosenName = "" Then
Return
End If
If File.Exists(File.DirInternal, fd.ChosenName) = False Then
Msgbox(fd.ChosenName & " does not exist.", "")
Return
End If
Dim TR As TextReader
Dim s As String
Dim ch As Char
Dim Number As Short
Dim Decrypt As String
Dim c As Cipher
TR.Initialize(File.OpenInput(File.DirInternal, fd.ChosenName))
s = TR.ReadLine
'add decryption and display file contents code here
encfile.Show("Enter Encryption Code","Code","OK","Canel","Negative",Null)
inputcode1 = encfile.Input
Dim Code As Short
inputc1 = encfile.Input
Code = inputc1
'Code = inputcode1
File.OpenInput(File.DirInternal,fd.ChosenName)
'Do Until s.Length
'Number = s
Decrypt = inputc1 + Code
'Loop
Msgbox("Incorrect Encryption Key. Access Denied!!","ACCESS DENIED!!!!")
'EditText1.Text = s
EditText1.Text = Decrypt
Msgbox(Decrypt,"Test")
'EditText1.Select(1, 0)
'MenuItem4.Enabled = False
'asndkajsndjkas
TR.Close
It will load the file but it won't decrypt it.
Any help would be great and very much appreciated.