_articlecontent1_lblcontent><%@ 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>
Java Asp PHP .Net XML C/C++ CGI VB Jsp J2ee J2se J2me EJB Servlet Tomcat Resin Struts Weblogic Eclipse ANT GUI JMS Web servise IDEA Webphere Hibernate Spring Jboss Applet Swing Socket Javamail Perl Ajax P2P 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器