【发布时间】:2012-08-18 07:04:49
【问题描述】:
我目前有一个 MySQL 数据库,其中存储用于登录的用户名和密码等。我有一个 MS Access 2010 前端,我构建了一个登录屏幕,询问用户密码和名称,并将其与 MySQL 用户名和密码进行比较,如果它们匹配,它将打开另一个 MS Access 表单。我现在想将密码存储在 MySQL 数据库中的哈希 sha1 中,但我不知道如何编写我的 vbscript,以便它将用户在 MS Access 表单中输入的密码转换为哈希 sha1 和将其与该特定用户的 MySQL 数据库中已有的内容进行比较。我已经包含了我不使用哈希时使用的 vbscript。任何帮助将不胜感激。
'compares username and password to a query and will either open another form OR display an incorrect password message.
Dim dbs As Database
Dim rstUserPwd As Recordset
Dim bFoundMatch As Boolean
Set dbs = CurrentDb
'query that has all the usernames and password
Set rstUserPwd = dbs.OpenRecordset("qryUserPwd")
bFoundMatch = False
If rstUserPwd.RecordCount > 0 Then
rstUserPwd.MoveFirst
'name of the access form is called 'Login'
Do While rstUserPwd.EOF = False
If rstUserPwd![UserName] = Form_Login.txtusername.Value And rstUserPwd![Password] = Form_Login.txtpassword.Value Then
bFoundMatch = True
Exit Do
End If
rstUserPwd.MoveNext
Loop
End If
'open admin form
If bFoundMatch = True
DoCmd.Close acForm, Me.Name
DoCmd.OpenForm "admin"
Else
MsgBox "Incorrect User Name or Password"
End If
【问题讨论】:
-
标签错误,将 vbscript 替换为 vba ,先在 [sha] [mysql] 上搜索,已经回答了很多问题
-
感谢您的回复。我在 [sha] [mysql] 上进行了搜索,但没有找到答案。大多数帖子都与php有关。我没有找到vba的答案。我对编程很陌生,所以我不确定如何使用 php 答案来帮助解决我的 vba 问题。你知道可以回答这个问题的确切标签或链接吗?
标签: mysql vba ms-access-2010