Encryption 从Prestashop 1.6 MD5加密更新到1.7

Encryption 从Prestashop 1.6 MD5加密更新到1.7,encryption,prestashop,prestashop-1.6,password-encryption,prestashop-1.7,Encryption,Prestashop,Prestashop 1.6,Password Encryption,Prestashop 1.7,我正在将PS 1.6更新为1.7。我知道PS1.6使用了这种加密方法md5(\u COOKIE\u KEY.$passwd),但我们之前将其转换为md5($passwd),以便与我们以前的商店兼容,而不是与prestashop兼容 现在我们想更新到1.7,我们看到加密方法已更改为hash()。我们已经实现了登录以前更改此功能的用户:getByEmail(),但现在我们希望注册工作正常(将密码保存为md5($plaintextpassword))。我们知道新的加密方法更加安全,不建议使用md5($

我正在将PS 1.6更新为1.7。我知道PS1.6使用了这种加密方法
md5(\u COOKIE\u KEY.$passwd)
,但我们之前将其转换为
md5($passwd)
,以便与我们以前的商店兼容,而不是与prestashop兼容

现在我们想更新到1.7,我们看到加密方法已更改为hash()。我们已经实现了登录以前更改此功能的用户:
getByEmail()
,但现在我们希望注册工作正常(将密码保存为
md5($plaintextpassword)
)。我们知道新的加密方法更加安全,不建议使用
md5($plaintextpassword)
,但现在我们无法改变这一点

我们在Classes/Customer.php中更改了以下所有行:

$this->passwd = $crypto->hash($password);
致:


但是当我们注册一个新用户时,所有这些更改都以$2y$10$VPm9ygay2ldd0Vu0J4ttQuOdD/mIytURV/nXCXKs4GcB4AkIWtaQm格式保存为hash()方法,而不是bcef5cfa6F4BB0Abb94CF6FA7A7CB2F。我找不到需要更改以所需格式保存的位置?

您必须覆盖PrestaShop并添加新的附加密码检查器:

if(!loginWithOriginalMethod($password)) {
    loginWithAdditionalMethod($password);
}

通过使用这种方式,您的新老客户都可以登录您的店铺

您必须覆盖PrestaShop并添加新的额外密码检查器:

if(!loginWithOriginalMethod($password)) {
    loginWithAdditionalMethod($password);
}

通过使用这种方式,您的新客户和老客户都可以登录到您的商店

如果您可以直接在数据库中导入以前的1.6哈希,并且保留相同的cookie密钥,则该函数是向后兼容的

但是,如果像我一样,在我使用csv功能导入时,1.6哈希已使用新的cookie密钥重新哈希,则需要更新src/Core/Crypto/Hashing.php,将最后一个函数替换为:

确保替换为Prestashop 1.6中的cookie密钥

private function initHashMethods()
    {
        $this->hashMethods = array(
            'bcrypt' => array(
                'option' => array(),
                'hash' => function ($passwd, $staticSalt, $option) {
                    return password_hash($passwd, PASSWORD_BCRYPT);
                },
                'verify' => function ($passwd, $hash, $staticSalt) {
                    /*
                     * Prevent enumeration because nothing happens
                     * when there is no, or an invalid hash.
                     * Also, change the password to be sure it's not maching
                     * the new hash.
                     * The new hash is equal to 'test' in BCRYPT context.
                     */
                    if (empty($hash)) {
                        $hash = '$2y$10$azRqq.pN0OlWjeVfVMZXOOwqYAx1hMfme6ZnDV.27grGOEZvG.uAO';
                        $passwd = 'wrongPassword';
                    }

                    return password_verify($passwd, $hash);
                },
            ),
            'md5' => array(
                'option' => array(),
                'hash' => function ($passwd, $staticSalt, $option) {
                    return md5($staticSalt . $passwd);
                },
                'verify' => function ($passwd, $hash, $staticSalt) {
                    return md5($staticSalt . $passwd) === $hash;
                },
            ),
            'bcryptmd5' => array(
                'option' => array(),
                'hash' => function ($passwd, $staticSalt, $option) {
                    return password_hash(md5('<your 1.6 cookie key>' . $passwd), PASSWORD_BCRYPT);
                },
                'verify' => function ($passwd, $hash, $staticSalt) {
                    /*
                     * Prevent enumeration because nothing happens
                     * when there is no, or an invalid hash.
                     * Also, change the password to be sure it's not maching
                     * the new hash.
                     * The new hash is equal to 'test' in BCRYPT context.
                     */
                    if (empty($hash)) {
                        $hash = '$2y$10$azRqq.pN0OlWjeVfVMZXOOwqYAx1hMfme6ZnDV.27grGOEZvG.uAO';
                        $passwd = 'wrongPassword';
                    }

                    return password_verify(md5('<your 1.6 cookie key>' . $passwd), $hash);
                },
            ),
        );
    }
private函数initHashMethods()
{
$this->hashMethods=array(
“bcrypt”=>数组(
'选项'=>array(),
'hash'=>函数($passwd,$staticSalt,$option){
返回密码\u散列($passwd,password\u BCRYPT);
},
“验证”=>函数($passwd、$hash、$staticSalt){
/*
*防止枚举,因为什么都没有发生
*如果没有,或哈希无效。
*另外,请更改密码以确保它不正常运行
*新的散列。
*新哈希在BCRYPT上下文中等于“test”。
*/
if(空($hash)){
$hash='$2y$10$azRqq.pn0olwjevvmzxoowqyax1hmfme6zndv.27grGOEZvG.uAO';
$passwd='errowpassword';
}
返回密码\u验证($passwd,$hash);
},
),
“md5”=>数组(
'选项'=>array(),
'hash'=>函数($passwd,$staticSalt,$option){
返回md5($staticSalt.$passwd);
},
“验证”=>函数($passwd、$hash、$staticSalt){
返回md5($staticSalt.$passwd)==$hash;
},
),
“bcryptmd5”=>数组(
'选项'=>array(),
'hash'=>函数($passwd,$staticSalt,$option){
返回密码\u散列(md5('.$passwd),密码\u BCRYPT);
},
“验证”=>函数($passwd、$hash、$staticSalt){
/*
*防止枚举,因为什么都没有发生
*如果没有,或哈希无效。
*另外,请更改密码以确保它不正常运行
*新的散列。
*新哈希在BCRYPT上下文中等于“test”。
*/
if(空($hash)){
$hash='$2y$10$azRqq.pn0olwjevvmzxoowqyax1hmfme6zndv.27grGOEZvG.uAO';
$passwd='errowpassword';
}
返回密码验证(md5('.$passwd),$hash);
},
),
);
}

如果可以直接在数据库中导入以前的1.6哈希,并且保留相同的cookie密钥,则该函数是向后兼容的

但是,如果像我一样,在我使用csv功能导入时,1.6哈希已使用新的cookie密钥重新哈希,则需要更新src/Core/Crypto/Hashing.php,将最后一个函数替换为:

确保替换为Prestashop 1.6中的cookie密钥

private function initHashMethods()
    {
        $this->hashMethods = array(
            'bcrypt' => array(
                'option' => array(),
                'hash' => function ($passwd, $staticSalt, $option) {
                    return password_hash($passwd, PASSWORD_BCRYPT);
                },
                'verify' => function ($passwd, $hash, $staticSalt) {
                    /*
                     * Prevent enumeration because nothing happens
                     * when there is no, or an invalid hash.
                     * Also, change the password to be sure it's not maching
                     * the new hash.
                     * The new hash is equal to 'test' in BCRYPT context.
                     */
                    if (empty($hash)) {
                        $hash = '$2y$10$azRqq.pN0OlWjeVfVMZXOOwqYAx1hMfme6ZnDV.27grGOEZvG.uAO';
                        $passwd = 'wrongPassword';
                    }

                    return password_verify($passwd, $hash);
                },
            ),
            'md5' => array(
                'option' => array(),
                'hash' => function ($passwd, $staticSalt, $option) {
                    return md5($staticSalt . $passwd);
                },
                'verify' => function ($passwd, $hash, $staticSalt) {
                    return md5($staticSalt . $passwd) === $hash;
                },
            ),
            'bcryptmd5' => array(
                'option' => array(),
                'hash' => function ($passwd, $staticSalt, $option) {
                    return password_hash(md5('<your 1.6 cookie key>' . $passwd), PASSWORD_BCRYPT);
                },
                'verify' => function ($passwd, $hash, $staticSalt) {
                    /*
                     * Prevent enumeration because nothing happens
                     * when there is no, or an invalid hash.
                     * Also, change the password to be sure it's not maching
                     * the new hash.
                     * The new hash is equal to 'test' in BCRYPT context.
                     */
                    if (empty($hash)) {
                        $hash = '$2y$10$azRqq.pN0OlWjeVfVMZXOOwqYAx1hMfme6ZnDV.27grGOEZvG.uAO';
                        $passwd = 'wrongPassword';
                    }

                    return password_verify(md5('<your 1.6 cookie key>' . $passwd), $hash);
                },
            ),
        );
    }
private函数initHashMethods()
{
$this->hashMethods=array(
“bcrypt”=>数组(
'选项'=>array(),
'hash'=>函数($passwd,$staticSalt,$option){
返回密码\u散列($passwd,password\u BCRYPT);
},
“验证”=>函数($passwd、$hash、$staticSalt){
/*
*防止枚举,因为什么都没有发生
*如果没有,或哈希无效。
*另外,请更改密码以确保它不正常运行
*新的散列。
*新哈希在BCRYPT上下文中等于“test”。
*/
if(空($hash)){
$hash='$2y$10$azRqq.pn0olwjevvmzxoowqyax1hmfme6zndv.27grGOEZvG.uAO';
$passwd='errowpassword';
}
返回密码\u验证($passwd,$hash);
},
),
“md5”=>数组(
'选项'=>array(),
'hash'=>函数($passwd,$staticSalt,$option){
返回md5($staticSalt.$passwd);
},
“验证”=>函数($passwd、$hash、$staticSalt){