Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


result Xor BitConverter.ToInt32(chars, i) analog on php

How to convert this 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)
' 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

Sign In or Register to comment.