Does Qt support rsa encryption,QSslkey seems doesn't work. thanks in advance.
Qt supports RSA for SSL-connections. There are no interfaces to use RSA keys directly.
You could take a look at the Qt Cryptographic Architecture project, but it does not look to be maintained anymore.
Qt is supporting RSA encryption. You have to indicate to QSslKey the correct algorithm used: http://doc.qt.io/qt-5/qssl.html#KeyAlgorithm-enum
If you want encrypt data without ssl dependencies then you can use my library Qt-Secret. This library supports the qmake build system, which makes it very easy to connect to your project.
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
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With