+ ChangeFileEncryption.execute(dbPath, dbName, encryptCipher, Global.cipherPassword.toCharArray(), null, true);
+ Global.setDatabaseUrl("");
+ QMessageBox.information(this, tr("Decryption Complete"), tr("Decryption is complete"));
+ }
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ }
+ /**
+ * Encrypt/Decrypt the local database
+ **/
+ public void doDatabaseEncrypt() {
+ // The database is not currently encrypted
+ if (Global.getDatabaseUrl().toUpperCase().indexOf("CIPHER=") == -1) {
+ if (QMessageBox.question(this, tr("Confirmation"), tr("Encrypting the database is used" +
+ "to enhance security and is performed\nupon shutdown, but please be aware that if"+
+ " you lose the password your\nis lost forever.\n\nIt is highly recommended you " +
+ "perform a backup and/or fully synchronize\n prior to executing this funtction.\n\n" +
+ "Do you wish to proceed?"),
+ QMessageBox.StandardButton.Yes,
+ QMessageBox.StandardButton.No)==StandardButton.No.value()) {
+ return;
+ }
+ DBEncryptDialog dialog = new DBEncryptDialog();
+ dialog.exec();
+ if (dialog.okPressed()) {
+ Global.cipherPassword = dialog.getPassword();
+ encryptOnShutdown = true;
+ encryptCipher = dialog.getEncryptionMethod();
+ }
+ } else {
+ DBEncryptDialog dialog = new DBEncryptDialog();
+ dialog.setWindowTitle("Database Decryption");
+ dialog.hideEncryption();
+ dialog.exec();
+ if (dialog.okPressed()) {
+ if (!dialog.getPassword().equals(Global.cipherPassword)) {
+ QMessageBox.critical(null, tr("Incorrect Password"), tr("Incorrect Password"));
+ return;
+ }
+ decryptOnShutdown = true;
+ encryptCipher = "";
+ }
+ }
+ return;
+ }