【问题标题】:md5 encryption node js and magento not matching..md5加密节点js和magento不匹配..
【发布时间】:2015-12-02 12:00:31
【问题描述】:

我在 magento 和 node js 中都创建了登录服务。在 magento 中,如果客户使用密码注册,则密码使用 md5 salt key 值加密。 如果我使用加密节点 js 模块来解密 magento 密码,则会引发错误。

Error: Unknown cipher
    at Error (native)
    at new Decipher (crypto.js:210:16)
    at Object.Decipher (crypto.js:207:12)
    at D:\Workspace\mobileapp\routes\users.js:30:24
    at Layer.handle [as handle_request] (D:\Workspace\mobileapp\node_modules\express\lib\router\layer.js:95:5)
    at trim_prefix (D:\Workspace\mobileapp\node_modules\express\lib\router\index.js:312:13)
    at D:\Workspace\mobileapp\node_modules\express\lib\router\index.js:280:7
    at param (D:\Workspace\mobileapp\node_modules\express\lib\router\index.js:349:14)

只有当我解密 magento 密码时,我才能验证我的登录密码匹配并且我可以继续。我试图加密我的节点 js 登录密码,但密码不匹配..

【问题讨论】:

  • 您无法解密哈希。 MD5 是一种单向函数。但这并不安全。您需要使用强密码散列,如 scrypt、bcrypt 和 PBKDF2。由于散列函数是单向函数,因此您将无法“解密”散列。为了验证您的用户,您可以再次通过散列函数运行密码,以便与存储在数据库中的散列进行比较。查看更多:How to securely hash passwords?
  • 无论如何,如果你的代码有问题,那么你需要展示它。

标签: javascript php node.js magento encryption


【解决方案1】:

在magento中,如果客户使用密码注册,密码使用md5 salt key值加密。

这里有很多东西要解压。

  1. Magento 应该使用 bcrypt,而不是 MD5。
  2. MD5 不是加密。
  3. 什么是“盐键值”?

如果我使用加密节点 js 模块来解密 magento 密码,则会抛出错误。

你不能解密 MD5,因为 MD5 不是加密。

MD5 是一个散列函数。哈希函数不是加密。

哈希函数是加密的!但并不是所有的加密算法都是加密的。

Read this to understand the difference.

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多