Classes/WebExcess/Flow/Backup/Service/BackupService.php
public function generateKeyFile()
    {
        $this->output->outputLine();

        if ( file_exists($this->createFilePath([$this->localBackupTarget, 'key'])) ) {
            $this->output->outputLine('<b>You have already a keyfile!</b>');
            $this->output->outputLine('If you generate a new one, all existing Backups are worthless.');
            $this->output->outputLine();
            $this->output->outputLine('Call \'./flow backup:clear --force\' to delete all Backups and the Keyfile.');
            $this->output->outputLine();
            return;
        }

        $this->output->outputLine('<b>Generate a new Crypto Key</b>');
        $this->output->outputLine();

        $this->files->createDirectoryRecursively($this->localBackupTarget);

        try {
            $key = \Crypto::createNewRandomKey();
            file_put_contents($this->createFilePath([$this->localBackupTarget, 'key']), $key);
            // WARNING: Do NOT encode $key with bin2hex() or base64_encode(),
            // they may leak the key to the attacker through side channels.
        } catch (Ex\CryptoTestFailedException $ex) {
            die('Cannot safely create a key');
        } catch (Ex\CannotPerformOperationException $ex) {
            die('Cannot safely create a key');
        }

        $this->output->outputLine('done');
        $this->output->outputLine();

    }
public function generateKeyFile()
    {
        $this->output->outputLine();

        if ( file_exists($this->createFilePath([$this->localBackupTarget, 'key'])) ) {
            $this->output->outputLine('<b>You have already a keyfile!</b>');
            $this->output->outputLine('If you generate a new one, all existing Backups are worthless.');
            $this->output->outputLine();
            $this->output->outputLine('Call \'./flow backup:clear --force\' to delete all Backups and the Keyfile.');
            $this->output->outputLine();
            return;
        }

        $this->output->outputLine('<b>Generate a new Crypto Key</b>');
        $this->output->outputLine();

        $this->files->createDirectoryRecursively($this->localBackupTarget);

        try {
            $key = \Crypto::createNewRandomKey();
            file_put_contents($this->createFilePath([$this->localBackupTarget, 'key']), $key);
            // WARNING: Do NOT encode $key with bin2hex() or base64_encode(),
            // they may leak the key to the attacker through side channels.
        } catch (Ex\CryptoTestFailedException $ex) {
            die('Cannot safely create a key');
        } catch (Ex\CannotPerformOperationException $ex) {
            die('Cannot safely create a key');
        }

        $this->output->outputLine('done');
        $this->output->outputLine();

    }
public function generateKeyFile ( ) { $ this -> output -> outputLine ( ) ; if ( file_exists ( $ this -> createFilePath ( [ $ this -> localBackupTarget , 'key' ] ) ) ) { $ this -> output -> outputLine ( '<b>You have already a keyfile!</b>' ) ; $ this -> output -> outputLine ( 'If you generate a new one, all existing Backups are worthless.' ) ; $ this -> output -> outputLine ( ) ; $ this -> output -> outputLine ( 'Call \'./flow backup:clear --force\' to delete all Backups and the Keyfile.' ) ; $ this -> output -> outputLine ( ) ; return ; } $ this -> output -> outputLine ( '<b>Generate a new Crypto Key</b>' ) ; $ this -> output -> outputLine ( ) ; $ this -> files -> createDirectoryRecursively ( $ this -> localBackupTarget ) ; try { $ key = \ Crypto :: createNewRandomKey ( ) ; file_put_contents ( $ this -> createFilePath ( [ $ this -> localBackupTarget , 'key' ] ) , $ key ) ; // WARNING: Do NOT encode $key with bin2hex() or base64_encode(), // they may leak the key to the attacker through side channels. } catch ( Ex \ CryptoTestFailedException $ ex ) { die ( 'Cannot safely create a key' ) ; } catch ( Ex \ CannotPerformOperationException $ ex ) { die ( 'Cannot safely create a key' ) ; } $ this -> output -> outputLine ( 'done' ) ; $ this -> output -> outputLine ( ) ; }
Create a new Crypto Key File

@return void
Create a new Crypto Key File