代码拉取完成,页面将自动刷新
同步操作将从 qingfengfumeng/文件软硬件加解密平台 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#include "AESwidget.h"
#include "ui_AESwidget.h"
#include <QFileDialog>
#include <QMessageBox>
#include <QFile>
AESwidget::AESwidget(QWidget *parent):
QWidget(parent),
ui(new Ui::AESwidget)
{
ui->setupUi(this);
#if _MSC_VER >= 1600
#pragma execution_character_set("utf-8") // 解决中文乱码问题
#endif
ui->progressBar->setRange(0, 100); // 设置进度条的范围从0到100
ui->progressBar->setValue(0); // 初始化进度条的值为0
//设置信号
connect(ui->genpushButton, SIGNAL(clicked()), this, SLOT(genpushButton_click()));
connect(ui->filepushButton, SIGNAL(clicked()), this, SLOT(filepushButton_click()));
connect(ui->keypushButton, SIGNAL(clicked()), this, SLOT(keypushButton_click()));
connect(ui->encryptpushButton, SIGNAL(clicked()), this, SLOT(encryptpushButton_click()));
connect(ui->decryptpushButton, SIGNAL(clicked()), this, SLOT(decryptpushButton_click()));
connect(ui->backpushButton, SIGNAL(clicked()), this, SLOT(backpushButton_click()));
}
AESwidget::~AESwidget()
{
delete ui;
}
void AESwidget::on_genpushButton_clicked()
{
QString folderPath = QFileDialog::getExistingDirectory(this, "Select Folder", QDir::homePath());
if (!folderPath.isEmpty())
{
QString fileName = folderPath + "/key.txt";
QFile file(fileName);
std::string filePathStr = fileName.toStdString();
aes.genKey(filePathStr);
// 更新进度条的值
ui->progressBar->setValue(100);
QMessageBox::information(this, "Success", "密钥生成成功!");
ui->textBrowser->append("生成的密钥存储在: " + fileName);
}
}
void AESwidget::on_filepushButton_clicked()
{
QString filePath = QFileDialog::getOpenFileName(this, "Open File", QDir::homePath(), "Text files (*.txt)");
if (!filePath.isEmpty())
{
ui->progressBar->setValue(0);
infile_path = filePath.toStdString();
ui->filelineEdit->setText(filePath);
ui->textBrowser->append("选择文件: " + filePath);
}
}
void AESwidget::on_keypushButton_clicked()
{
QString filePath = QFileDialog::getOpenFileName(this, "Open File", QDir::homePath(), "Text files (*.txt)");
if (!filePath.isEmpty())
{
ui->progressBar->setValue(0);
key_path = filePath.toStdString();
ui->keylineEdit->setText(filePath);
aes.getKey(key_path);
ui->textBrowser->append("密钥文件: " + filePath);
}
}
void AESwidget::on_encryptpushButton_clicked()
{
QString folderPath = QFileDialog::getExistingDirectory(this, "Select Folder", QDir::homePath());
if (!folderPath.isEmpty())
{
QString fileName = folderPath + "/encrypted_file.txt";
QFile file(fileName);
std::string outfile_path = fileName.toStdString();
aes.encrypt_file(infile_path, outfile_path);
ui->progressBar->setValue(100);
QMessageBox::information(this, "Success", "文件加密成功!");
ui->textBrowser->append("加密后的文件存放路径: " + fileName);
}
}
void AESwidget::on_decryptpushButton_clicked()
{
QString folderPath = QFileDialog::getExistingDirectory(this, "Select Folder", QDir::homePath());
if (!folderPath.isEmpty())
{
QString fileName = folderPath + "/decrypted_file.txt";
QFile file(fileName);
std::string outfile_path = fileName.toStdString();
aes.decrypt_file(infile_path, outfile_path);
ui->progressBar->setValue(100);
QMessageBox::information(this, "Success", "文件解密成功!");
ui->textBrowser->append("解密后的文件存放路径: " + fileName);
}
}
void AESwidget::on_backpushButton_clicked()
{
emit sendsignal();
this->close();
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。