您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

ASP.net中md5加密码的方法

2024/7/13 14:50:47发布18次查看
<%@ page language="c#" contenttype="text/html"%> <%@ import namespace="system"%> <script language="c#" runat="server"> void page_load(object sender,eventargs e){ //获取要加密的字段,并转化为byte[]数组 byte[] data=system.text.encoding.unicode.getbytes(source.text.tochararray()); //建立加密服务 system.security.cryptography.md5 md5 = new system.security.cryptography.md5cryptoserviceprovider(); //加密byte[]数组 byte[] result= md5.computehash(data); //将加密后的数组转化为字段 string sresult=system.text.encoding.unicode.getstring(result); //显示出来 sha1_1.text="md5普通加密:"+sresult.tostring()+"<br/>"; //作为密码方式加密 string enpswdstr=system.web.security.formsauthentication.hashpasswordforstoringinconfigfile(source.text.tostring(),"md5"); //显示出来 sha1_2.text="md5密码加密:"+enpswdstr+"<br/>"; } </script> <html> <head> <meta http-equiv="content-type" content="text/html; charset=gb2312"> <title>测试</title> </head> <body> <h3>sha1加密</h3> <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" /> (回车) </form> </body> </html>
以上就是asp.net中md5加密码的方法的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product