我目前有一个 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