【发布时间】:2011-05-13 17:38:54
【问题描述】:
Qt 是否支持 rsa 加密,QSslkey 似乎不起作用。 提前致谢。
【问题讨论】:
标签: qt encryption rsa
Qt 是否支持 rsa 加密,QSslkey 似乎不起作用。 提前致谢。
【问题讨论】:
标签: qt encryption rsa
Qt 支持 RSA 进行 SSL 连接。没有直接使用 RSA 密钥的接口。
您可以查看Qt Cryptographic Architecture project,但它看起来不再需要维护了。
【讨论】:
Qt 支持 RSA 加密。您必须向 QSslKey 指明使用的正确算法:http://doc.qt.io/qt-5/qssl.html#KeyAlgorithm-enum
【讨论】:
如果你想加密没有 ssl 依赖的数据,那么你可以使用我的库 Qt-Secret。 该库支持 qmake 构建系统,可以非常轻松地连接到您的项目。
git clone 'https://github.com/QuasarApp/Qt-Secret.git'
cd Qt-Secret
git submodule update --init --recursive
qmake -r
make -j8
make test #(for testing)
cd yourRepo
git submodule add https://github.com/QuasarApp/Qt-Secret.git # add the repository of Qt-Secret into your repo like submodule
git submodule update --init --update
在你的 pro 文件中包含 Qt-Secret 库的 pri 文件:
include($$PWD/Qt-Secret/src/Qt-Secret.pri)
cd yourRepo
git submodule add https://github.com/QuasarApp/Qt-Secret.git # add the repository of Qt-Secret into your repo like submodule
git submodule update --init --update
添加规则以构建 Qt-Secret。
INCLUDEPATH 和LIBS。#include <qrsaencryption.h>
QByteArray pub, priv;
QRSAEncryption e(QRSAEncryption::Rsa::RSA_2048);
e.generatePairKey(pub, priv);
QByteArray msg = "test message";
auto encodeData = e.encode(msg, pub);
auto decodeData = e.decode(encodeData, priv);
#include <qrsaencryption.h>
QByteArray pub, priv;
QRSAEncryption e;
e.generatePairKey(pub, priv, QRSAEncryption::Rsa::RSA_128); // or other rsa size
QByteArray msg = "test message";
auto signedMessage = e.signMessage(msg, priv);
if (e.checkSignMessage(signedMessage, pub)) {
// message signed success
}
【讨论】: