cdoverlaw Posted February 20, 2004 Posted February 20, 2004 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 Quote
Administrators PlausiblyDamp Posted February 20, 2004 Administrators Posted February 20, 2004 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. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
cdoverlaw Posted February 21, 2004 Author Posted February 21, 2004 (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 February 21, 2004 by cdoverlaw Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.