Hash with MD5 in VB.NET

后端 未结 4 1458
自闭症患者
自闭症患者 2020-12-06 15:08

So, I got a bit of a problem here, I got a database, a login and a registration, all in different classes, now I need to hash the password in the database and read it out ag

4条回答
  •  旧时难觅i
    2020-12-06 15:44

       Private Function GetHash(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 New StringBuilder
    
        For Each b As Byte In bytesToHash
            strResult.Append(b.ToString("x2"))
        Next
    
        Return strResult.ToString
    
    End Function
    

提交回复
热议问题