欢迎您访问我爱IT技术网,今天小编为你分享的编程技术是:【ASP.net中md5加密码的方法】,下面是详细的讲解!
ASP.net中md5加密码的方法
<%@ 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加密码的方法的用户互动如下:
相关问题:在ASP.NET中MD5加密怎么用?
答://使用前需导入以下命名空间:using System.Web.Security; 散列码加密有SHA1和MD5两种,第二个参数可任选一种 string "加密后" = FormsAuthentication.HashPasswordForStoringInConfigFile("原码" ,"MD5"); >>详细
相关问题:asp.net 中的MD5和SHA1加密
答:不用导入 直接string xxx =System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(要转换的字符串,"MD5"); 就可以了 。。 >>详细
相关问题:asp.net(c#)中,md5加密代码
答:string strMd5 = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile("123", "md5"); strMd5 就是 123 经过 MD5 加密后的结果 >>详细
- 【asp】asp.net url重写浅谈-net-url重写
- 【DataSet】DataSet、DataTable、DataRow区别详解
- 【asp】asp.net 动态添加多个用户控件-net-动态添
- 【ASP】ASP.NET中内嵌页面代码的一个问题-NET-内
- 【创建】ASP.NET Web API教程 创建域模型的方法详
- 【Asp】Asp.net 页面调用javascript变量的值-net-
- 【ASP】ASP.NET 5升级后如何删除旧版本的DNX-NET5
- 【404页面】ASP.NET设置404页面返回302HTTP状态码
- 【asp】asp.net开发中常见公共捕获异常方式总结(
- 【Visual】分享Visual Studio原生开发的10个调试
- 评论列表(网友评论仅供网友表达个人看法,并不表明本站同意其观点或证实其描述)
-
