Php Prestashop 1.7客户密码加密?

Php Prestashop 1.7客户密码加密?,php,prestashop,bcrypt,prestashop-1.7,password-hash,Php,Prestashop,Bcrypt,Prestashop 1.7,Password Hash,我为Prestashop1.6制作了一些基于php的第三方系统。它可以直接连接Prestashop数据库。我把我的Presta升级到了1.7.5.1,它可以正常工作。只是它不再登录客户,因为我可以看到密码加密已更改。我在1.6中使用了md5(COOKIE_KEY.“password”),但我在1.7中看到的密码与md5完全不同。你能告诉我加密是怎么回事吗。(如果你用php代码告诉我会更好) Prestashop 1.7.5.1 $2y$10$6b460aRLklgWblz75NAMteYXLJw

我为Prestashop1.6制作了一些基于php的第三方系统。它可以直接连接Prestashop数据库。我把我的Presta升级到了1.7.5.1,它可以正常工作。只是它不再登录客户,因为我可以看到密码加密已更改。我在1.6中使用了md5(COOKIE_KEY.“password”),但我在1.7中看到的密码与md5完全不同。你能告诉我加密是怎么回事吗。(如果你用php代码告诉我会更好)

Prestashop 1.7.5.1

$2y$10$6b460aRLklgWblz75NAMteYXLJwjfV6a/uN8GJKgJgPDBuNhHs.ym


对于123456,PrestaShop 1.7.x现在用作首选哈希方法(尽管仍支持md5)。

为了更好地理解PrestaShop v1.6.x与1.7.x之间检查密码的行为,让我们看看Customer类中的
getByEmail()
方法:

/**
  * Return customer instance from its e-mail (optionally check password).
  *
  * @param string $email e-mail
  * @param string $plaintextPassword Password is also checked if specified
  * @param bool $ignoreGuest
  *
  * @return bool|Customer|CustomerCore Customer instance
 */
 public function getByEmail($email, $plaintextPassword = null, $ignoreGuest = true)
如果提供了
$plaintextPassword
,则将使用以下信息检索密码的加密版本:

$this->passwd = $crypto->hash($plaintextPassword);
可以通过执行以下操作实例化哈希类:

$crypto = ServiceLocator::get('\\PrestaShop\\PrestaShop\\Core\\Crypto\\Hashing');
使用PrestaShop 1.7类/方法的示例解决方案:

<?php

namespace PrestaShop\PrestaShop\Core\Crypto;
include('config/config.inc.php');

$plaintextPassword = '123456';
$crypto = new Hashing;
$encryptedPassword = $crypto->hash($plaintextPassword, _COOKIE_KEY_);

echo 'Clear: '.$plaintextPassword.'<br />Encrypted: '.$encryptedPassword;

/* Result (example)
Clear: 123456
Encrypted: $2y$10$6b460aRLklgWblz75NAMteYXLJwjfV6a/uN8GJKgJgPDBuNhHs.ym */
<?php

$plaintextPassword = '123456';
$encryptedPassword = password_hash($plaintextPassword, PASSWORD_BCRYPT);
echo var_dump(password_verify($plaintextPassword, $encryptedPassword)); // True if encryption is matching

谢谢,但我不想包含任何预启动文件。那么,md5是如何像以前一样得到支持的呢?(虽然md5仍然受到支持)“我可以使用旧类型的加密吗?或者我可以像这样加密而不包括任何prestashop文件吗?”AnılTürk,我强烈建议不要使用md5,因为现在认为加密级别太弱了。我编辑了我的答案,以便使用bcrypt提供一个替代解决方案,而不需要包含任何pretashop文件或cookie密钥。我希望这有帮助;-)我试过了,但它总是返回true。我也试过包含配置文件解决方案。它重定向商店主页。如果明文密码错误,解决方案2也会返回“始终为真”。有什么想法吗?