[Solved] Laravel: The only supported ciphers are AES-128-CBC and AES-256-CBC with the correct key lengths.

Recently I set up a project with the laravel PHP framework and hit a little bump right away. After cloning my project on my computer at home, I encountered an error message about the AES key length.

Luckily I wasn’t the only one with that issue and running the following and conveniently available artisan commands fixed it already:

php artisan key:generate
php artisan config:clear

Commands with output:

php artisan key:generate
Application key [base64:xxxxxxxxxxxxxx] set successfully.
php artisan config:clear
Configuration cache cleared!

The project had a basic authentication setup through php artisan make:auth by the way, which is why it needs sessions in the first place.

Full error messages below:

RuntimeException in compiled.php line 13261:
The only supported ciphers are AES-128-CBC and AES-256-CBC with the correct key lengths.
in compiled.php line 13261
at Encrypter->__construct('', 'AES-256-CBC') in compiled.php line 7739
at EncryptionServiceProvider->Illuminate\Encryption\{closure}(object(Application), array()) in compiled.php line 1374
at Container->build(object(Closure), array()) in compiled.php line 1330
at Container->make('encrypter', array()) in compiled.php line 1908
at Application->make('Illuminate\Contracts\Encryption\Encrypter') in compiled.php line 1431
at Container->resolveClass(object(ReflectionParameter)) in compiled.php line 1408
at Container->getDependencies(array(object(ReflectionParameter)), array()) in compiled.php line 1394
at Container->build('App\Http\Middleware\EncryptCookies', array()) in compiled.php line 1330
at Container->make('App\Http\Middleware\EncryptCookies', array()) in compiled.php line 1908
at Application->make('App\Http\Middleware\EncryptCookies') in compiled.php line 9868
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in compiled.php line 9858
at Pipeline->then(object(Closure)) in compiled.php line 8164
at Router->runRouteWithinStack(object(Route), object(Request)) in compiled.php line 8155
at Router->dispatchToRoute(object(Request)) in compiled.php line 8146
at Router->dispatch(object(Request)) in compiled.php line 2472
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in compiled.php line 3224
at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in compiled.php line 9873
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in compiled.php line 9858
at Pipeline->then(object(Closure)) in compiled.php line 2416
at Kernel->sendRequestThroughRouter(object(Request)) in compiled.php line 2400
at Kernel->handle(object(Request)) in index.php line 54
at require_once('/home/jonathan/projects/xxx/xxx-backend/public/index.php') in server.php line 21
in compiled.php line 13261
at Encrypter->__construct('', 'AES-256-CBC') in compiled.php line 7739
at EncryptionServiceProvider->Illuminate\Encryption\{closure}(object(Application), array()) in compiled.php line 1374
at Container->build(object(Closure), array()) in compiled.php line 1330
at Container->make('encrypter', array()) in compiled.php line 1908
at Application->make('Illuminate\Contracts\Encryption\Encrypter') in compiled.php line 1431
at Container->resolveClass(object(ReflectionParameter)) in compiled.php line 1408
at Container->getDependencies(array(object(ReflectionParameter)), array()) in compiled.php line 1394
at Container->build('App\Http\Middleware\EncryptCookies', array()) in compiled.php line 1330
at Container->make('App\Http\Middleware\EncryptCookies', array()) in compiled.php line 1908
at Application->make('App\Http\Middleware\EncryptCookies') in compiled.php line 2426
at Kernel->terminate(object(Request), object(Response)) in index.php line 58
at require_once('/home/jonathan/projects/xxx/xxxx-backend/public/index.php') in server.php line 21

Thank you for reading! If you have any comments, additions or questions, please leave them in the form below! You can also tweet them at me

If you want to read more like this, follow me on feedly or other rss readers

2 thoughts on “[Solved] Laravel: The only supported ciphers are AES-128-CBC and AES-256-CBC with the correct key lengths.”

Leave a Reply

Your email address will not be published. Required fields are marked *