Return to Snippet

Revision: 29936
at August 5, 2010 06:56 by psybuck2002us


Initial Code
Public Shared Function getMD5Hash(ByVal strToHash As String) As String
            Dim md5Obj As New System.Security.Cryptography.MD5CryptoServiceProvider()
            Dim bytesToHash() As Byte = System.Text.Encoding.ASCII.GetBytes(strToHash)

            bytesToHash = md5Obj.ComputeHash(bytesToHash)

            Dim strResult As String = ""
            Dim b As Byte

            For Each b In bytesToHash
                strResult += b.ToString("x2")
            Next

            Return strResult
End Function

Initial URL

                                

Initial Description
This function accepts a string and converts it to its corresponding 32 bit hexadecimal MD5 hash. It comes in handy for encrypting passwords and keys.

Initial Title
Hash a string using MD5 hash algorithm

Initial Tags

                                

Initial Language
VB.NET