34 Star 68 Fork 28

qingfengfumeng/文件软硬件加解密平台

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
ZUCwidget.cpp 3.80 KB
一键复制 编辑 原始数据 按行查看 历史
qingfengfumeng 提交于 2025-03-31 19:21 +08:00 . 增加ZUC前端代码设计
#include "ZUCwidget.h"
#include "ui_ZUCwidget.h"
#include <QFileDialog>
#include <QMessageBox>
#include <QFile>
ZUCwidget::ZUCwidget(QWidget *parent):
QWidget(parent),
ui(new Ui::ZUCwidget)
{
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()));
}
ZUCwidget::~ZUCwidget()
{
delete ui;
}
void ZUCwidget::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();
zuc.genKey(filePathStr);
// 更新进度条的值
ui->progressBar->setValue(100);
QMessageBox::information(this, "Success", "密钥生成成功!");
ui->textBrowser->append("生成的密钥存储在: " + fileName);
}
}
void ZUCwidget::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 ZUCwidget::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);
zuc.getKey(key_path);
ui->textBrowser->append("密钥文件: " + filePath);
}
}
void ZUCwidget::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();
zuc.enc_dec_file(infile_path, outfile_path, 0);
ui->progressBar->setValue(100);
QMessageBox::information(this, "Success", "文件加密成功!");
ui->textBrowser->append("加密后的文件存放路径: " + fileName);
}
}
void ZUCwidget::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();
zuc.enc_dec_file(infile_path, outfile_path, 1);
ui->progressBar->setValue(100);
QMessageBox::information(this, "Success", "文件解密成功!");
ui->textBrowser->append("解密后的文件存放路径: " + fileName);
}
}
void ZUCwidget::on_backpushButton_clicked()
{
emit sendsignal();
this->close();
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/qingfengfumeng/cryptography_file_protection.git
git@gitee.com:qingfengfumeng/cryptography_file_protection.git
qingfengfumeng
cryptography_file_protection
文件软硬件加解密平台
master

搜索帮助