This is an article which is describing an error generated when executing a Laravel framework-based project web application. There are error generated in the Laravel framework-based web application project which is written in an error log saved in the folder ‘storage/logs/laravel.log’.
[XXXX-XX-XX XX:XX:XX] local.ERROR: RuntimeException: The only supported ciphers are AES-128-CBC and AES-256-CBC with the correct key lengths. in /var/www/html/laravel-project/vendor/laravel/framework/src/Illuminate/Encryption/Encrypter.php:43 Stack trace: #0 /var/www/html/laravel-project/vendor/laravel/framework/src/Illuminate/Encryption/EncryptionServiceProvider.php(27): Illuminate\Encryption\Encrypter->__construct('', 'AES-256-CBC') #1 /var/www/html/laravel-project/vendor/laravel/framework/src/Illuminate/Container/Container.php(745): Illuminate\Encryption\EncryptionServiceProvider->Illuminate\Encryption\{closure}(Object(Illuminate\Foundation\Application), Array) #2 /var/www/html/laravel-project/vendor/laravel/framework/src/Illuminate/Container/Container.php(643): Illuminate\Container\Container->build(Object(Closure), Array) #3 /var/www/html/laravel-project/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(709): Illuminate\Container\Container->make('encrypter', Array) #4 /var/www/html/laravel-project/vendor/laravel/framework/src/Illuminate/Container/Container.php(863): Illuminate\Foundation\Application->make('encrypter') #5 /var/www/html/laravel-project/vendor/laravel/framework/src/Illuminate/Container/Container.php(818): Illuminate\Container\Container->resolveClass(Object(ReflectionParameter)) #6 /var/www/html/laravel-project/vendor/laravel/framework/src/Illuminate/Container/Container.php(787): Illuminate\Container\Container->getDependencies(Array, Array) #7 /var/www/html/laravel-project/vendor/laravel/framework/src/Illuminate/Container/Container.php(643): Illuminate\Container\Container->build('App\\Http\\Middle...', Array) #8 /var/www/html/laravel-project/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(709): Illuminate\Container\Container->make('App\\Http\\Middle...', Array) #9 /var/www/html/laravel-project/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(173): Illuminate\Foundation\Application->make('App\\Http\\Middle...') #10 /var/www/html/laravel-project/public/index.php(58): Illuminate\Foundation\Http\Kernel->terminate(Object(Illuminate\Http\Request), Object(Illuminate\Http\Response)) #11 {main} ~
The error itself is described as follows :
local.ERROR: RuntimeException: The only supported ciphers are AES-128-CBC and AES-256-CBC with the correct key lengths.
Not only in the laravel.log which is written, but also in the main page of the associated Laravel framework-based web application as shown in the image below :
In the above output, the error also pointed a specific error message as follows :
RuntimeException in Encrypter.php line 43 : The only supported ciphers are AES-128-CBC and AES-256-CBC with the correct key lengths.
To correct the error and make the application run properly, below is the step which is taken to fix the problem :
Edit the following file named ‘app.php’ which is located in ‘laravel-project/config’ depends on the name of the root base folder used. So, the full path will be shown as follow :
user@hostname:/var/www/html/laravel-project/config$
For detail consideration, the context of this article is using Laravel 5.3 as an example. And the solution for the above is quite easy which is by changing a certain line in the file named ‘app.php’ as follows :
From the original line below :
'key' => env('APP_KEY'),
to be changed into a modified line as follows :
'key' => env('APP_KEY','mykey'),
This is the actual view which is displayed the original file :
It is actually shown as the image below :
The solution is just to change the APP_KEY by defining the value from nothing into any kinds of value which is preferred just to make the web application based on Laravel framework-based working. In the above content, the value of APP_KEY is defined as ‘mykey’. This is the output of the main page when the value of APP_KEY in app.php has already been changed :