Skip to content

Commit 8f1a966

Browse files
committed
Move empty key detection above starts_with check
1 parent 3a4fdd0 commit 8f1a966

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/Illuminate/Encryption/EncryptionServiceProvider.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,21 @@ public function register()
1818
$this->app->singleton('encrypter', function ($app) {
1919
$config = $app->make('config')->get('app');
2020

21-
// If the key starts with "base64:", we will need to decode the key before handing
22-
// it off to the encrypter. Keys may be base-64 encoded for presentation and we
23-
// want to make sure to convert them back to the raw bytes before encrypting.
24-
if (Str::startsWith($key = $config['key'], 'base64:')) {
25-
$key = base64_decode(substr($key, 7));
26-
}
21+
$key = $config['key'];
2722

2823
if (is_null($key) || $key === '') {
2924
throw new RuntimeException(
3025
'The application encryption key is missing. Run php artisan key:generate to generate it.'
3126
);
3227
}
3328

29+
// If the key starts with "base64:", we will need to decode the key before handing
30+
// it off to the encrypter. Keys may be base-64 encoded for presentation and we
31+
// want to make sure to convert them back to the raw bytes before encrypting.
32+
if (Str::startsWith($key, 'base64:')) {
33+
$key = base64_decode(substr($key, 7));
34+
}
35+
3436
return new Encrypter($key, $config['cipher']);
3537
});
3638
}

0 commit comments

Comments
 (0)