<?phpnamespaceIlluminate\Encryption;useRuntimeException;useIlluminate\Support\ServiceProvider;classEncryptionServiceProviderextendsServiceProvider{/** * Register the service provider. * * @return void * * @throws \RuntimeException */publicfunctionregister(){$this->app->singleton('encrypter',function($app){$config=$app->make('config')->get('app');$key=$config['key'];$cipher=$config['cipher'];if(Encrypter::supported($key,$cipher)){returnnewEncrypter($key,$cipher);}elseif(McryptEncrypter::supported($key,$cipher)){returnnewMcryptEncrypter($key,$cipher);}else{thrownewRuntimeException('No supported encrypter found. The cipher and / or key length are invalid.');}});}}