mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-20 11:00:44 -06:00
Add automatic crypted databases open via dotenvs (#1404)
* Rename confusing variables
* Fix some project warnings
* Fix code style
* Add constant for the default page size
* Move KeyFormats enum to CipherSettings
* Fix code style
* Fix memory leak
* Stop relying on CipherDialog for encryption settings management
* Fix code style
* Add .env format for QSettings
* Add automatic crypted databases open via dotenvs
This adds support for `.env` files next to the crypted databases that
are to be opened that contains the needed cipher settings.
The only required one is the plain-text password as a value for the key
with the name of the database like this:
myCryptedDatabase.sqlite = MyPassword
This way, databases with a different extension are supported too:
myCryptedDatabase.db = MyPassword
You can also specify a custom page size adding a different line
(anywhere in the file) like this:
myCryptedDatabase.db_pageSize = 2048
If not specified, `1024` is used.
You can also specify the format of the specified key using the
associated integer id:
anotherCryptedDatabase.sqlite = 0xCAFEBABE
anotherCryptedDatabase.sqlite_keyFormat = 1
where `1` means a Raw key. If not specified, `0` is used, which means a
simple text Passphrase.
Dotenv files (`.env`) are already used on other platforms and by
different tools to manage environment variables, and it's recommended
to be ignored from version control systems, so they won't leak.
* Add new files to CMakeLists
* Move DotenvFormat include to the implementation
* Fix build error
* Remove superfluous method
(related to ac51c23)
* Remove superfluous checks
* Fix memory leaks
(introduced by 94bbb46)
* Fix code style
* Make dotenv related variable and comment clearer
* Remove duplicated code
* Remove unused forward declaration
(introduced by e5a0293)
This commit is contained in:
committed by
Martin Kleusberg
parent
c861f1b9d9
commit
3cdc65a63f
@@ -2530,8 +2530,8 @@ void MainWindow::updateFilter(int column, const QString& value)
|
||||
void MainWindow::editEncryption()
|
||||
{
|
||||
#ifdef ENABLE_SQLCIPHER
|
||||
CipherDialog dialog(this, true);
|
||||
if(dialog.exec())
|
||||
CipherDialog cipherDialog(this, true);
|
||||
if(cipherDialog.exec())
|
||||
{
|
||||
// Show progress dialog even though we can't provide any detailed progress information but this
|
||||
// process might take some time.
|
||||
@@ -2553,14 +2553,16 @@ void MainWindow::editEncryption()
|
||||
file.close();
|
||||
}
|
||||
|
||||
CipherSettings cipherSettings = cipherDialog.getCipherSettings();
|
||||
|
||||
// Attach a new database using the new settings
|
||||
qApp->processEvents();
|
||||
if(ok)
|
||||
ok = db.executeSQL(QString("ATTACH DATABASE '%1' AS sqlitebrowser_edit_encryption KEY %2;").arg(db.currentFile() + ".enctemp").arg(dialog.password()),
|
||||
ok = db.executeSQL(QString("ATTACH DATABASE '%1' AS sqlitebrowser_edit_encryption KEY %2;").arg(db.currentFile() + ".enctemp").arg(cipherSettings.getPassword()),
|
||||
false, false);
|
||||
qApp->processEvents();
|
||||
if(ok)
|
||||
ok = db.executeSQL(QString("PRAGMA sqlitebrowser_edit_encryption.cipher_page_size = %1").arg(dialog.pageSize()), false, false);
|
||||
ok = db.executeSQL(QString("PRAGMA sqlitebrowser_edit_encryption.cipher_page_size = %1").arg(cipherSettings.getPageSize()), false, false);
|
||||
|
||||
// Export the current database to the new one
|
||||
qApp->processEvents();
|
||||
|
||||
Reference in New Issue
Block a user