Thanks Dean.
That does the trick.
For anyone else who needs this function, here it is:
Function MD5Encrypt(ByVal str As String) As String
Dim md5 As
System.Security.Cryptography.MD5CryptoServiceProvider
Dim bytValue() As Byte
Dim bytHash() As Byte
Dim strOutput As String
Dim i As Integer
' Create New Crypto Service Provider Object
md5 = New
System.Security.Cryptography.MD5CryptoServiceProvider
' Convert the original string to array of Bytes
bytValue = System.Text.Encoding.UTF8.GetBytes(str)
' Compute the Hash, returns an array of Bytes
bytHash = md5.ComputeHash(bytValue)
md5.Clear()
For i = 0 To bytHash.Length - 1
'don't lose the leading 0
strOutput &= bytHash(i).ToString("x").PadLeft(2, "0")
Next
MD5Encrypt = strOutput
' 11111111 = 1bbd886460827015e5d605ed44252251 in mysql
' 11111111 = 1bbd886460827015e5d605ed44252251 in VB.Net
' G72IZGCCcBXl1gXtRCUiUQ== UTF8
End Function
--- In [email protected], Dean Fiala
<[EMAIL PROTECTED]> wrote:
> If you take a look at the output you'll see that mySQL is
returning 32
> hexadecimal characters.
>
> You'll see the ComputeHash function is returning 16 bytes, the
base64
> is converting it into 24 characters that are not limited to
> hexadecimal range. But if you convert a byte into its hexidecimal
> representation, you get 2 hexadecimal chars 16x2 = 32 j(don't
forget
> to keep the leading 0s.)
>
> So what you need to do is convert each byte in bytHash to its
> hexadecimal representation.
>
> There is a probably a simplr way to this, but its late.
>
> Dim i As Integer
> For i = 0 To bytHash.Length - 1
> 'don't lose the leading 0
> strOutput &= bytHash(i).ToString("x").PadLeft(2, "0")
> Next
>
>
>
------------------------ Yahoo! Groups Sponsor --------------------~-->
Get Bzzzy! (real tools to help you find a job). Welcome to the Sweet Life.
http://us.click.yahoo.com/A77XvD/vlQLAA/TtwFAA/saFolB/TM
--------------------------------------------------------------------~->
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/