简体   繁体   English

Qt是否支持RSA加密?

[英]Does Qt support RSA encryption?

Does Qt support rsa encryption,QSslkey seems doesn't work. Qt是否支持rsa加密,QSslkey似乎不起作用。 thanks in advance. 提前致谢。

Qt supports RSA for SSL-connections. Qt支持RSA进行SSL连接。 There are no interfaces to use RSA keys directly. 没有接口可以直接使用RSA密钥。

You could take a look at the Qt Cryptographic Architecture project , but it does not look to be maintained anymore. 您可以查看Qt Cryptographic Architecture项目 ,但它看起来不再需要维护。

Qt is supporting RSA encryption. Qt支持RSA加密。 You have to indicate to QSslKey the correct algorithm used: http://doc.qt.io/qt-5/qssl.html#KeyAlgorithm-enum 您必须向QSslKey指出使用的正确算法: 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 . 如果你想加密没有ssl依赖的数据,那么你可以使用我的库Qt-Secret This library supports the qmake build system, which makes it very easy to connect to your project. 该库支持qmake构建系统,这使得连接到项目变得非常容易。


For example: 例如:

Build 建立

  •  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) 

Include 包括

For qmake projects 对于qmake项目

  •  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: 在您的pro文件中包含Qt-Secret库的pri文件:

     include($$PWD/Qt-Secret/src/Qt-Secret.pri) 
  • Rebuild your project. 重建您的项目。

For other build systems 对于其他构建系统

  •  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. 添加规则以构建Qt-Secret。

  • Add INCLUDEPATH and LIBS for your build system . 为构建系统添加INCLUDEPATHLIBS
  • Rebuild your project. 重建您的项目。

Usage 用法

RSA RSA

Encryption and decryption of messages. 消息的加密和解密。

#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);

Signature and verification of the message signature. 签名和验证消息签名。

#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
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM