doctor069
asked on
PHP MD5 Hash and .net MD5 not matching
Hi-
I have to get data from an external PHP site to my .net site.
The developer uses the following PHP code to get a hash:
$var1=1318437972;
$var2=01CdzTgUNgxIg;
md5(md5($var1). $var2)
Hash=06b27a58c07faee223d69 ca9e4a8716 3
I am trying to get the same hash in vb .net but the hashes are different:
Dim var1 As String = "1318437972"
Dim var2 As String = "01CdzTgUNgxIg"
Dim MD5Time As String = MD5(var1) & var2
Dim MD5Out As String = MD5(MD5Time)
MD5Out=5750b2229f7d00f955b 235616f633 fdc
So...
PHP Hash is 06b27a58c07faee223d69ca9e4 a87163
VB Hash is 5750b2229f7d00f955b235616f 633fdc
PS - My MD5 Function is provided below
Thanks in advance
I have to get data from an external PHP site to my .net site.
The developer uses the following PHP code to get a hash:
$var1=1318437972;
$var2=01CdzTgUNgxIg;
md5(md5($var1). $var2)
Hash=06b27a58c07faee223d69
I am trying to get the same hash in vb .net but the hashes are different:
Dim var1 As String = "1318437972"
Dim var2 As String = "01CdzTgUNgxIg"
Dim MD5Time As String = MD5(var1) & var2
Dim MD5Out As String = MD5(MD5Time)
MD5Out=5750b2229f7d00f955b
So...
PHP Hash is 06b27a58c07faee223d69ca9e4
VB Hash is 5750b2229f7d00f955b235616f
PS - My MD5 Function is provided below
Thanks in advance
Private Function MD5(ByVal str As String) As String
Dim provider As MD5CryptoServiceProvider
Dim bytValue() As Byte
Dim bytHash() As Byte
Dim strOutput As String = ""
Dim i As Integer
provider = New MD5CryptoServiceProvider()
bytValue = System.Text.Encoding.UTF8.GetBytes(str)
bytHash = provider.ComputeHash(bytValue)
provider.Clear()
For i = 0 To bytHash.Length - 1
strOutput &= bytHash(i).ToString("x").PadLeft(2, "0")
Next
Return strOutput
End Function
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Going to close this and try it in the PHP group
Here is what my hash function looks like:
Open in new window
I don't know if that helps you, but it might be worth a shot ;) Obviously you don't need to take in the optional encoding and hashAlgorithm arguments, that just a straight copy and paste from my personal encryption library..Instead of base64 encoding it you might try the literal string value of the bytes (again, you may want to check the encoding).
Open in new window
best of luck.