Qt5.9使用Crypto++库(VS2015)

 环境:Qt5.9.7,vs2015,MSVC2015 32bit,cryptopp820.zip

1、下载crypto++源码  https://www.cryptopp.com/release820.html并解压到cryptopp文件夹。

2、vs2015打开cryptopp目录下 cryptest.sln工程文件,有4个项目

                

 

3、设置编译输出为Release(或Debug),四个项目分别右键——>属性——>C/C++——>代码生成——>运行库,改成动态库多线程MD(或者动态库多线程调试MTD),然后在cryptest项目上右键——>生成,等待完成。

 

4、在cryptopp目录下会新增编译目录,动态库文件在cryptopp/Win32/Output/Release( 或Debug)目录下

5、QT新建一个工程,在工程目录下新增目录c++/cryptopp/lib,c++/cryptopp/include, 将cryptlib.lib添加到../cryptopp/lib目录下,将cryptopp目录下的所有.h文件复制到../cryptopp/include目录下,在 Pro中添加头引用和库引用如下:

INCLUDEPATH += "$$PWD/c++/cryptopp/include"
LIBS += -L"$$PWD/c++/cryptopp/lib" -lcryptlib

6、在c++文件中添加测试代码:

//引用头文件
#include "c++/cryptopp/include/md5.h"
#include "c++/cryptopp/include/filters.h"
#include "c++/cryptopp/include/hex.h"

//测试主要代码
std::string text="abc123";
    std::string digest;
        CryptoPP::Weak1::MD5 md5;
        CryptoPP::HashFilter hashfilter(md5);
        hashfilter.Attach(new CryptoPP::HexEncoder(new CryptoPP::StringSink(digest), false));
        hashfilter.Put(reinterpret_cast<const unsigned char*>(text.c_str()), text.length());
        hashfilter.MessageEnd();
        QString tmp= QString::fromStdString(digest);
        qDebug()<<"md5:"<<tmp;
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

超奇电子

你的鼓励是我创作的动力。

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值