|
-
Mar 15th, 2009, 10:49 PM
#1
Thread Starter
Frenzied Member
[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
-
Mar 16th, 2009, 06:49 AM
#2
Re: Converting PHP to VB6
Are you trying to convert ascii to hex?
-
Mar 16th, 2009, 04:53 PM
#3
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:
Public RandomKey As Long
'now set the randomkey anywhere you would like to.
Public Function stringToHex(ByVal uString as String, ByVal Binder as String, ByVal Key as String) As String
Dim Index As Long, Count as Long, Current as Long, Result As String
Do While (Index < Len(uString))
If Count >= Len(Binder) Then Count = 0
Current = Instr(Key,Mid$(uString,Index+1,1))
If Current > 0 Then
Current = (Current + Instr(Key,Mid$(Binder,Count+1,1))) Mod Len(Key)
Result = Result & Mid$(Key,Current+1,1)
Else
Result = Result & Mid$(uString,Index+1,1)
End If
Count = Count +1
Index = Index +1
Loop
If RandomKey < 10 Then Result = Result & "0"
Result = Result & cstr(RandomKey)
stringToHex = Result
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.
-
Mar 16th, 2009, 05:33 PM
#4
Member
Re: Converting PHP to VB6
its an encryption.
i've seen this before somewhere...
-
Mar 17th, 2009, 01:29 AM
#5
Re: Converting PHP to VB6
AES would be better (and faster), i guess. But for password content you can also use MD5.
-
Mar 18th, 2009, 07:12 PM
#6
Thread Starter
Frenzied Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|