Welcome to the new platform of Programmers Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use it's exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
result Xor BitConverter.ToInt32(chars, i) analog on php
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)
' 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