Answered by:
Login control hash password SHA1

Question
-
User1028962535 posted
Hello,
I am trying to hash my password in an asp.net login control before validating it in a database, but its not working, is this possible?
Protected Sub ValidateUser(sender As Object, e As EventArgs)
Dim userId As Integer = 0
Dim roles As String = String.Empty
Dim constr As String = ConfigurationManager.ConnectionStrings("constr").ConnectionString
Using con As New SqlConnection(constr)
Using cmd As New SqlCommand("Validate_User")
cmd.CommandType = CommandType.StoredProcedureDim EncryptedPassword As String = FormsAuthentication.HashPasswordForStoringInConfigFile(password, "SHA1") (NOT WORKING)
cmd.Parameters.AddWithValue("@Username", Login1.UserName)
cmd.Parameters.AddWithValue("@Password", Login1.EncryptedPassword)
cmd.Connection = concon.Open()
Dim reader As SqlDataReader = cmd.ExecuteReader()
reader.Read()
userId = Convert.ToInt32(reader("UserId"))
roles = reader("Roles").ToString()
con.Close()
End Using
Select Case userId
Case -1
Login1.FailureText = "Username and/or password is incorrect."
Exit Select
Case -2
Login1.FailureText = "Account has not been activated."
Exit Selectthanks
Dan
Wednesday, July 11, 2018 2:53 PM
Answers
-
User-1171043462 posted
Refer
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Wednesday, July 11, 2018 3:47 PM
All replies
-
User-369506445 posted
Hi
Please follow below link
https://stackoverflow.com/questions/13373781/hashing-passwords-for-a-login-form-in-vb-net
Wednesday, July 11, 2018 3:06 PM -
User-1171043462 posted
Refer
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Wednesday, July 11, 2018 3:47 PM -
Wednesday, July 11, 2018 3:48 PM
-
User1028962535 posted
Thanks
Thursday, July 12, 2018 5:26 AM