成人午夜激情影院,小视频免费在线观看,国产精品夜夜嗨,欧美日韩精品一区二区在线播放

ASP.net中md5加密碼的方法

2010-08-28 10:46:40來源:西部e網(wǎng)作者:

_ArticleContent1_lblContent><%@ Page Language="C#" ContentType="text/html"%>
<%@ Import Namespace="System"%>
<script language="C#" runat="server">
void Page_Load(Object sender,EventArgs e){
//獲取要加密的字段,并轉(zhuǎn)化為Byte[]數(shù)組
byte[] data=System.Text.Encoding.Unicode.GetBytes(source.Text.ToCharArray());
//建立加密服務(wù)
System.Security.Cryptography.MD5 md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
//加密Byte[]數(shù)組
byte[] result= md5.ComputeHash(data);
//將加密后的數(shù)組轉(zhuǎn)化為字段
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> 
關(guān)鍵詞:ASP.net

贊助商鏈接:

主站蜘蛛池模板: 洛扎县| 南安市| 沙田区| 昌黎县| 湟中县| 天峨县| 广昌县| 辉县市| 稻城县| 清新县| 恩平市| 咸丰县| 中西区| 苏尼特右旗| 阿城市| 明星| 新兴县| 闸北区| 吉隆县| 福州市| 永德县| 安吉县| 揭西县| 浦东新区| 庆阳市| 星座| 桦南县| 吉首市| 大渡口区| 吴忠市| 安多县| 博罗县| 巴塘县| 渝北区| 东阳市| 天水市| 安溪县| 巴中市| 白水县| 濉溪县| 鱼台县|