Qt笔记-AES加密
生活随笔
收集整理的這篇文章主要介紹了
Qt笔记-AES加密
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
Qt5.5.1好像沒有,用了三方老外大神的。
https://github.com/bricke/Qt-AES
下載下來后,將對應的源碼拷貝到項目中就可以了。
這里提供個事例代碼:
#include <QCoreApplication> #include <QCryptographicHash> #include <QVector> #include <QDebug> #include "QAesEncryption.h"int main(int argc, char *argv[]) {QCoreApplication a(argc, argv);QString key = "0123456789012345";qDebug() << "key.size : " << key.toUtf8().size();QString string = "Hello World";QAESEncryption encryption(QAESEncryption::AES_128, QAESEncryption::ECB, QAESEncryption::PKCS7);QByteArray enBA = encryption.encode(string.toUtf8(), key.toUtf8());QByteArray enBABase64 = enBA.toBase64();qDebug() << "string : " << string;qDebug() << "enBA : " << enBABase64;enBA = QByteArray::fromBase64(enBABase64);QByteArray deBA = encryption.decode(enBA, key.toUtf8());//移除填充qDebug() << "deBA : " << QAESEncryption::RemovePadding(deBA, QAESEncryption::PKCS7);return a.exec(); }?運行結果如下:
總結
以上是生活随笔為你收集整理的Qt笔记-AES加密的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Qt文档阅读笔记-QLibrary基本概
- 下一篇: HTTPS-客户端与服务器三次握手过程(