All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
delphi映像内存的操作
《Effective,C#》:区别四个判等函数_.net资料_编程技术
Sqlserver如何创建语言辅助函数_[SQL,Server教程]
如何利用PHP和CSS改变网页文字大小_php资料_编程技术
ADO.NET概述
几个比较有用的正则表达式_[PHP教程]
XMLHTTP 对象及其方法简介_[XML教程]
组合ASP.NET,2.0数据控件构建强大用户接口_[Asp.Net教程]
将内容自动添加到指定文本域的JS_[Html教程]
Silverlight,2(beta1)数据操作(1)——使用ASP.NET,Web,Service_[Asp.Net教程]
Reading number is top 10 pictures
Black and white also sexy--YanLiu2
So beauty, will let you spray blood1
男人帮杂志里的惹火性感美女1
传销的好处
China telecom 114 spokesman MeiYanXu1
南昌铁路局攸县车站125户铁路职工微利房终成骗局
分手的感悟
A beautiful girl to bud1
Tie a large font of mouse
So beauty, will let you spray blood8
Download software ranking
Unix video tutorial17
The cock of the Grosvenor LTD handsome
dreamweaver8中文版
功夫熊猫2(上集)
apache-tomcat-6.0.33
天龙八部最新服务端
Tram sex maniac 2 (H) rar bag18
Popkart Cracked versions Mobile phone games
美女写真3
株洲本地在线棋牌游戏
归海一刀 published in(发表于) 2014/1/30 1:57:08 Edit(编辑)
用ASP.NET加密口令的程序_[Asp.Net教程]

用ASP.NET加密口令的程序_[Asp.Net教程]

用ASP.NET加密口令的程序_[Asp.Net教程]

















给大家提供一个简单实用,但是老套的方法,就是口令加密。在此我们使用ASP.NET技术对口令加密。简单的讲,就是将用户提供的口令加密之后,然后让它和存放于系统中的数据比较,如果相同,则通过验证。
在ASP中,并未提供加密的对象,我们只能使用外部的对象来进行加密。现在好了,在ASP.NET中提供了加密的解决方法。在名字空间
System.Web.Security中包含了类FormsAuthentication,其中有一个方法HashPasswordForStoringInConfigFile。这个方法可以将用户提供
的字符变成乱码,然后存储起来,甚至可以 存储在cookies中。
HashPasswordForStoringInConfigFile方法使用起来很简单,它支持"SHA1"和"MD5"加密算法。
下面的代码简单的演示了关于其用法:
<%@ Page language="c#" %>
<%@ Import Namespace="System.Web.Security" %>







Original Clear Text Password:



ID="Button1" />



Encrypted Password In SHA1:



Encrypted Password In MD5:








正如你所看到的这样简单易用。我们可以把这段加密程序封装在一个函数里便于重复的使用。代码如下:
public string EncryptPassword(string
PasswordString,string PasswordFormat )
{
if (PasswordFormat="SHA1"){

EncryptPassword=FormsAuthortication.HashPasswordForStoringIn
ConfigFile(PasswordString ,"SHA1");
}
elseif (PasswordFormat="MD5")
{
EncryptPassword=FormsAuthortication.HashPasswordForStoringIn
ConfigFile(PasswordString ,"MD5");
}
else
{
EncryptPassword="";
}

我们可以在数据库中添加一个字段,使用insert将加密的口令作为一个string存入数据库中。当用户登陆的时候,就可以将用户输入的口令加密结果和数据库中的正确结果比较,通过这种办法来验证口令的正确性了。




























添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.