Qt RSA OpenSSL C++ Qt加密解密签字通信系统窗体源码

简介: Qt RSA OpenSSL C++ Qt加密解密签字通信系统窗体源码
程序示例精选
Qt RSA OpenSSL C++ Qt加密解密签字通信系统窗体源码
如需安装运行环境或远程调试,可点击
博主头像进入个人主页查看博主联系方式,由专业技术人员远程协助!

前言

这篇博客针对《Qt RSA OpenSSL C++ Qt加密解密签字通信系统窗体源码》编写代码,代码整洁,规则,易读。 学习与应用推荐首选。

运行结果

文章目录

一、所需工具软件
二、使用步骤
1. 主要代码
2. 运行结果

三、在线协助

一、所需工具软件

1. VS2019, C++
2. QT

二、使用步骤

代码如下(示例):

//加密
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
{
   
   
    ui.setupUi(this);

    QObject::connect(ui.pushButton, SIGNAL(clicked()), this, SLOT(TestRSAEncode_sendout()));
    QObject::connect(ui.pushButton_2, SIGNAL(clicked()), this, SLOT(receiver()));

}


void MainWindow::TestRSASign()
{
   
   
    GenerateKeyEx();
    string strData = "orderId=01010500201502000004reqTime=20150205012727ext=20151120ext2=1";
    string strSigned;
    if (RSASignAction(strData, strSigned))
    {
   
   
        printf("加签成功\n");
        if (RSAVerifyAction(strData, strSigned))
        {
   
   
            printf("验签成功\n");
        }

    }
}


//发送
string strEncode;
string strDecode;
void MainWindow::TestRSAEncode_sendout()
{
   
   

    TestRSASign();

    //

    QString sendoutWord = QString("%1").arg(ui.textEdit->toPlainText());
    string strEncodeData = sendoutWord.toStdString();
    //string strEncodeData = "你好吗";


    GenerateKey();
    strEncode = EncodeByBioPublicKey(strEncodeData);
    strDecode = DecodeByBioPrivateKey(strEncode);

    printf("Old data:%s\n", strEncodeData.c_str());
    printf("Encode data:%s\n", strEncode.c_str());
    printf("Decode data:%s\n", strDecode.c_str());


    std::string encoded64 = base64_encode((const char*)(strEncode.c_str()), strEncode.length());
    std::cout << "base64encodedtxt:" << encoded64 << std::endl;


    QFile::remove("saveSendOut.txt");
    QFile filetxt(QString::fromStdString("saveSendOut_server.txt"));
    if (filetxt.open(QIODevice::WriteOnly))
    {
   
   
        QTextStream out(&filetxt);
        out.setCodec("UTF-8");
        out.flush();

    }
    filetxt.close();

    std::string dir555 = "saveSendOut_server.txt";
    std::string filePathCopy = "../client-exe/saveSendOut_server.txt";
    std::string filePathCopy2 = "../client-exe/private.pem";

    //std::string filePathCopy = "D:/saveSendOut.txt";
    QFile::remove(QString::fromStdString(filePathCopy));
    QFile::remove(QString::fromStdString(filePathCopy2));
    QFile::copy(QString::fromStdString(dir555), QString::fromStdString(filePathCopy));
    QFile::copy(QString::fromStdString("private.pem"), QString::fromStdString(filePathCopy2));
}


inline string readFile(const string& filename) 
{
   
   
    ifstream in(filename);
    istreambuf_iterator<char> begin(in), end;
    string content(begin, end);
    in.close();
    return content;
}
void MainWindow::receiver()
{
   
   
    //自接收
    string strDecode = DecodeByBioPrivateKey(strEncode);
    std::cout << "strDecode: " << strDecode << std::endl;
    ui.textEdit_2->setPlainText(title2);
    ui.textEdit_4->append(QString::fromStdString("自接收解密: ") + strDecode.c_str());

    //远程接收
    //QFile file(QString::fromStdString("saveSendOut.txt"));
    //if (file.open(QFile::ReadOnly | QFile::Text))
    //{
   
   
    //    QTextStream fs(&file);
    //    QString fileContent(fs.readAll());
    //    std::cout << "fileContent: " << fileContent.toStdString() << std::endl;

    //    string strDecodeRemotion = DecodeByBioPrivateKey(fileContent.toStdString());
    //    ui.textEdit_4->append(QString::fromStdString("远程接收解密: ") + strDecodeRemotion.c_str());
    //}
    //file.close();

    //远程接收

    string content = readFile("saveSendOut.txt");
    std::string decoded64 = base64_decode(content);
    string strDecodeRemotion = DecodeByBioPrivateKey(decoded64);
    ui.textEdit_4->append(QString::fromStdString("远程接收解密: ") + strDecodeRemotion.c_str());

}

运行结果

三、在线协助:

如需安装运行环境或远程调试,可点击博主头像,进入个人主页查看博主联系方式,由专业技术人员远程协助!

1)远程安装运行环境,代码调试
2)Visual Studio, Qt, C++, Python编程语言入门指导
3)界面美化
4)软件制作

博主个人主页:https://developer.aliyun.com/profile/expert/rfnzgp3sk3ahc
博主所有文章点这里:https://developer.aliyun.com/profile/expert/rfnzgp3sk3ahc
博主联系方式点这里:https://developer.aliyun.com/profile/expert/rfnzgp3sk3ahc
相关文章
|
3月前
|
安全 网络协议 数据安全/隐私保护
掌握Qt和C++:构建你的第一个P2P应用程序
掌握Qt和C++:构建你的第一个P2P应用程序
206 3
|
5天前
|
网络协议 安全 网络安全
中间人攻击之未加密的通信
【8月更文挑战第12天】
14 2
|
1月前
|
数据安全/隐私保护 C++ 计算机视觉
Qt(C++)开发一款图片防盗用水印制作小工具
文本水印是一种常用的防盗用手段,可以将文本信息嵌入到图片、视频等文件中,用于识别和证明文件的版权归属。在数字化和网络化的时代,大量的原创作品容易被不法分子盗用或侵犯版权,因此加入文本水印成为了保护原创作品和维护知识产权的必要手段。 通常情况下,文本水印可以包含版权声明、制作者姓名、日期、网址等信息,以帮助识别文件的来源和版权归属。同时,为了增强防盗用效果,文本水印通常会采用字体、颜色、角度等多种组合方式,使得水印难以被删除或篡改,有效地降低了盗用意愿和风险。 开发人员可以使用图像处理技术和编程语言实现文本水印的功能,例如使用Qt的QPainter类进行文本绘制操作,将文本信息嵌入到图片中,
99 1
Qt(C++)开发一款图片防盗用水印制作小工具
|
3月前
|
安全 数据安全/隐私保护 Python
【计算巢】端到端加密通信:保障即时通讯的安全性
【5月更文挑战第31天】端到端加密通信确保了信息在传输过程中的安全,防止他人窥探和篡改。只有通信双方能解密消息,类似使用只有两人才能打开的锁。通过一个简单的Python加密代码示例展示了加密原理。理解并掌握端到端加密对于保护个人及企业信息安全至关重要。在信息时代,注重隐私和安全,利用加密技术保障通信安全。
44 1
|
22天前
|
存储 网络安全 数据安全/隐私保护
[flask]使用mTLS双向加密认证http通信
【7月更文挑战第16天】在Flask应用中实现mTLS双向TLS加密认证可增强HTTP通信安全性。步骤包括: 1. 使用OpenSSL为服务器和客户端生成证书和密钥。 2. 配置Flask服务器使用这些证书: - 安装`flask`和`pyopenssl`. - 设置SSL上下文并启用mTLS验证: 注意事项: - 保持证书有效期并及时更新. - 确保证书链信任. - 充分测试mTLS配置.
|
1月前
|
数据可视化 开发者 C++
Qt(C++)使用QChart静态显示3个设备的温度变化曲线
QChart模块是Qt Charts库的基础,提供了用于创建和显示各种类型图表的类和接口。Qt Charts库是一个功能丰富、易于使用的数据可视化工具库,可以帮助开发者在应用程序中添加漂亮而又交互性强的图表。
34 1
Qt(C++)使用QChart静态显示3个设备的温度变化曲线
|
12天前
|
安全 网络安全 数据安全/隐私保护
[flask]使用mTLS双向加密认证http通信
[flask]使用mTLS双向加密认证http通信
|
12天前
|
网络协议 应用服务中间件 Go
[golang]使用mTLS双向加密认证http通信
[golang]使用mTLS双向加密认证http通信
|
1月前
|
存储 JSON 数据可视化
Qt(C++)使用QChart动态显示3个设备的温度变化曲线
Qt的QChart是一个用于绘制图表和可视化数据的类。提供了一个灵活的、可扩展的、跨平台的图表绘制解决方案,可以用于各种应用程序,如数据分析、科学计算、金融交易等。
109 1
|
1月前
|
安全 网络协议 网络安全
SSL(Secure Sockets Layer)是一种安全协议,用于在客户端和服务器之间建立加密的通信通道。
SSL(Secure Sockets Layer)是一种安全协议,用于在客户端和服务器之间建立加密的通信通道。

热门文章

最新文章

推荐镜像

更多