public function generateKeys(bool
$override = false
): bool
{ $this->lastMessage = null;
if (null ===
$this->encryptionKey && '' !==
$this->decryptionKey =
(string) $this->decryptionKey
) { $this->lastMessage = 'Cannot generate keys when a decryption key has been provided while instantiating the vault.';
return false;
} try { $this->
loadKeys();
} catch (\RuntimeException
) { // ignore failures to load keys
} if ('' !==
$this->decryptionKey && !
is_file($this->pathPrefix.'encrypt.public.php'
)) { $this->
export('encrypt.public',
$this->encryptionKey
);
} if (!
$override && null !==
$this->encryptionKey
) { $this->lastMessage =
sprintf('Sodium keys already exist at "%s*.{public,private}" and won\'t be overridden.',
$this->
getPrettyPath($this->pathPrefix
));