0
我的工作需要存儲加密信息的存儲,更新,顯示(在控制器使用)的項目工作正常使用use Illuminate\Support\Facades\Crypt;
無法地穴::從工匠命令解密Laravel /流明
但是,當我需要創建一個命令來在計劃運行,在命令我需要得到未加密的代碼,但是當我使用它,它表明
的MAC無效
注:當我使用use Crypt;
,在控制器做工精細的代碼,但在命令,它說
類「地穴」未找到
在命令的代碼(函數topupSim()
導致錯誤):
topupSim
功能,代碼使用隱窩:
public static function topupSim(Sim $sim, TopupCode $topupCode)
{
$code = $topupCode->getCode();
$serial = $topupCode->getSerial();
//TODO: Do topup for sim
if (false /*Success*/) {
$topupCode->setUse();
return true;
}
return false;
}
2功能getCode()
,getSerial()
使用隱窩,這兩個函數都是在示範
public function getCode()
{
$code = Crypt::decrypt($this->getAttribute('code'));
return $code;
}
public function getSerial()
{
$serial = Crypt::decrypt($this->getAttribute('serial'));
return $serial;
}
日誌文件:
[2016-08-19 02:58:57] lumen.INFO: ** TopUpForCriticalSimsCommand: started
[2016-08-19 03:01:02] lumen.ERROR: exception 'Illuminate\Contracts\Encryption\DecryptException' with message 'The MAC is invalid.' in D:\working-tools\xampp\htdocs\VedSmsGateway\source\sms_gateway\vendor\illuminate\encryption\BaseEncrypter.php:48
Stack trace:
#0 D:\working-tools\xampp\htdocs\VedSmsGateway\source\sms_gateway\vendor\illuminate\encryption\Encrypter.php(96): Illuminate\Encryption\BaseEncrypter->getJsonPayload('eyJpdiI6InBFT2d...')
#1 D:\working-tools\xampp\htdocs\VedSmsGateway\source\sms_gateway\vendor\illuminate\support\Facades\Facade.php(218): Illuminate\Encryption\Encrypter->decrypt('eyJpdiI6InBFT2d...')
#2 D:\working-tools\xampp\htdocs\VedSmsGateway\source\sms_gateway\app\Models\TopupCode.php(114): Illuminate\Support\Facades\Facade::__callStatic('decrypt', Array)
#3 D:\working-tools\xampp\htdocs\VedSmsGateway\source\sms_gateway\app\Models\TopupCode.php(114): Illuminate\Support\Facades\Crypt::decrypt('eyJpdiI6InBFT2d...')
#4 D:\working-tools\xampp\htdocs\VedSmsGateway\source\sms_gateway\app\Engine.php(721): Ved\SmsGateway\Models\TopupCode->getCode()
#5 D:\working-tools\xampp\htdocs\VedSmsGateway\source\sms_gateway\app\Console\Commands\TopUpForCriticalSimsCommand.php(57): Ved\SmsGateway\Engine::topupSim(Object(Ved\SmsGateway\Models\Sim), Object(Ved\SmsGateway\Models\TopupCode))
#6 [internal function]: Ved\SmsGateway\Console\Commands\TopUpForCriticalSimsCommand->handle()
#7 D:\working-tools\xampp\htdocs\VedSmsGateway\source\sms_gateway\vendor\illuminate\container\Container.php(507): call_user_func_array(Array, Array)
#8 D:\working-tools\xampp\htdocs\VedSmsGateway\source\sms_gateway\vendor\illuminate\console\Command.php(169): Illuminate\Container\Container->call(Array)
#9 D:\working-tools\xampp\htdocs\VedSmsGateway\source\sms_gateway\vendor\symfony\console\Command\Command.php(256): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#10 D:\working-tools\xampp\htdocs\VedSmsGateway\source\sms_gateway\vendor\illuminate\console\Command.php(155): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#11 D:\working-tools\xampp\htdocs\VedSmsGateway\source\sms_gateway\vendor\symfony\console\Application.php(791): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#12 D:\working-tools\xampp\htdocs\VedSmsGateway\source\sms_gateway\vendor\symfony\console\Application.php(186): Symfony\Component\Console\Application->doRunCommand(Object(Ved\SmsGateway\Console\Commands\TopUpForCriticalSimsCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#13 D:\working-tools\xampp\htdocs\VedSmsGateway\source\sms_gateway\vendor\symfony\console\Application.php(117): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#14 D:\working-tools\xampp\htdocs\VedSmsGateway\source\sms_gateway\vendor\laravel\lumen-framework\src\Console\Kernel.php(69): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#15 D:\working-tools\xampp\htdocs\VedSmsGateway\source\sms_gateway\artisan(35): Laravel\Lumen\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#16 {main}
我嘗試:
composer dump-autoload
composer clear-cache
但沒有成功
任何人都知道,請幫忙,謝謝提前
此主題可能會帶來信息[https://stackoverflow.com/questions/46070732/laravel-decryptexception-the-mac-is-invalid/47926508#47926508](https://stackoverflow.com/questions/46070732/ laravel-decryptexception最MAC-是-無效/ 47926508#47926508) – 4givN