CGI Development

Moderators: Jonathan
Number of threads: 57
Number of posts: 124

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
result Xor BitConverter.ToInt32(chars, i) analog on php Posted by s_akmal on 29 Nov 2008 at 2:21 AM
How to convert this vb.net code into php code?

Private Function CalcHash(ByVal stringToHash As String) As String
' get character codes into an array
Dim chars As Byte() = Encoding.ASCII.GetBytes(stringToHash)
Dim result As Integer = 0
'step along the string in chunks of bytes
For i As Integer = 0 To chars.Length - 1 Step 4
' get 4 bytes as an int and xor into the result
result = result Xor BitConverter.ToInt32(chars, i)
Next
' get the negative result, no idea where the extra -1 comes from
result = -result - 1
' make sure that the resulting string is always 8 hex digits
Return result.ToString("x8")
End Function

Thanks...



 

Recent Jobs