【问题标题】:vbscript that converts into hash and compares it to another hash转换为哈希并将其与另一个哈希进行比较的 vbscript
【发布时间】: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


【解决方案1】:

Mysql 有它自己的 sha1 函数(和其他加密),所以你可以做类似“SELECT permission FROM customers WHERE sha1(key) = sha1('"&entered_key&"')”的事情 见http://dev.mysql.com/doc/refman/5.5/en/encryption-functions.html#function_sha1 所以你的 vba 本身不需要 sha 算法。

如果你真的想要,你可以使用 vba/vbscript sha 算法,如果你在周围搜索,你会找到几个,例如这个http://bytes.com/topic/access/insights/906938-sha2-cryptographic-hash-algorithm-vba-vbscript

【讨论】:

  • 谢谢彼得...第二个链接正是我要找的。​​span>
猜你喜欢
  • 1970-01-01
  • 2012-03-24
  • 2019-02-03
  • 1970-01-01
  • 1970-01-01
  • 2016-10-25
  • 2012-08-14
  • 2019-03-26
  • 1970-01-01
相关资源
最近更新 更多