Hash with MD5 in VB.NET

后端 未结 4 1460
自闭症患者
自闭症患者 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条回答
  •  醉话见心
    2020-12-06 15:37

    This would be my solution:

    Public Sub _Enkripsi()
    
        Dim _DES As New TripleDESCryptoServiceProvider()
        Dim _HashMD5 As New MD5CryptoServiceProvider()
    
        _DES.Key = _HashMD5.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(PasswordTextBox.Text))
        _DES.Mode = CipherMode.ECB
        Dim _DESEncrypt As ICryptoTransform = _DES.CreateEncryptor()
        Dim _Buffer As Byte() = System.Text.ASCIIEncoding.ASCII.GetBytes(PasswordTextBox.Text)
        _Password = Convert.ToBase64String(_DESEncrypt.TransformFinalBlock(_Buffer, 0, _Buffer.Length))
    
    End Sub
    

提交回复
热议问题