In the system administrator has a practical application, for a database management system, database security is very important, so the password stored to the database is usually encrypted. Even with the hack database, it will not be easy to steal your account and password, which can reduce your unnecessary losses. OK, here are some basic implementation codes:
The encrypted code format is the same:
First step:
Copy Code code as follows:
<span style= "FONT-SIZE:16PX; Color: #000000; >system.web.security.formsauthentication.hashpasswordforstoringinconfigfile (str, target) </span>
Targe incoming is the way of encryption, SHA1 and MD5 are common ways. <br> below give a concrete example:<br> the first step: write the following code in the background of the Web page:
Copy Code code as follows:
<span style= "FONT-SIZE:16PX; Color: #000000; > String str = this.tbPwd.Text;
String str1 = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile (str, "SHA1");
String str2 = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile (str, "MD5");
This.lbName.Text = "SHA1 encrypted password:" + str1 + "<br/> SHA1 encryption length is:" + str1. Length + "<br/><br/>" + "MD5 encrypted password:" + str2 + "<BR/>MD5 encryption lengths are:" + str2. Length;
</span>
Part II: Refreshes the Web page as shown in the following illustration:
An empty string is encrypted even if it is empty and nothing is entered
Third Step: Enter a string: 123456, the result of clicking the button is as follows:
As can be seen from the above, SHA1 and MD5 have a great effect on the protection of data in concrete actual projects.