[Reposted] Use the ASP.NET encryption password

xiaoxiao2021-03-06  19

When we build a database on the website, it is necessary to protect users' information security. Most users are not willing to let others know their own information, and the network management does not want to lose the reputation of the website because of security issues. No matter who, security issues are very important.

In order to solve this problem, I provide you with a simple and practical, but the old suit is the password encryption. Here we use ASP.NET technology to encrypt passwords. Simply put, it is to encrypt the password provided by the user, and then compare it and the data stored in the system, if the same is verified.

In ASP, the encrypted object is not provided, we can only use external objects to encrypt. Now it is good, providing encrypted solutions in ASP.NET. In the name space

System.Web.Security contains class formsauthentication, with a method HashPasswordforStoringInconfigfile. This method can provide users with

The characters become garbled, then store it, and even store it in cookies.

The HashPasswordforstoringInConfigfile method is easy to use, which supports "SHA1" and "MD5" encryption algorithms.

The following code has a simple demonstration about its usage:

<% @ Page language = "c #"%>

<% @ Import namespace = "system.web.security"%>