Sébastien
Sébastien

Reputation: 308

No supported encrypter found. The cipher and / or key length are invalid with laravel

I have a problem with my laravel install. The error message (shown below) happens from time to time (maybe somewhere around every 100 clicks).

I did the php artisan key:generate command.

I also checked the APP_KEY value in my .env file: it's formatted like that base64:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

In my config/app.php I have the following code: 'cipher' => 'AES-256-CBC'

I don't see where the problem comes from... Could it be because of a length difference between the two variables? But if it does, why is it happening just randomly like that?

RuntimeException in EncryptionServiceProvider.php line 45:
No supported encrypter found. The cipher and / or key length are invalid.
in EncryptionServiceProvider.php line 45
at EncryptionServiceProvider->getEncrypterForKeyAndCipher(null, 'AES-256-CBC') in EncryptionServiceProvider.php line 25
at EncryptionServiceProvider->Illuminate\Encryption\{closure}(object(Application), array()) in Container.php line 731
at Container->build(object(Closure), array()) in Container.php line 629
at Container->make('encrypter', array()) in Application.php line 697
at Application->make('Illuminate\Contracts\Encryption\Encrypter') in Container.php line 849
at Container->resolveClass(object(ReflectionParameter)) in Container.php line 804
at Container->getDependencies(array(object(ReflectionParameter)), array()) in Container.php line 775
at Container->build('Sparta\Http\Middleware\EncryptCookies', array()) in Container.php line 629
at Container->make('Sparta\Http\Middleware\EncryptCookies', array()) in Application.php line 697
at Application->make('Sparta\Http\Middleware\EncryptCookies') in Pipeline.php line 126
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Router.php line 726
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 699
at Router->dispatchToRoute(object(Request)) in Router.php line 675
at Router->dispatch(object(Request)) in Kernel.php line 246
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 44
at CheckForMaintenanceMode->handle(object(Request), object(Closure))
at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Kernel.php line 132
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 99
at Kernel->handle(object(Request)) in index.php line 54
Whoops, looks like something went wrong.

Upvotes: 0

Views: 4604

Answers (3)

HectorMazzu
HectorMazzu

Reputation: 1389

In the .env file set APP_KEY= (without value) and save. Then run the following commands:

php artisan key:generate
php artisan config:cache

It works for me.

Upvotes: 4

Sébastien
Sébastien

Reputation: 308

I managed to trigger this message by clicking several times in a row on the same button at a very fast pace if that can help...

Upvotes: 0

Onix
Onix

Reputation: 2179

Check your key in the .env file.

Run php artisan key:generate to generate a new one.

Then check if the key in the .env file changed. if not change it manually.

Upvotes: 0

Related Questions