Results 1 to 6 of 6

Thread: [RESOLVED] Converting PHP to VB6

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2007
    Posts
    1,072

    Resolved [RESOLVED] Converting PHP to VB6

    I need to convert this code from PHP to VB6:

    PHP Code:
    function stringToHex($uString$binder$key) {
            
    $index 0;
            
    $count 0;
            while (
    $index strLen($uString)) {
                if (
    $count >= strlen($binder))
                    
    $count 0;
                
    $current strpos($key$uString{$index});
                if (
    $current !== false) {
                    
    $current = ($current strpos($key$binder{$count})) % strlen($key);
                    
    $result .= $key{$current};
                } else {
                    
    $result .= $uString{$index};
                }
                
    $count++;
                
    $index++;
            }
            if (
    $randomKey 10)
                
    $result .= 0;
            
    $result .= $randomKey;
            return 
    $result;
        } 
    I've tried many times, and so has my friend.

    Please help

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Converting PHP to VB6

    Are you trying to convert ascii to hex?

  3. #3
    Frenzied Member Jim Davis's Avatar
    Join Date
    Mar 2001
    Location
    Mars base one Username: Jim Davis Password: yCrm33
    Posts
    1,284

    Re: Converting PHP to VB6

    PHP Code:
    function stringToHex($uString$binder$key) {
            
    $index 0;
            
    $count 0;
            while (
    $index strLen($uString)) {
                if (
    $count >= strlen($binder))
                    
    $count 0;
                
    $current strpos($key$uString{$index});
                if (
    $current !== false) {
                    
    $current = ($current strpos($key$binder{$count})) % strlen($key);
                    
    $result .= $key{$current};
                } else {
                    
    $result .= $uString{$index};
                }
                
    $count++;
                
    $index++;
            }
            if (
    $randomKey 10)
                
    $result .= 0;
            
    $result .= $randomKey;
            return 
    $result;
        } 
    vb Code:
    1. Public RandomKey As Long
    2. 'now set the randomkey anywhere you would like to.
    3.  
    4. Public Function stringToHex(ByVal uString as String, ByVal Binder as String, ByVal Key as String) As String
    5.   Dim Index As Long, Count as Long, Current as Long, Result As String
    6.  
    7.   Do While (Index < Len(uString))
    8.  
    9.     If Count >= Len(Binder) Then Count = 0
    10.  
    11.     Current = Instr(Key,Mid$(uString,Index+1,1))
    12.  
    13.     If Current > 0 Then
    14.       Current = (Current + Instr(Key,Mid$(Binder,Count+1,1))) Mod Len(Key)
    15.       Result = Result & Mid$(Key,Current+1,1)
    16.     Else
    17.       Result = Result & Mid$(uString,Index+1,1)
    18.     End If
    19.  
    20.     Count = Count +1
    21.     Index = Index +1
    22.  
    23.   Loop
    24.  
    25.   If RandomKey < 10 Then Result = Result & "0"
    26.   Result = Result & cstr(RandomKey)
    27.   stringToHex = Result
    28. End Function

    Well this is would be a translation if i'm right. I didnt test since i dont know what are the inputs/output could be. I also have no idea what is the purpose of this code. But what i'm pretty sure, that it isn't a string to hex conversion. But more like, some kind of a letter mixer thingige, or what. But i also not sure the reason why it is does that.


  4. #4
    Member mOBSCENE's Avatar
    Join Date
    Mar 2009
    Location
    New Jersey
    Posts
    46

    Re: Converting PHP to VB6

    its an encryption.

    i've seen this before somewhere...

  5. #5
    Frenzied Member Jim Davis's Avatar
    Join Date
    Mar 2001
    Location
    Mars base one Username: Jim Davis Password: yCrm33
    Posts
    1,284

    Re: Converting PHP to VB6

    AES would be better (and faster), i guess. But for password content you can also use MD5.

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2007
    Posts
    1,072

    Re: Converting PHP to VB6

    I have the fix:

    Code:
    Current = (Current + Instr(Key,Mid$(Binder,Count+1,1))) Mod Len(Key)
    That line needs to be:

    Code:
    Current = (Current + Instr(Key,Mid$(Binder,Count+1,1)) -2) Mod Len(Key)
    Probably something to do with starting string indices.

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