update v 1.0.7.5

This commit is contained in:
Sujit Prasad
2016-06-13 20:41:55 +05:30
parent aa9786d829
commit 283d97e3ea
5078 changed files with 339851 additions and 175995 deletions

View File

@@ -1,27 +1,48 @@
<?php namespace Illuminate\Encryption;
<?php
namespace Illuminate\Encryption;
use RuntimeException;
use Illuminate\Support\Str;
use Illuminate\Support\ServiceProvider;
class EncryptionServiceProvider extends ServiceProvider {
class EncryptionServiceProvider extends ServiceProvider
{
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$this->app->singleton('encrypter', function ($app) {
$config = $app->make('config')->get('app');
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$this->app->singleton('encrypter', function($app)
{
$encrypter = new Encrypter($app['config']['app.key']);
if (Str::startsWith($key = $config['key'], 'base64:')) {
$key = base64_decode(substr($key, 7));
}
if ($app['config']->has('app.cipher'))
{
$encrypter->setCipher($app['config']['app.cipher']);
}
return $encrypter;
});
}
return $this->getEncrypterForKeyAndCipher($key, $config['cipher']);
});
}
/**
* Get the proper encrypter instance for the given key and cipher.
*
* @param string $key
* @param string $cipher
* @return mixed
*
* @throws \RuntimeException
*/
protected function getEncrypterForKeyAndCipher($key, $cipher)
{
if (Encrypter::supported($key, $cipher)) {
return new Encrypter($key, $cipher);
} elseif (McryptEncrypter::supported($key, $cipher)) {
return new McryptEncrypter($key, $cipher);
} else {
throw new RuntimeException('No supported encrypter found. The cipher and / or key length are invalid.');
}
}
}