All articles(网络文学目录) All Pictures(图片目录) All Softwares(软件目录)

 
利用MD5加密数据库中的密码_[Asp.Net教程]

Writer: delv Article type: Programming skills(编程技巧) Time: 2014/1/16 9:31:15 Browse times: 329 Comment times: 0

利用MD5加密数据库中的密码_[Asp.Net教程]


Head photo

Go homepage
Upload pictures
Write articles

利用MD5加密数据库中的密码_[Asp.Net教程]























.NET提供了进行数据加密类,下面就用例子进行说明如何使用MD5进行数据加密。




首先,创建一个UserAccount表,字段两个:UserName和Password,类型分别为varchar(25)和binary(16),下面的ASP.NET代码就是创建用户时的具体实现:




<%@ Import Namespace="System.Security.Cryptography" %>
<%@ Import Namespace="System.Text" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>





创建帐号:


用户名:


密码:

onClick="CreateAccount"/>



下面是对用户进行验证的ASP.NET代码:





<%@ Import Namespace="System.Security.Cryptography" %>
<%@ Import Namespace="System.Text" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>





登录:


用户名:

密 码:

onClick="Login"/>

下面是MD5CryptoServiceProvider直接生成的例子:
<%@ Import Namespace="System.Security.Cryptography" %>
<%@ Import Namespace="System.Text" %>





Enter a string:

Display="Dynamic" ErrorMessage="You must provide a value here..." />
Display="Dynamic" ErrorMessage="The string must be 20 characters or less..."
ValidationExpression="^.{1,20}" />


onClick="DisplayEncryptedText" />






来源:孟宪会之精彩世界















































There are 0 records,
Comment:
Must be registered users to comment(必须是注册用户才能发表评论)

Disclaimer Privacy Policy About us Site Map
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.