Encryption - RC4

This commit is contained in:
Jakub Melka
2021-05-29 18:13:30 +02:00
parent 936fe2fbe7
commit e3fecc0568
6 changed files with 399 additions and 7 deletions

View File

@ -128,6 +128,16 @@ void PDFEncryptionSettingsDialog::updateUi()
ui->userPasswordEdit->setEnabled(ui->userPasswordEnableCheckBox->isChecked());
ui->ownerPasswordEdit->setEnabled(ui->ownerPasswordEnableCheckBox->isChecked());
if (!ui->userPasswordEdit->isEnabled())
{
ui->userPasswordEdit->clear();
}
if (!ui->ownerPasswordEdit->isEnabled())
{
ui->ownerPasswordEdit->clear();
}
ui->userPasswordStrengthHintWidget->setEnabled(ui->userPasswordEnableCheckBox->isChecked());
ui->ownerPasswordStrengthHintWidget->setEnabled(ui->ownerPasswordEnableCheckBox->isChecked());
@ -151,4 +161,37 @@ void PDFEncryptionSettingsDialog::updatePasswordScore()
ui->ownerPasswordStrengthHintWidget->setCurrentValue(ownerPasswordScore);
}
void PDFEncryptionSettingsDialog::accept()
{
pdf::PDFSecurityHandlerFactory::SecuritySettings settings;
pdf::PDFSecurityHandlerFactory::EncryptContents encryptContents = pdf::PDFSecurityHandlerFactory::All;
if (ui->encryptAllExceptMetadataRadioButton->isChecked())
{
encryptContents = pdf::PDFSecurityHandlerFactory::AllExceptMetadata;
}
else if (ui->encryptFileAttachmentsOnlyRadioButton->isChecked())
{
encryptContents = pdf::PDFSecurityHandlerFactory::EmbeddedFiles;
}
settings.algorithm = static_cast<const pdf::PDFSecurityHandlerFactory::Algorithm>(ui->algorithmComboBox->currentData().toInt());
settings.encryptContents = encryptContents;
settings.userPassword = ui->userPasswordEdit->text();
settings.ownerPassword = ui->ownerPasswordEdit->text();
settings.permissions = 0;
for (auto item : m_checkBoxToPermission)
{
if (item.first->isChecked())
{
settings.permissions += uint32_t(item.second);
}
}
m_updatedSecurityHandler = pdf::PDFSecurityHandlerFactory::createSecurityHandler(settings);
QDialog::accept();
}
} // namespace pdfviewer