简体   繁体   中英

How to decrypt encrypted password that is stored in database when user logins through login control asp.net c#

I created a custom registration page in asp.net c# and encrypted the password and saved it in SQL express database.I want to decrypt that password when user logins.I am using build in Login Control??

Can you please guide me how i will decrypt that password?? In code behind of login control i have used a select query with where clause that matches the user password that is stored in encrypted form in database.

You should match the encrypted password and not decrypt all of your passwords. You should temporarly encrypt the password the user inserted and query the database searching for a correspondence with the encrypted password.

An alternative to what @trippino recommended would be to store the hash value of your passwords in your databases, instead of the encrypted version. When the user logs in, you create a hash of the user's password and compare it with the hashes you have stored in your database.

This is usually safer since at no instance (other than the initial hashing phase) you are dealing with the actual user's password.

You don't decrypt the password. You simply match the encrypted password using the same algorithm you used to store it.

the easiest way to do this job is to encrypt the password that is entered and match it with already saved password. like eg you entered a password ' test ' at the time of registration and in database, it's saved as ' 193ed271e1eytjgwedguwegdkgwke ', now when user enter a test again on login encypt it with same function and it'll again generate the same encrypted code, if it's not the same code, it must be not the same password !

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM