Results 1 to 6 of 6

Thread: How can I use RC4 encryption for RealBasic?

  1. #1
    Join Date
    Jun 2004
    Posts
    63

    How can I use RC4 encryption for RealBasic?

    I have installed RealBasic on the computer of mine. I am looking to have RC4 encryption on the application of mine. however I am not aware of any code which I can used to get the requirement of mine. Let me know if you are aware of any code which I can use to apply to fix the matter of mine. I am waiting for the prompt replies of yours in this particular matter. Thanks a lot in advance.

  2. #2
    Join Date
    Jun 2009
    Posts
    1,205

    Re: How can I use RC4 encryption for RealBasic?

    Looking at the requirement of matter I am suggesting following code which you should copy and paste so that you can avoid the syntax error.
    Code:
    function rc4(strData as string, strKey as string) as string
    
       dim memAsciiArray(255) as integer
      dim memKeyArray(255)   as integer
      dim memJump            as integer
      dim memTemp            as integer
      dim memY               as integer
      dim intKeyLength       as integer
      dim intIndex           as integer
      dim intT               as integer
      dim intX               as integer
      dim strCData           as string
      
      intKeyLength = len(strKey)
      
      for intIndex = 0 to 255
        memKeyArray(intIndex)   = asc(mid(strKey, ((intIndex) mod (intKeyLength)) + 1, 1))
      next
      
      for intIndex = 0 to 255
        memAsciiArray(intIndex) = intIndex
      next
      
      for intIndex = 0 to 255
        memJump                 = (memJump + memAsciiArray(intIndex) + memKeyArray(intIndex)) mod 256
        memTemp                 = memAsciiArray(intIndex)
        memAsciiArray(intIndex) = memAsciiArray(memJump)
        memAsciiArray(memJump)  = memTemp
      next
      
      intIndex = 0
      memJump  = 0
      
      for intX = 1 to len(strData)
        intIndex                = (intIndex + 1) mod 256
        memJump                 = (memJump + memAsciiArray(intIndex)) mod 256
        intT                    = (memAsciiArray(intIndex) + memAsciiArray(memJump)) mod 256
        memTemp                 = memAsciiArray(intIndex)
        memAsciiArray(intIndex) = memAsciiArray(memJump)
        memAsciiArray(memJump)  = memTemp
        memY                    = memAsciiArray(intT)
        strCData                = strCData + chr(bitwise.bitxor(asc(mid(strData, intX, 1)), bitwise.bitxor(memTemp,memY)))
      next
      
      return strCData
    
    end function

  3. #3
    Join Date
    Mar 2009
    Posts
    1,221

    Re: How can I use RC4 encryption for RealBasic?

    I have modified the following code so that it can make use of the memory block so that there will be enhanced performance of the code. However performance will be affected by the speed of the computer.
    Code:
      Dim MM as MemoryBlock = strData
      Dim MM2 as New MemoryBlock(LenB(strData))
      
      intKeyLength = len(strKey)
      
      for intIndex = 0 to 255
        memKeyArray(intIndex) = asc(mid(strKey, ((intIndex) mod (intKeyLength)) + 1, 1))
      next
      
      for intIndex = 0 to 255
        memAsciiArray(intIndex) = intIndex
      next
      
      for intIndex = 0 to 255
        memJump = (memJump + memAsciiArray(intIndex) + memKeyArray(intIndex)) mod 256
        memTemp = memAsciiArray(intIndex)
        memAsciiArray(intIndex) = memAsciiArray(memJump)
        memAsciiArray(memJump) = memTemp
      next
      
      intIndex = 0
      memJump = 0
      
      for intX = 1 to theLen
        intIndex = (intIndex + 1) mod 256
        memJump = (memJump + memAsciiArray(intIndex)) mod 256
        intT = (memAsciiArray(intIndex) + memAsciiArray(memJump)) mod 256
        memTemp = memAsciiArray(intIndex)
        memAsciiArray(intIndex) = memAsciiArray(memJump)
        memAsciiArray(memJump) = memTemp
        memY = memAsciiArray(intT)
        mm2.Byte(intX - 1) = bitwise.bitxor(val("&h" + hex(MM.byte(IntX - 1))), bitwise.bitxor(memTemp,memY))
      next
      
      return MM2

  4. #4
    Join Date
    May 2008
    Posts
    1,304

    Re: How can I use RC4 encryption for RealBasic?

    I let you know that RC4 is seems to be symmetric function. It means that you should use the same function for both the purpose of the decryption as well as encryption. So you can use the above mentioned code for the same purpose over here.
    Code:
    Function rc4(strData as string, strKey as String) As String
      Dim MM as MemoryBlock = strData
      Dim MM2 as New MemoryBlock(LenB(strData))
      dim memAsciiArray(255) as integer
      dim memKeyArray(255)   as integer
      dim memJump as integer
      dim memTemp as integer
      dim memY as integer
      dim intKeyLength as integer
      dim intIndex as integer
      dim intT as integer
      dim intX as integer
      
      intKeyLength = len(strKey)
      
      for intIndex = 0 to 255
        memKeyArray(intIndex) = asc(mid(strKey, ((intIndex) mod (intKeyLength)) + 1, 1))
      next
      
      for intIndex = 0 to 255
        memAsciiArray(intIndex) = intIndex
      next
      
      for intIndex = 0 to 255
        memJump = (memJump + memAsciiArray(intIndex) + memKeyArray(intIndex)) mod 256
        memTemp = memAsciiArray(intIndex)
        memAsciiArray(intIndex) = memAsciiArray(memJump)
        memAsciiArray(memJump) = memTemp
      next
      
      intIndex = 0
      memJump = 0
      
      for intX = 1 to MM2.Size
        intIndex = (intIndex + 1) mod 256
        memJump = (memJump + memAsciiArray(intIndex)) mod 256
        intT = (memAsciiArray(intIndex) + memAsciiArray(memJump)) mod 256
        memTemp = memAsciiArray(intIndex)
        memAsciiArray(intIndex) = memAsciiArray(memJump)
        memAsciiArray(memJump) = memTemp
        memY = memAsciiArray(intT)
        mm2.Byte(intX - 1) = bitwise.bitxor(val("&h" + hex(MM.byte(IntX - 1))), bitwise.bitxor(memTemp,memY))
      next
      
      return MM2
    End Function

  5. #5
    Join Date
    Nov 2008
    Posts
    1,066

    Re: How can I use RC4 encryption for RealBasic?

    I am suggesting following code which you should try to get the requirement of mine and I am hoping that it will be useful to you.
    Code:
      dim mm as memoryblock = s
      dim MM2 as New MemoryBlock(LenB(S))
      dim theLen as integer = LenB(S)
      dim t as integer
      
      For I as integer = 1 to theLen
        dim temp as integer = BitwiseXOR(Val("&h" + hex(mm.byte(i-1))), (128 + T * i) Mod 256)
        
        MM2.byte(i-1) = temp
      Next
      
      Return mm2

  6. #6
    Join Date
    May 2009
    Posts
    539

    Re: How can I use RC4 encryption for RealBasic?

    If any of the above mentioned code is not working for you than I recommend that you should use the following piece of code to meet the requirement of yours.

    Code:
    dim memAsciiArray(255) as integer
      dim memKeyArray(255) as Integer
      dim memJump as integer
      dim memTemp as integer
      dim memY as integer
      dim intKeyLength as integer
      dim intIndex as integer
      dim intT as integer
      dim intX as integer
      dim strCData as string
      
      Dim theLen as Integer = LenB(strData)
      Dim MM as MemoryBlock = strData
      Dim MM2 as New MemoryBlock(LenB(strData))
      
      intKeyLength = len(strKey)
      
      for intIndex = 0 to 255
        memKeyArray(intIndex) = asc(mid(strKey, ((intIndex) mod (intKeyLength)) + 1, 1))
      next
      
      for intIndex = 0 to 255
        memAsciiArray(intIndex) = intIndex
      next
      
      for intIndex = 0 to 255
        memJump = (memJump + memAsciiArray(intIndex) + memKeyArray(intIndex)) mod 256
        memTemp = memAsciiArray(intIndex)
        memAsciiArray(intIndex) = memAsciiArray(memJump)
        memAsciiArray(memJump) = memTemp
      next
      
      intIndex = 0
      memJump = 0
      
      for intX = 1 to theLen
        intIndex = (intIndex + 1) mod 256
        memJump = (memJump + memAsciiArray(intIndex)) mod 256
        intT = (memAsciiArray(intIndex) + memAsciiArray(memJump)) mod 256
        memTemp = memAsciiArray(intIndex)
        memAsciiArray(intIndex) = memAsciiArray(memJump)
        memAsciiArray(memJump) = memTemp
        memY = memAsciiArray(intT)
        mm2.Byte(intX - 1) = bitwise.bitxor(val("&h" + hex(MM.byte(IntX - 1))), bitwise.bitxor(memTemp,memY))
      next
      
      return MM2

Similar Threads

  1. Replies: 5
    Last Post: 27-07-2011, 11:20 PM
  2. Manipulating HTML document into the RealBasic
    By Borislav in forum Software Development
    Replies: 5
    Last Post: 27-07-2011, 11:10 PM
  3. Difference between REALbasic and Cocoa
    By Gajananvihari in forum Software Development
    Replies: 4
    Last Post: 26-02-2010, 10:27 AM
  4. what is REALbasic?
    By Jagruti23 in forum Software Development
    Replies: 4
    Last Post: 26-02-2010, 10:08 AM
  5. Replies: 2
    Last Post: 22-02-2006, 03:53 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,715,549,911.60655 seconds with 17 queries