Qt是否支持RSA加密,看起来QSslkey无法工作。谢谢。
Qt支持RSA加密。您需要向QSslKey指示所使用的正确算法:http://doc.qt.io/qt-5/qssl.html#KeyAlgorithm-enum
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
Include in your pro file the pri file of Qt-Secret library:
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
Add the rule to build Qt-Secret.
INCLUDEPATH
and LIBS
for your build system .#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
}