我刚刚在我的系统上安装了zendcart,我尝试将我已经拥有的站点的用户数据库与zendcart数据库合并.
我已设法正确移植所有内容,只有密码似乎不起作用.我自己的系统md5在进入数据库时对密码进行哈希处理,我不知道zencart是如何哈希密码的,但据我所知,它与我目前只使用3个字符连接的算法几乎相同.
ex current password: sad97213sd123js123
ex zendcart pass: sad97213sd123js123:c1
Run Code Online (Sandbox Code Playgroud)
如何重新设置我的密码以匹配zendcarts标准,或者..如何编辑zendcart以接受通过除zendcart之外的其他方式生成的盐渍密码
先谢谢你
在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
Run Code Online (Sandbox Code Playgroud)
它描述了在决定如何处理密码之前使用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
}
Run Code Online (Sandbox Code Playgroud)
编辑://commented the code.
正如你所看到的,:c1只是盐后缀(explodes当他找到它时)它读取来定义它应该运行哪个算法来根据 PHP 版本保持向后兼容性(在你的例子中,MD5),这就是哈希值相同的原因。
我建议您删除所有密码末尾的后缀:,或者处理该函数及其依赖项以忽略此检查。