Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

 

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

  • Administrators
Posted

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.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted (edited)

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

Edited by cdoverlaw

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...