Dilemma

cdoverlaw

Well-known member
Joined
Oct 11, 2003
Messages
146
I am using this code which should open a encrypted file, decrypt it and then decrypt the data inside it to reveal a serverID/Domain

Code:
Sub ConvertSerial()
        Dim ch As Char
        Dim strCode As String
        Dim Code, Number As Short
        Dim Decrypt As String = ""
        Dim inbox As String
        Dim path As String

        path = System.Windows.Forms.Application.StartupPath & "\data002.cde"

        If path <> "" Then
            Try open file and trap any errors using handler
                strCode = 4712
                If strCode = "" Then Exit Sub if cancel clicked
                Code = CShort(strCode)
                FileOpen(1, path, OpenMode.Input)
                Do Until EOF(1) read lines from file
                    Input(1, Number) read encrypted numbers
                    ch = Chr(Number Xor Code) convert with Xor
                    Decrypt = Decrypt & ch and build string
                Loop
                Serial = Decrypt then display converted string
            Catch

            Finally
                FileClose(1) close file
            End Try
        End If


        Decrypt = ""
        path = Serial

        If path <> "" Then
            Try open file and trap any errors using handler
                strCode = 4712
                If strCode = "" Then Exit Sub if cancel clicked
                Code = CShort(strCode)
                FileOpen(1, path, OpenMode.Input)
                Do Until EOF(1) read lines from file
                    Input(1, Number) read encrypted numbers
                    ch = Chr(Number Xor Code) convert with Xor
                    Decrypt = Decrypt & ch and build string
                Loop
                frmAbout.txtServerID.Text = Decrypt then display converted string
            Catch

            Finally
                FileClose(1) close file
            End Try
        End If
    End Sub

What is wrong as this isnt doing anything, its not showing the domain in the box like it should

Jonathan
 
What does the variable Decrypt look like if you step through the code? Is it being built up correctly?

Also there is a lot of VB6 code in there - you might be better of looking at classes under System.IO and System.Security.Cryptography for this kind of thing.
 
the thing is this code works when opening a file and decrypting, but dosent seem to work when decrypting data already in program,
anyone know how i can fix this
 
Last edited by a moderator:
Back
Top