ASP.NET中使用MD5和SHA1算法加密
来源:互联网 发布:newblue mac 编辑:程序博客网 时间:2024/06/01 07:15
.NET SDK中提供了CookieAuthentication类,其中的HashPasswordForStoringInConfigFile方法可直接使用MD5和SHA1算法。例子如下:
file: encrypting.aspx
<%@ Page language="c#" Codebehind="encrypting.cs" AutoEventWireup="false" Inherits="encrypting.encrypting" %>
<html><head>
<meta name="GENERATOR" Content="Microsoft Visual Studio 7.0">
<meta name="CODE_LANGUAGE" Content="C#"></head>
<body>
<form method="post" runat="server">
<asp:TextBox id=TextBox1 runat="server"></asp:TextBox>
<asp:Button id=Button1 runat="server" Text="encrypting"></asp:Button>
Encrypting Password(MD5):
<asp:Label id=MD5 runat="server"></asp:Label>
</form>
</body></html>
file:encrypting.cs
namespace encrypting
{
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Web.Security;
/// <summary>
/// Summary description for encrypting.
/// </summary>
public class encrypting : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label MD5;
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.TextBox TextBox1;
public encrypting()
{
Page.Init += new System.EventHandler(Page_Init);
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
//
// Evals true first time browser hits the page
//
}
}
protected void Page_Init(object sender, EventArgs e)
{
//
// CODEGEN: This call is required by the ASP+ Windows Form Designer.
//
InitializeComponent();
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
Button1.Click += new System.EventHandler (this.Button1_Click);
this.Load += new System.EventHandler (this.Page_Load);
}
public void Button1_Click (object sender, System.EventArgs e)
{
MD5.Text = CookieAuthentication.HashPasswordForStoringInConfigFile(TextBox1.Text,"MD5");
//SHA1 use CookieAuthentication.HashPasswordForStoringInConfigFile(TextBox1.Text,"SHA1");
}
}
}
- ASP.NET中使用MD5和SHA1算法加密
- ASP.NET中使用MD5和SHA1算法加密
- ASP.NET中使用MD5和SHA1算法加密
- ASP.NET中使用MD5和SHA1算法加密
- ASP.NET中使用MD5和SHA1算法加密
- ASP.NET中使用MD5和SHA1算法加密
- ASP.NET中密码保护,MD5和SHA1算法的使用
- ASP.NET中密码保护,MD5和SHA1算法的使用
- ASP.NET中密码保护,MD5和SHA1算法的使用
- ASP.NET中密码保护,MD5和SHA1算法的使用
- ASP.NET中密码保护,MD5和SHA1算法的使用
- ASP.NET中密码保护,MD5和SHA1算法的使用
- ASP.NET with C#使用md5,sha1加密初探
- ASP.Net中MD5和SHA1加密的几种方法
- ASP.Net中MD5和SHA1加密的几种方法
- ASP.NET中MD5和SHA1加密的几种方法
- ASP.NET中MD5和SHA1加密的几种方法
- ASP.NET中MD5和SHA1加密的几种方法
- 驱动模块及其用户空间的调用
- 简单的使用.NET非对称加密算法的例子
- MySQL的的主要特性
- javascript方向键(上下键)控制表格行选中并高亮显示
- 消息积累-CSDN问题整理,以备自己日后查询
- ASP.NET中使用MD5和SHA1算法加密
- 开博贴
- Spark部分流程说明
- Serv-U简单设置
- Sql Server2005报出奇怪异常
- 利用Java实现网页浏览器
- 状态机
- 网络操作系统和“鲜果在线”
- 简单数据库操作类