Hello. I have been trying to encrypt password and found a code which is working with Access fine but as i have changed to SQL it is not decoding the encrypted text.. it amazes me..
this SQl code is not letting me log on..
Dim objConn As New SqlConnection(ConfigurationManager.ConnectionStrings("myconn").ConnectionString)
Dim objCmd As SqlCommand
Dim objDR As SqlDataReader
Function CheckCredentials(Username As String, Password As String) As Boolean
objCmd = New SqlCommand("SELECT Salt, Pass FROM Users WHERE Username=@givenUsername", objConn)
objDR = objCmd.ExecuteReader()
If Not objDR.Read() Then
Dim strSalt As String = objDR("Salt")
Dim strStoredPassword As String = objDR("Pass")
Dim strGivenPassword As String = FormsAuthentication.HashPasswordForStoringInConfigFile(strSalt & Password, "SHA1")
Return strStoredPassword = strGivenPassword
Sub CheckCredentials_Click(s As Object, e As EventArgs)
If (CheckCredentials(txtUsername.Text, txtPassword.Text) = True) Then
lblCheck.Text = "You entered the right credentials!"
lblCheck.Text = "You entered the wrong credentials!"
View Complete Post