CGI Development

Moderators: Jonathan
Number of threads: 55
Number of posts: 121

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

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.