user3177519
user3177519

Reputation: 401

Laravel configuration error: The cipher and / or key length are invalid

I am using laravel 5 i have tried possible solution on similar question on stack but that didn't helped me . Below are my updated files that i edited

My .env file is updated with appkey see here

generated appkey with php artisan command key generate and put that in . env

APP_ENV=local
APP_DEBUG=true
APP_KEY=[9vkErFVjzUX3ozuOcD7T7KTHNKP2FBNB]

DB_HOST=localhost
DB_DATABASE=blogdb
DB_USERNAME=rootDB_PASSWORD=

CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync

MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

Also Updated app.php file cipher and appkey manually

  'key' => env('APP_KEY', '[9vkErFVjzUX3ozuOcD7T7KTHNKP2FBNB]'),

  'cipher' => 'AES-256-CBC',

Don't know why it is generating 34 bit app key using php artisan command

Upvotes: 0

Views: 1082

Answers (2)

user3177519
user3177519

Reputation: 401

All Data in my question was correct but as i was using it laravel first time so when api key generated it came with '[' ']' brackets but it was not supposed to be used with that so correct api key and files code is below -

In env File ( APP_KEY without brackets )

APP_ENV=local
APP_DEBUG=true
APP_KEY=9vkErFVjzUX3ozuOcD7T7KTHNKP2FBNB

DB_HOST=localhost
DB_DATABASE=blogdb
DB_USERNAME=rootDB_PASSWORD=

CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync

MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

Also Updated app.php file cipher and appkey manually ( APP_KEY without brackets )

'key' => env('APP_KEY', '[9vkErFVjzUX3ozuOcD7T7KTHNKP2FBNB]'),

'cipher' => 'AES-256-CBC',

Upvotes: 0

Mohammad Gitipasand
Mohammad Gitipasand

Reputation: 350

please use

php artisan key:generate

or use

php artisan list

to view all artisans. then .env file simillar:

APP_KEY=base64:s1TFa5c254BawHqjiRznrmFatra08lRuIwNLDm2inr4=

and app.php simillar:

    'key' => env('APP_KEY'),

    'cipher' => 'AES-256-CBC',

Upvotes: 2

Related Questions