-3
我的散列md5 + salt,其中salt在應用程序中預先製作。VB.NET解密一個散列並在DataGridView中顯示
Function md5hash(value As String) As Byte()
Return md5.ComputeHash(ASCIIEncoding.ASCII.GetBytes(value))
End Function
Function decrypt(encryptedString As String, key As String) As String
de5.Key = md5hash(key)
de5.Mode = CipherMode.ECB
Dim buffer As Byte() = Convert.FromBase64String(encryptedString)
Return ASCIIEncoding.ASCII.GetString(de5.CreateDecryptor().TransformFinalBlock(buffer, 0, buffer.Length))
End Function
現在我想檢索數據庫中散列(加密)的數據。我可以檢索數據,但散列。不是等效的字符串。這是我的DataGridView代碼。
connection()
Dim dataAdapter As New MySqlDataAdapter
Dim dataTable As New DataTable
Dim bSource As New BindingSource
Try
conn.Open()
Dim query As String
query = "SELECT column07 AS 'Company ID', column08 AS Lastname, column12 AS Firstname, column06 AS Middlename, column02 AS 'Contact No.', column05 AS 'Current Address', column14 AS 'Permanent Address' FROM dbtest.table01 WHERE column15 = '" & encrypt("Single", salt) & "'"
command = New MySqlCommand(query, conn) 'I think this is the part where I put my decrypt method.
dataAdapter.SelectCommand = command 'Maybe here.
dataAdapter.Fill(dataTable) 'I dont know where and how
bSource.DataSource = dataTable 'Please help thanks!
DataGridView_Accounts.DataSource = bSource
dataAdapter.Update(dataTable)
conn.Close()
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Finally
conn.Dispose()
End Try
查詢工作正常。它只是解密(dehashing)不是。
哈希是單向加密,所以他們不能解密。另外,按照今天的標準,MD5是一種全面散列方法。 – Plutonix
就像我所說的,檢索正在工作。與散列數據。它甚至可以檢索到標籤/文本框。我只是不知道如何檢索它並顯示在datagridview中。 – Maki
我們不知道'de5'是什麼,我們不知道'encrypt'的確能理解你正在做什麼。通過文本和標題,你不能「散列」散列,這就是他們的觀點。我懷疑你在加密,而MD5是用來散列鹽的? – Plutonix