同步操作将从 陈炳煌/sqlitebrowser 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#include "CipherDialog.h"#include "ui_CipherDialog.h"#include "sqlitedb.h"#include <QPushButton>#include <QRegExpValidator>#include <QtCore/qmath.h>CipherDialog::CipherDialog(QWidget* parent, bool encrypt) :QDialog(parent),ui(new Ui::CipherDialog),encryptMode(encrypt),rawKeyValidator(new QRegExpValidator(QRegExp("0x[a-fA-F0-9]+"))){ui->setupUi(this);int minimumPageSizeExponent = 9;int maximumPageSizeExponent = 16;int defaultPageSizeExponent = 10;for(int exponent = minimumPageSizeExponent; exponent <= maximumPageSizeExponent; exponent++){int pageSize = static_cast<int>(qPow(2, exponent));ui->comboPageSize->addItem(QLocale().toString(pageSize), pageSize);if (exponent == defaultPageSizeExponent)ui->comboPageSize->setCurrentIndex(exponent - minimumPageSizeExponent);}ui->comboPageSize->setMinimumWidth(ui->editPassword->width());if(encrypt){ui->labelDialogDescription->setText(tr("Please set a key to encrypt the database.\nNote that if you change any of the other, optional, settings you'll need ""to re-enter them as well every time you open the database file.\nLeave the password fields empty to disable the ""encryption.\nThe encryption process might take some time and you should have a backup copy of your database! Unsaved ""changes are applied before modifying the encryption."));} else {ui->labelDialogDescription->setText(tr("Please enter the key used to encrypt the database.\nIf any of the other settings were altered for this database file ""you need to provide this information as well."));ui->editPassword2->setVisible(false);ui->labelPassword2->setVisible(false);}// Set the default encryption settings depending on the SQLCipher version we useQString sqlite_version, sqlcipher_version;DBBrowserDB::getSqliteVersion(sqlite_version, sqlcipher_version);if(sqlcipher_version.startsWith('4'))ui->radioEncryptionSqlCipher4->setChecked(true);elseui->radioEncryptionSqlCipher3->setChecked(true);}CipherDialog::~CipherDialog(){delete rawKeyValidator;delete ui;}CipherSettings CipherDialog::getCipherSettings() const{CipherSettings::KeyFormats keyFormat = CipherSettings::getKeyFormat(ui->comboKeyFormat->currentIndex());QString password = ui->editPassword->text();int pageSize = ui->comboPageSize->itemData(ui->comboPageSize->currentIndex()).toInt();CipherSettings cipherSettings;cipherSettings.setKeyFormat(keyFormat);cipherSettings.setPassword(password);cipherSettings.setPageSize(pageSize);cipherSettings.setKdfIterations(ui->spinKdfIterations->value());cipherSettings.setHmacAlgorithm(QString("HMAC_") + ui->comboHmacAlgorithm->currentText());cipherSettings.setKdfAlgorithm(QString("PBKDF2_HMAC_") + ui->comboKdfAlgorithm->currentText());return cipherSettings;}void CipherDialog::checkInputFields(){if(sender() == ui->comboKeyFormat){CipherSettings::KeyFormats keyFormat = CipherSettings::getKeyFormat(ui->comboKeyFormat->currentIndex());if(keyFormat == CipherSettings::KeyFormats::Passphrase){ui->editPassword->setValidator(nullptr);ui->editPassword2->setValidator(nullptr);ui->editPassword->setPlaceholderText("");} else if(keyFormat == CipherSettings::KeyFormats::RawKey) {ui->editPassword->setValidator(rawKeyValidator);ui->editPassword2->setValidator(rawKeyValidator);ui->editPassword->setPlaceholderText("0x...");}ui->editPassword->setText("");ui->editPassword2->setText("");}bool valid = true;if(encryptMode)valid = ui->editPassword->text() == ui->editPassword2->text();ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(valid);}void CipherDialog::toggleEncryptionSettings(){if(ui->radioEncryptionSqlCipher3->isChecked()){// SQLCipher3ui->comboPageSize->setCurrentText(QLocale().toString(1024));ui->spinKdfIterations->setValue(64000);ui->comboHmacAlgorithm->setCurrentText("SHA1");ui->comboKdfAlgorithm->setCurrentText("SHA1");ui->comboPageSize->setEnabled(false);ui->spinKdfIterations->setEnabled(false);ui->comboHmacAlgorithm->setEnabled(false);ui->comboKdfAlgorithm->setEnabled(false);} else if(ui->radioEncryptionSqlCipher4->isChecked()) {// SQLCipher4ui->comboPageSize->setCurrentText(QLocale().toString(4096));ui->spinKdfIterations->setValue(256000);ui->comboHmacAlgorithm->setCurrentText("SHA512");ui->comboKdfAlgorithm->setCurrentText("SHA512");ui->comboPageSize->setEnabled(false);ui->spinKdfIterations->setEnabled(false);ui->comboHmacAlgorithm->setEnabled(false);ui->comboKdfAlgorithm->setEnabled(false);} else if(ui->radioEncryptionCustom->isChecked()) {// Customui->comboPageSize->setEnabled(true);ui->spinKdfIterations->setEnabled(true);ui->comboHmacAlgorithm->setEnabled(true);ui->comboKdfAlgorithm->setEnabled(true);}}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。