ASP.net中md5加密码的方法
来源:互联网 发布:淘宝新店开张宣传语 编辑:程序博客网 时间:2024/06/13 05:33
<%@ 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>
本文来自: 脚本之家(www.jb51.net) 详细出处参考:http://www.jb51.net/article/368.htm
- ASP.net中md5加密码的方法
- ASP.net中md5加密码的方法(转贴)
- ASP.net中md5加密码的方法
- ASP.net中md5加密码的方法
- ASP.net中md5加密码的方法
- ASP.net中md5加密码的方法
- ASP.net中md5加密码的方法
- ASP.net中md5加密密码的方法
- ASP.net中md5加密密码的方法
- ASP.net中md5加密的方法
- ASP.net中md5加密的方法 .
- asp.net中md5加密的方法
- ASP.NET中MD5和SHA1的几种方法
- 为什么要在MD5加密的密码中加“盐”
- asp.net中关于MD5的加密
- ASP.NET下用MD5加密密码
- asp.net 密码加密 MD5 加密
- ASP.NET下实现密码MD5加密
- ATL的GUI程序设计(2)
- ATL的GUI程序设计(3)
- asp.net WebForm页面间传值方法
- CGlib简单介绍
- ATL的GUI程序设计(4)
- ASP.net中md5加密码的方法
- 【升级4G XP认】XP下玩转4GB内存
- asp.net页面包含的处理
- 在线安装VisualSVN Server 1.7.1与Trac
- ZOJ 1711 Sum It Up
- 几个C#常用正则表达式的总结
- 国内第一本Django图书《Django Web开发指南》
- chmod命令详细用法
- ASP.NET 数据访问类