I have a form register.aspx
and a login function and I am using vb.net
In my register.aspx
I have two textboxes, for user name and password and a submit button. If the user click's on the submit button, the password will be hashed and stored with the username in the database table called Customer
I would like to know-
1) How to hash a password?
2) How to compare the hashed value in database with the password entered in the textbox while login?
To answer your questions in order.
Psuedo code:
Function GetUser(name, password)
hashedPassword = Hash(password)
sqlcmd = 'select userkey from user where username = @name and password = @pass'
add cmd parameter ('@name', name)
add cmd parameter ('@pass', hashedPassword)
userKey = cmd.executequry
Return userkey
End Function
That said, don't do this if you can implement OpenID instead. The world really doesn't need another site where you have to remember or share a password for no good reason.
You may use FormsAuthentication.HashPasswordForStoringInConfigFile
static method (System.Web.Security namespace).
Dim plain="abc"
Dim hash= FormsAuthentication.HashPasswordForStoringInConfigFile(plain, "MD5")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.