The method of MD5 password in asp.net

Source: Internet
Author: User
Tags md5 sha1 encryption tostring
asp.net| encryption <%@ Page language= "C #" contenttype= "text/html"%>
<%@ Import namespace= "System"%>
<script language= "C #" runat= "Server" >
void Page_Load (Object Sender,eventargs e) {
Get the field to encrypt and convert to byte[] Array
Byte[] Data=system.text.encoding.unicode.getbytes (source. Text.tochararray ());
Establish Cryptographic Services
System.Security.Cryptography.MD5 MD5 = new System.Security.Cryptography.MD5CryptoServiceProvider ();
Encrypted byte[] Array
Byte[] result= md5.computehash (data);
Converts an encrypted array into a field
String sresult=system.text.encoding.unicode.getstring (Result);
Show it
Sha1_1.text= "MD5 General Encryption:" +sresult.tostring () + "<br/>";
Encrypt as password
String Enpswdstr=system.web.security.formsauthentication.hashpasswordforstoringinconfigfile (source. Text.tostring (), "MD5");
Show it
sha1_2.text= "MD5 Password encryption:" +enpswdstr+ "<br/>";
}
</script>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<title> Testing </title>
<body>
&LT;H3&GT;SHA1 Encryption <form runat= "Server" >
<asp:label id= "sha1_1" runat= "Server" ></asp:label>
<asp:label id= "sha1_2" runat= "Server" ></asp:label>
<asp:textbox id= "source" runat= "Server" textmode= "Singleline" text= "Test" autopostback= "true"/>
Car
</form>
</body>



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.