Server : Apache System : Linux host44.registrar-servers.com 4.18.0-513.18.1.lve.2.el8.x86_64 #1 SMP Sat Mar 30 15:36:11 UTC 2024 x86_64 User : vapecompany ( 2719) PHP Version : 7.4.33 Disable Function : NONE Directory : /home/vapecompany/demo.vapecompany.com.bd/vendor/laravel/framework/src/Illuminate/Encryption/ |
Upload File : |
<?php namespace Illuminate\Encryption; use Illuminate\Support\ServiceProvider; use Illuminate\Support\Str; use Opis\Closure\SerializableClosure; class EncryptionServiceProvider extends ServiceProvider { /** * Register the service provider. * * @return void */ public function register() { $this->registerEncrypter(); $this->registerOpisSecurityKey(); } /** * Register the encrypter. * * @return void */ protected function registerEncrypter() { $this->app->singleton('encrypter', function ($app) { $config = $app->make('config')->get('app'); return new Encrypter($this->parseKey($config), $config['cipher']); }); } /** * Configure Opis Closure signing for security. * * @return void */ protected function registerOpisSecurityKey() { $config = $this->app->make('config')->get('app'); if (! class_exists(SerializableClosure::class) || empty($config['key'])) { return; } SerializableClosure::setSecretKey($this->parseKey($config)); } /** * Parse the encryption key. * * @param array $config * @return string */ protected function parseKey(array $config) { if (Str::startsWith($key = $this->key($config), $prefix = 'base64:')) { $key = base64_decode(Str::after($key, $prefix)); } return $key; } /** * Extract the encryption key from the given configuration. * * @param array $config * @return string * * @throws \Illuminate\Encryption\MissingAppKeyException */ protected function key(array $config) { return tap($config['key'], function ($key) { if (empty($key)) { throw new MissingAppKeyException; } }); } }