vb.net: MD5 Hash erzeugen


Die folgende Funktion erzeugt aus einem String einen MD5 Hash ohne Salt:

   Public Shared Function HashPwd(ByVal input As String)
            Dim x As System.Security.Cryptography.MD5CryptoServiceProvider = New System.Security.Cryptography.MD5CryptoServiceProvider
            Dim bs As Byte() = Encoding.UTF8.GetBytes(input)
            bs = x.ComputeHash(bs)
            Dim s As StringBuilder = New StringBuilder()
            For Each b As Byte In bs
                s.Append(b.ToString("x2").ToLower)
            Next
            Dim password As String = s.ToString
            Return password
        End Function

Schreibe einen Kommentar