PDA

Click to See Complete Forum and Search --> : vb.NET convert to PHP


dr_aybyd
Aug 7th, 2010, 11:00 AM
Is there any good way to convert a vb.net code into PHP?
Here is my code function that want to convert into php. Tia

Dim valuearray As Byte() = New Byte(3) {}
Dim s As String = myMD5res
Dim rx As New Regex("\w{2}")
Dim mc As MatchCollection = rx.Matches(s)
Dim sb As New StringBuilder()

Dim n As Integer = mc.Count / 4
For i As Integer = 0 To n - 1
For j As Integer = 0 To n - 1
valuearray(j) = Convert.ToByte(mc(i + (j * n)).Value, 16)
Next
Dim value As Integer = valuearray(0) Xor valuearray(1) Xor valuearray(2) Xor valuearray(3)

sb.Append(value.ToString("X2"))
Next

Dim hex32 As String = sb.ToString()
Dim myCodes As Integer = ("&H" & hex32 And &H1FFFFFF) Or &H2000000
Dim newCodes As String = myCodes.ToString("X2")

Dim hexNumber As [String] = newCodes
Dim hextodecs As Integer = Int32.Parse(hexNumber, NumberStyles.HexNumber)
TextBox1.Text = hextodecs

kows
Aug 7th, 2010, 06:51 PM
not unless you rewrite it.

what exactly is this piece of code supposed to be doing?

dr_aybyd
Aug 7th, 2010, 07:16 PM
that will Xor my MD5 results

tomcatexodus
Aug 25th, 2010, 12:27 PM
If for only this function, then rewriting it would be optimal.

However, if in the future you want to utilize large and cumbersome functions that would take far too much work to rewrite to PHP from VB, if you compile your functions into a library, you can access them from PHP via the COM Class (http://www.php.net/manual/en/class.com.php). Unfortunately I haven't really explored this so I don't have much other information on it, but google reveals a number of tutorials and forum threads on it.