diff --git a/src/Console/Commands/KeysCommand.php b/src/Console/Commands/KeysCommand.php index 8db16d6..1d529e8 100644 --- a/src/Console/Commands/KeysCommand.php +++ b/src/Console/Commands/KeysCommand.php @@ -44,22 +44,21 @@ public function handle() $this->error('Encryption keys already exist. Use the --force option to overwrite them.'); return 1; - } else { - if (class_exists(LegacyRSA::class)) { - $keys = (new LegacyRSA)->createKey($this->input ? (int) $this->option('length') : 4096); - - file_put_contents($publicKey, Arr::get($keys, 'publickey')); - file_put_contents($privateKey, Arr::get($keys, 'privatekey')); - } else { - $key = RSA::createKey($this->input ? (int) $this->option('length') : 4096); + } + if (class_exists(LegacyRSA::class)) { + $keys = (new LegacyRSA())->createKey($this->input ? (int) $this->option('length') : 4096); - file_put_contents($publicKey, (string) $key->getPublicKey()); - file_put_contents($privateKey, (string) $key); - } + file_put_contents($publicKey, Arr::get($keys, 'publickey')); + file_put_contents($privateKey, Arr::get($keys, 'privatekey')); + } else { + $key = RSA::createKey($this->input ? (int) $this->option('length') : 4096); - $this->info('Encryption keys generated successfully.'); + file_put_contents($publicKey, (string) $key->getPublicKey()); + file_put_contents($privateKey, (string) $key); } + $this->info('Encryption keys generated successfully.'); + return 0; }