Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/295.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在Laravel 8中解密Cookie_Php_Encryption_Laravel 8 - Fatal编程技术网

Php 如何在Laravel 8中解密Cookie

Php 如何在Laravel 8中解密Cookie,php,encryption,laravel-8,Php,Encryption,Laravel 8,最近,我们将Laravel应用程序从5.6升级到Laravel 8.18.1。我们在RouteServiceProvider.php中使用cookie解密 HomeController.php $encrypter = app(\Illuminate\Contracts\Encryption\Encrypter::class); $channel_cookie = $encrypter->decrypt(Cookie::get('channel')); // result "mo

最近,我们将Laravel应用程序从5.6升级到Laravel 8.18.1。我们在RouteServiceProvider.php中使用cookie解密

HomeController.php

$encrypter = app(\Illuminate\Contracts\Encryption\Encrypter::class);
$channel_cookie = $encrypter->decrypt(Cookie::get('channel')); // result "mobile"
$encrypter = app(\Illuminate\Contracts\Encryption\Encrypter::class);
$channel_cookie = $encrypter->decrypt(Cookie::get('channel')); // result "a86aa854d5e61e2873acd30373b6725e36fba671|mobile"
$channel_cookie = explode("|",$channel_cookie)[1]; // result mobile
Cookie::队列(“频道”,“移动”,60241);//通道加密 价值观= EYJPDII6IJJVTGFZZZHDEOXPJMK9VTGFFYMLSBXC9PsiSinZHbHbLijioid0DJMW9ZbHbFfqTk5AVXBDZ09IIWIBWfjijoiZGM4U1YTY0ZVKNTE4NJBLNZG4NZZZZZWmZZWnjdJdKNgNgGyZIwM3MJ9

在Laravel5.6中,它直接将散列解密为一个值

RouteServiceProvider.php

$encrypter = app(\Illuminate\Contracts\Encryption\Encrypter::class);
$channel_cookie = $encrypter->decrypt(Cookie::get('channel')); // result "mobile"
$encrypter = app(\Illuminate\Contracts\Encryption\Encrypter::class);
$channel_cookie = $encrypter->decrypt(Cookie::get('channel')); // result "a86aa854d5e61e2873acd30373b6725e36fba671|mobile"
$channel_cookie = explode("|",$channel_cookie)[1]; // result mobile
在Laravel8.18.1中,它将散列解密为带有竖线的值

RouteServiceProvider.php

$encrypter = app(\Illuminate\Contracts\Encryption\Encrypter::class);
$channel_cookie = $encrypter->decrypt(Cookie::get('channel')); // result "mobile"
$encrypter = app(\Illuminate\Contracts\Encryption\Encrypter::class);
$channel_cookie = $encrypter->decrypt(Cookie::get('channel')); // result "a86aa854d5e61e2873acd30373b6725e36fba671|mobile"
$channel_cookie = explode("|",$channel_cookie)[1]; // result mobile

这是在Laravel 8中解密Cookie的安全解决方案吗?

您找到了更好的方法吗?这是一种非常奇怪的解密方式,但我也找不到其他解决方案。