.NET中带有口令加密的注册页面(还是发表在这里吧~-~)
来源:互联网 发布:软件架构师认证 编辑:程序博客网 时间:2024/05/23 12:00
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
下面的代码就是在做注册页面时将数据加密后存储到数据库的过程
Imports System.Web.Security
Imports System.Data
Imports System.Data.SqlClient '////////所需要的名称空间
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim PassFormate As String
'///////////////EncryptPassword调用函数
PassFormate = EncryptPassword(uid.Text, "md5") '//////////或者是EncryptPassword(uid.Text, "sha1")
'TextBox2.Text = EncryptPassword(uid.Text, "md5")
'TextBox3.Text = EncryptPassword(uid.Text, "sha1")
'///////////这些大家自己试验吧
'TextBox4.Text = FormsAuthentication.FormsCookieName
'TextBox5.Text = FormsAuthentication.FormsCookiePath
'TextBox6.Text = FormsAuthentication.GetRedirectUrl(uid.Text, True)
'FormsAuthentication.SetAuthCookie(uid.Text, True)
Dim sql As String = "insert into pwd(uid,pwd) values(@uid,@pwd)"
Dim comm As SqlCommand = New SqlCommand(sql, conn)
conn.Open()
comm.Parameters.Add(New SqlParameter("@uid", SqlDbType.Char, 16))
comm.Parameters("@uid").Value = uid.Text
comm.Parameters.Add(New SqlParameter("@pwd", SqlDbType.Char, 16))
comm.Parameters("@pwd").Value = PassFormate
comm.ExecuteNonQuery()
End Sub
'////////////////定义加密函数,可以随时调用。
Function EncryptPassword(ByVal password As String, ByVal passwordformate As String)
If passwordformate = "sha1" Then
EncryptPassword = FormsAuthentication.HashPasswordForStoringInConfigFile(password, "sha1")
ElseIf passwordformate = "md5" Then
EncryptPassword = FormsAuthentication.HashPasswordForStoringInConfigFile(password, "md5")
Else
EncryptPassword = ""
End If
End Function
至于用户的验证也是一样
NET中带有口令加密的注册页面(还是发表在这里吧~-~)';return true">
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
在ASP.NET中提供了加密的功能。名字空间System.Web.Security中包含了类FormsAuthentication,其中有一个方法HashPasswordForStoringInConfigFile。这个方法可以将用户提供的字符变成乱码,然后存储起来。注意此方法是不能继承的。下面的代码就是在做注册页面时将数据加密后存储到数据库的过程
Imports System.Web.Security
Imports System.Data
Imports System.Data.SqlClient '////////所需要的名称空间
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim PassFormate As String
'///////////////EncryptPassword调用函数
PassFormate = EncryptPassword(uid.Text, "md5") '//////////或者是EncryptPassword(uid.Text, "sha1")
'TextBox2.Text = EncryptPassword(uid.Text, "md5")
'TextBox3.Text = EncryptPassword(uid.Text, "sha1")
'///////////这些大家自己试验吧
'TextBox4.Text = FormsAuthentication.FormsCookieName
'TextBox5.Text = FormsAuthentication.FormsCookiePath
'TextBox6.Text = FormsAuthentication.GetRedirectUrl(uid.Text, True)
'FormsAuthentication.SetAuthCookie(uid.Text, True)
Dim sql As String = "insert into pwd(uid,pwd) values(@uid,@pwd)"
Dim comm As SqlCommand = New SqlCommand(sql, conn)
conn.Open()
comm.Parameters.Add(New SqlParameter("@uid", SqlDbType.Char, 16))
comm.Parameters("@uid").Value = uid.Text
comm.Parameters.Add(New SqlParameter("@pwd", SqlDbType.Char, 16))
comm.Parameters("@pwd").Value = PassFormate
comm.ExecuteNonQuery()
End Sub
'////////////////定义加密函数,可以随时调用。
Function EncryptPassword(ByVal password As String, ByVal passwordformate As String)
If passwordformate = "sha1" Then
EncryptPassword = FormsAuthentication.HashPasswordForStoringInConfigFile(password, "sha1")
ElseIf passwordformate = "md5" Then
EncryptPassword = FormsAuthentication.HashPasswordForStoringInConfigFile(password, "md5")
Else
EncryptPassword = ""
End If
End Function
至于用户的验证也是一样
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
- .NET中带有口令加密的注册页面(还是发表在这里吧~-~)
- .NET中带有口令加密的注册页面
- 带有口令加密的注册页面
- 在Tomcat7的配置文件中加密管理员口令
- 在ASP.NET中加密页面机制
- ASP.NET 加密口令
- 还是在这里写吧
- 还是在这里写吧
- 还是选择在这里吧
- 使用 ASP.NET 加密口令
- 使用 ASP.NET 加密口令
- 使用 ASP.NET 加密口令
- 使用 ASP.NET 加密口令
- 使用ASP.NET加密口令
- 使用ASP.NET加密口令
- 使用ASP.NET加密口令
- 使用asp.net加密口令
- 使用ASP.NET加密口令
- WINDOWS2000服务器账号登陆身份验证
- PHP新手上路:2.PHP入门
- PHP新手上路:1.PHP简介
- 通过自定义类来达到向aspx页面加入脚本代码的例子
- IIS下安装PHP4及MySQL
- .NET中带有口令加密的注册页面(还是发表在这里吧~-~)
- PHP.MVC的模板标签系统(五)
- SUNWEN教程之----C#进阶7
- Win2000安装Apache+PHP4+MySQL
- .NET中带有口令加密的注册页面
- PHP.MVC的模板标签系统(三)
- Application事件的执行顺序
- PHP.MVC的模板标签系统(四)
- 用Visual C#调用Windows API函数(转)