jadjoubran / laravel5-angular-material-starter

Get started with Laravel 5.3 and AngularJS (material)
https://laravel-angular.readme.io/
MIT License
1.66k stars 400 forks source link

No supported encrypter found. The cipher and / or key length are invalid. #60

Closed seongbae-ml closed 9 years ago

seongbae-ml commented 9 years ago

Hey,

I am getting following error when I browse localhost:8000:

Whoops, looks like something went wrong.

1/1 RuntimeException in compiled.php line 6784: No supported encrypter found. The cipher and / or key length are invalid. in compiled.php line 6784 at EncryptionServiceProvider->Illuminate\Encryption{closure}(object(Application), array()) in compiled.php line 1086 at Container->build(object(Closure), array()) in compiled.php line 1039 at Container->make('encrypter', array()) in compiled.php line 1577 at Application->make('Illuminate\Contracts\Encryption\Encrypter') in compiled.php line 1131 at Container->resolveClass(object(ReflectionParameter)) in compiled.php line 1115 at Container->getDependencies(array(object(ReflectionParameter)), array()) in compiled.php line 1101 at Container->build('Illuminate\Cookie\Middleware\EncryptCookies', array()) in compiled.php line 1039 at Container->make('Illuminate\Cookie\Middleware\EncryptCookies', array()) in compiled.php line 1577 at Application->make('Illuminate\Cookie\Middleware\EncryptCookies') in compiled.php line 9279 at Pipeline->Illuminate\Pipeline{closure}(object(Request)) in compiled.php line 2776 at CheckForMaintenanceMode->handle(object(Request), object(Closure)) at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in compiled.php line 9279 at Pipeline->Illuminate\Pipeline{closure}(object(Request)) in Request.php line 95 at Request->handle(object(Request), object(Closure)) at call_user_func_array(array(object(Request), 'handle'), array(object(Request), object(Closure))) in compiled.php line 9279 at Pipeline->Illuminate\Pipeline{closure}(object(Request)) at call_user_func(object(Closure), object(Request)) in compiled.php line 9269 at Pipeline->then(object(Closure)) in compiled.php line 2053 at Kernel->sendRequestThroughRouter(object(Request)) in compiled.php line 2036 at Kernel->handle(object(Request)) in index.php line 53 at require_once('/Users/sbae/Projects/laravel5-angular-material-starter/public/index.php') in server.php line 19

jadjoubran commented 9 years ago

Hi!

Your issue can be resolved by running: php artisan key:generate This will generate the APP_KEY and save it inside a .env file.

But how did you install this package? Because it usually generates it automatically

ekvedaras commented 9 years ago

I've got the same problem. Fallowed installation guide, but my IDE shown that constant MCRYPT_RIJNDAEL_128 was not defined :) Did not check, maybe it is fixed already or simply something went wrong during installation.

jadjoubran commented 9 years ago

@unxp so even with php artisan key:generate it didn't work? You probably need to install mcrypt - follow this question and please let me know if it works for you so I can update the docs with common issues

GrahamCampbell commented 9 years ago

Likely you forgot to recache the config.

seongbae-ml commented 9 years ago

That's weird.. I've checked that mcrypt is installed and mcrypt.so is added to php.ini. I also cleared application cache - "php artisan cache:clear" but still getting error. I will spend some more time tonight to find out what's going on.

I've noticed that APP_KEY in config/app.php has default "somerandomstring" and I've replaced it with one from .env file (one that was generated). This didn't help either.

I think it has something to do with MCRYPT_RIJNDAEL_128.

GrahamCampbell commented 9 years ago

I think it has something to do with MCRYPT_RIJNDAEL_128.

No, you need to make sure the default cipher is used so that you get to use openssl instead of mcrypt.

GrahamCampbell commented 9 years ago

https://github.com/laravel/laravel/blob/master/config/app.php#L83

seongbae-ml commented 9 years ago

Thank you! Changing cipher from 'MCRYPT_RIJNDAEL_128' to 'AES-256-CBC' fixed it.

By default, you have cipher set to 'MCRYPT_RIJNDAEL_128':

https://github.com/jadjoubran/laravel5-angular-material-starter/blob/master/config/app.php#L83

jadjoubran commented 9 years ago

Fixed as of 2.10.1

irfanwv commented 8 years ago

@jadjoubran when I run this php artisan key:generate command then also give same error

jadjoubran commented 8 years ago

@irfanwv Which error? Feel free to open a new issue with detailed info Thanks!

akashgangrade commented 6 years ago

Getting this error on artisan key: generate command

?[37;41m ?[39;49m ?[37;41m [ErrorException] ?[39;49m ?[37;41m Cannot modify header information - headers already sent by (output sta rted ?[39;49m ?[37;41m at E:\wamp64\www\abc\abc\config\app.php:1) ?[39;49m ?[37;41m ?[39;49m