php – 将加密密钥从Laravel 5.2迁移到5.3
发布时间:2020-12-14 19:40:12 所属栏目:大数据 来源:网络整理
导读:我目前正在尝试从Laravel 5.2更新到5.3.但是现在我遇到了将加密从MCrypt转换为OpenSSL的问题,如此处的升级指南 https://laravel.com/docs/5.3/upgrade#upgrade-5.3.0所述.为此,我按照上面的文档中的建议编写了一个命令.但是有一个错误: [2016-09-18 11:07:4
我目前正在尝试从Laravel 5.2更新到5.3.但是现在我遇到了将加密从MCrypt转换为OpenSSL的问题,如此处的升级指南
https://laravel.com/docs/5.3/upgrade#upgrade-5.3.0所述.为此,我按照上面的文档中的建议编写了一个命令.但是有一个错误:
[2016-09-18 11:07:46] local.ERROR: exception 'IlluminateContractsEncryptionDecryptException' with message 'The payload is invalid.' in /home/vagrant/Code/bob/vendor/laravel/legacy-encrypter/src/BaseEncrypter.php:44 命令: <?php namespace AppConsoleCommands; use AppUser; use IlluminateConsoleCommand; use LaravelLegacyEncrypterMcryptEncrypter; class McryptToOpenSSL extends Command { /** * The name and signature of the console command. * * @var string */ protected $signature = 'key:migrate'; /** * The console command description. * * @var string */ protected $description = 'Migrates key from deprecated Mcrypt to OpenSSL.'; /** * Create a new command instance. * * @return void */ public function __construct() { parent::__construct(); } /** * Execute the console command. * * @return mixed */ public function handle() { $legacy = new McryptEncrypter(env('APP_KEY_LEGACY')); $users = User::all(); foreach ($users as $user) { $user->password = encrypt( $legacy->decrypt($user->password) ); $user->save(); } } } .env(出于安全原因,密钥略有变化) APP_ENV=local APP_DEBUG=true APP_KEY=base64:3VU8u79ZU0dObazwvd2lHHOAVRJjy5kvzXKeKtcHVYk= APP_KEY_LEGACY=zejqrdy7WjA58xGoSuj634RYXB97vLyp 解决方法
您是否手动覆盖用户的密码加密? 默认情况下,如果您不进行任何更改,则无需进行密码迁移. 密码不使用encrypt()加密,它使用password_hash(),这就是有效载荷无效的原因.
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |