0
当我有这个简单的MD5加密,但它似乎并没有工作,当我检查我的数据库没有已与我在密码文本框中键入改变了我的密码不会被加密。为什么插入VB.NET
这里是我的代码:
Dim strText As String = MetroTextBox6.Text
Dim bytHashedData As Byte()
Dim encoder As New UTF8Encoding()
Dim md5Hasher As New MD5CryptoServiceProvider
Using con = new MySqlConnection("server = localhost; user id = root; database = db; password = root")
Using cmd = con.CreateCommand()
con.Open()
Dim sqlQuery As String = "INSERT INTO candidate(uname,pword) VALUES("@votes, @pword")
With cmd
.CommandText = sqlQuery
.Parameters.AddWithValue("@uname", TextBox4.Text)
.Parameters.AddWithValue("@pword, MetroTextBox6.Text)
.ExecuteNonQuery()
bytHashedData = md5Hasher.ComputeHash(encoder.GetBytes(strText))
End With
MsgBox("Record Inserted")
End Using
...因为您在*之前插入值*,所以计算散列,然后您不对散列做任何事情。你如何期待数据库接收一个你还没有创建的值? SQL设计得非常好,但它并不具有先见之明。 – David 2014-10-19 14:47:42
你也没有输入密码 - 你是哈希它是一种方式。你不能解密它 – Plutonix 2014-10-19 15:02:12
没有盐的哈希? – Codexer 2014-10-20 00:54:52