how to use encrypted and decrypted Password for storing in databse and after that use it for login using Asp.net MVC.
Loading
how to use encrypted and decrypted Password for storing in databse and after that use it for login using Asp.net MVC.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Jaimin ShethiyaPosted May 9, 2024, 6:38 AM
Hello Soheb,
Here is the article links,
https://stackoverflow.com/questions/785016/best-practices-for-encrypting-and-decrypting-passwords-c-net
https://www.c-sharpcorner.com/article/encryption-and-decryption-using-a-symmetric-key-in-c-sharp/
Thanks
Amit MohantyPosted May 9, 2024, 6:15 AM
Check the below links:
https://www.aspsnippets.com/Articles/3639/ASPNet-Core-MVC-Encrypt-and-Decrypt-Username-or-Password-stored-in-database/
https://www.code2night.com/Blog/MyBlog/How-to-Encrypt-and-Decrypt-Password-in-Asp.Net-
Naimish MakwanaPosted May 9, 2024, 4:37 AM
To use encryption and decryption for storing passwords in a database and then using it for login in an ASP.NET MVC application.
Here’s a simple step-by-step guide:
Install the necessary package: Install the
System.Security.Cryptographynamespace which provides cryptographic services, including secure encoding and decoding of data.Encrypt the Password: When a user is registering or changing their password, you should hash the password. Here’s a simple way to do that:
Store the Encrypted Password: Store this hashed password in your database. Never store the plain-text password.
Verify the Password: When a user logs in, hash the password they enter in the same way as before, and compare it to the hashed password in your database.
Thanks
Soheb AhmadPosted May 9, 2024, 4:24 AM
sir can you provide any articale with Example.
Jaimin ShethiyaPosted May 9, 2024, 4:23 AM
Hello Soheb,
When you store data on the database side, you need to encrypt the password, update that value in the password field or properties, and save the data in the database.
When the user uses the password at that time, you need to bring that password from the database, decrypt that password, and compare both values; if they match, then provide grant access; otherwise, you won't.
Here are some links for how to encrypt and decrypt things on the C# side.
https://stackoverflow.com/questions/785016/best-practices-for-encrypting-and-decrypting-passwords-c-net
https://www.c-sharpcorner.com/article/encryption-and-decryption-using-a-symmetric-key-in-c-sharp/
Thanks
Tural SuleymaniPosted May 8, 2024, 7:17 PM
Encryption: Encrypt the password before storing it in the database. You can use cryptographic hashing algorithms like bcrypt, PBKDF2, or SHA-256. ASP.NET provides built-in support for hashing passwords using the
System.Security.Cryptographynamespace.Storage: Store the encrypted password in your database. Make sure the field in your database table is large enough to accommodate the encrypted password.
Login: When a user attempts to log in, you hash the provided password and compare it with the stored, encrypted password in the database. If the hashes match, the passwords match.