Converting hash-generating code from ASP to PHP

Crusy

New Member
I have this code in ASP:\[code\]Public Function ComputeCredentialHash(ByVal timestamp As DateTime, ByVal id As String, ByVal authKey As String) As String Dim sig As String = timestamp.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.fffZ") & id & authKey Dim sigdata As Byte() = System.Text.Encoding.ASCII.GetBytes(sig) Dim md5 As System.Security.Cryptography.MD5 = New System.Security.Cryptography.MD5CryptoServiceProvider() Dim md5Hash As String = System.Convert.ToBase64String(md5.ComputeHash(sigdata)) Return md5HashEnd Function\[/code\]And I need to write a PHP function that does the same thing. So far I have:\[code\]function ComputeCredentialHash ($timestamp, $id, $authKey) { $sigData = http://stackoverflow.com/questions/15615784/mb_convert_encoding($timestamp.$id.$authKey,"ASCII", "auto"); $md5 = md5($sigData); $md5Hash = base64_encode($md5); echo "ComputeCredentialHash => $md5Hash<br/>Sig Data =http://stackoverflow.com/questions/15615784/> $sigData<br/>MD5 Sig => $md5<br/>"; return $md5Hash;}\[/code\]But this does not work. I'm sure it's due to the \[code\]ASCII.GetBytes\[/code\] function, but I'm not really sure how to convert that because I'm not really sure what it does. It looks like it just returns the number of bytes, but that doesn't really make sense to me (for why it would give you something so generic to make a hash out of). Anyway, if anyone can help, I'd appreciate it.
 
Top