Private Sub b2_Click(sender As Object, e As EventArgs) Handles b2.Click Try If t1.Text = Nothing Then MsgBox("You must enter the username ", Microsoft.VisualBasic.MsgBoxStyle.Exclamation, "Eror") End If If t2.Text = Nothing Then MsgBox("You must enter the Password ", Microsoft.VisualBasic.MsgBoxStyle.Exclamation, "Eror") End If Dim rndsalt1 As String Dim hashcheck As String Dim pwd As String = t2.Text DBConnection.Open() Dim abc As String = "select Rand_Salt,Hash_Code from pwdTable where UserName Like ' %" & t1.Text & "';" Dim cmd As SqlCommand = New SqlCommand(abc, DBConnection) Dim dr As SqlDataReader = cmd.ExecuteReader If dr.Read() Then rndsalt1 = dr(1).ToString() hashcheck = dr(2).ToString() End If DBConnection.Close() Dim passstr As String = pwd + rndsalt1 Dim bytes = Encoding.UTF8.GetBytes(passstr) Dim bpass As Byte() Dim hash As HashAlgorithm = New SHA256Managed() bpass = hash.ComputeHash(bytes) Dim storehash As String = Convert.ToBase64String(bpass) If storehash = hashcheck Then MessageBox.Show("Login sucessful !!!!") Else MessageBox.Show("Loged in sucessful ") End If Catch ex As Exception MessageBox.Show(ex.Message) End Try End Sub End Class
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)