【问题标题】:md5 and salt on a column in MSAccess tableMS Access 表中列上的 md5 和 salt
【发布时间】:2013-07-30 22:53:50
【问题描述】:

我是否可以运行更新查询以将一列纯文本存储密码更改为在 msaccess 中 md5+salt'ed 的列?

我试过了:

UPDATE TableName
SET Pass = CONCAT(MD5(CONCAT('salt', Pass)), ':salt');

但是当然它没有用,如果我把表名放在前面,比如:users.Pass,然后它会要求一个文件,如果我不它它告诉我访问找不到输入表.还有就是没有 CONCAT 函数,我完全看不懂。

我正在尝试将访问数据库转换为 mysql 数据库以将客户导入到 magento 安装中,并且没有很多访问经验。谢谢。

【问题讨论】:

  • MS 语言使用 + 而不是 concat 函数或 SQL 标准 ||
  • 我建议使用与 MD5 不同的散列函数,因为它很容易受到攻击。即使您要保护的数据微不足道,用户也倾向于为他们使用真实密码。 security.stackexchange.com 是了解一些基础知识的良好起点。
  • @ashareef - 但 magento 使用 md5+salt,我认为我无法在导入期间更改它
  • @FrankPl - 所以用 + 替换 concat?我会试试看。嗯不工作,也许我只是将纯文本传输到 mysql db 并以这种方式运行它
  • @Salty - 是的。但是我认为Access也没有MD5。如果您在 Access SQL 中需要它,您将不得不在 VBA 中以某种方式实现它。

标签: mysql magento ms-access


【解决方案1】:

我建议创建一个循环遍历所有记录并为每条记录设置 Pass 的 DAO 循环。您必须为 VBA 编写一个 MD5 散列函数或找到一个,或者如前所述,使用 SHA1。

Access 和 Access/Jet/DAO SQL 中的连接是使用与号或加号完成的。

这是一个使用 SHA1 对字符串进行哈希处理的函数。它返回一个 40 个字符的十六进制字符串。我不确定这是否与 Magento 散列算法兼容。

Public Function SHA1Hex(S As String) As String
    Dim asc, enc, bytes, outstr, pos
    'Borrow some objects from .NET (supported from 1.1 onwards)
    Set asc = CreateObject("System.Text.UTF8Encoding")
    Set enc = CreateObject("System.Security.Cryptography.SHA1CryptoServiceProvider")
    'Convert the string to a byte array and hash it
    bytes = asc.GetBytes_4(S)
    bytes = enc.ComputeHash_2((bytes))
    outstr = ""
    'Convert the byte array to a hex string
    For pos = 1 To LenB(bytes)
        outstr = outstr & LCase(Right("0" & Hex(AscB(MidB(bytes, pos, 1))), 2))
    Next
    SHA1Hex = outstr 'Returns a 40 byte/character hex string
    Set asc = Nothing
    Set enc = Nothing

End Function

DAO 循环的代码可以在 SO 上找到: Code to loop through all records in MS Access

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-11-09
    • 2012-04-19
    • 1970-01-01
    • 2021-05-20
    • 2012-04-10
    • 2014-08-01
    • 2010-12-14
    相关资源
    最近更新 更多