【问题标题】:Zendcart - Merging existing userdatabase with zendcart databaseZendcart - 将现有的用户数据库与 zendcart 数据库合并
【发布时间】:2015-09-16 10:57:30
【问题描述】:

我刚刚在我的系统上安装了 zendcart,我尝试将我已经拥有的站点的用户数据库与 zendcart 数据库合并。

我已经成功地正确移植了所有内容,只是密码似乎不起作用。 我自己的系统 md5 在密码进入数据库时​​对其进行哈希处理,我不知道 zencart 如何对其密码进行哈希处理,但据我所知,它与我目前使用的算法几乎相同,仅附加了 3 个字符。

ex current password: sad97213sd123js123
ex zendcart pass: sad97213sd123js123:c1

我如何重新调整我的密码以匹配 zendcarts 标准,或者.. 我如何编辑 zendcart 以接受由 zendcart 以外的其他方式生成的加盐密码

谢谢你

【问题讨论】:

  • 两个zendcart版本一样吗?
  • 我很抱歉造成混乱,只有一个系统是 zencart,另一个是自定义 CMS
  • 我相信“zendcart”是指“Zen Cart”。

标签: php hash md5


【解决方案1】:

class.zcPassword.php (/includes/classes) 中,你会发现它:

  /**
   * Determine the password type
   *
   * Legacy passwords were hash:salt with a salt of length 2
   * php < 5.3.7 updated passwords are hash:salt with salt of length > 2
   * php >= 5.3.7 passwords are BMCF format

它使用ircmaxell/password-compat 库描述了它在决定如何处理密码之前所做的传统比较,就在这里:

  function detectPasswordType($encryptedPassword)
  {
    $type = 'unknown';
    $tmp = explode(':', $encryptedPassword); // try to break the hash in an array of 2 elements at :, first being the hash, second a suffix
    if (count($tmp) == 2) { // if it breaks...
      if (strlen($tmp [1]) > 2) { //...then check if 2nd has a length > 2...
        $type = 'compatSha256'; //...if it does, it's SHA2
      } elseif (strlen($tmp [1]) == 2) {//...if not, make sure it's == 2...
        $type = 'oldMd5';// ...just to confirm it's MD5
      }
    }
    return $type; // and return the string to be treated ahead
  }

编辑//commented the code.

如您所见,:c1 只是盐后缀(当他找到它时,他是 explodes)它读取以根据 PHP 版本定义应该运行哪种算法以保持向后兼容性(在您的情况下为 MD5) ,这就是哈希值相同的原因。

我建议您只需删除 : 处所有密码末尾的后缀,或者使用该函数及其依赖项来忽略此检查。

【讨论】:

  • 您建议仅从密码中删除 :c1 也可以吗?
  • @Sjef92 如果您的新系统没有运行 Zen Cart 运行以验证旧哈希的相同功能,那么可以。后缀不会给您带来任何问题。如果您对实现它有任何疑问,只需将数据库转储到备份文件中即可!但我很确定。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2020-03-22
  • 2016-09-12
  • 1970-01-01
  • 2014-05-15
  • 2015-08-30
  • 1970-01-01
  • 2011-01-22
相关资源
最近更新 更多