我为Prestashop 1.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
发布于 2019-04-29 00:43:10
PrestaShop 1.7.x现在使用 bcrypt 作为首选哈希方法(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');使用 1.7类/方法的示例的PrestaShop解决方案:
<?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 */替代解决方案,无需包含任何PrestaShop文件/方法:
<?php
$plaintextPassword = '123456';
$encryptedPassword = password_hash($plaintextPassword, PASSWORD_BCRYPT);
echo var_dump(password_verify($plaintextPassword, $encryptedPassword)); // True if encryption is matching我希望这能帮到你。
https://stackoverflow.com/questions/55895336
复制相似问题