zoukankan      html  css  js  c++  java
  • QT AES加密

    一、

    使用库:https://github.com/bricke/Qt-AES

    二、代码举例

    #include <QCryptographicHash>
    复制代码
    void MainWindow::on_pushButton_clicked()
    {
        QAESEncryption encryption(QAESEncryption::AES_128, QAESEncryption::ECB, QAESEncryption::ZERO);
    
        QString key="12345";
        QString date="20200730";
        QString data="BFEBFBFF000406F1Z9ABXEMP"+date;
    
        QByteArray hashKey = QCryptographicHash::hash(key.toUtf8(), QCryptographicHash::Md5);
        QByteArray encodedText = encryption.encode(data.toUtf8(), hashKey);
        QString str_encode_text=QString::fromLatin1(encodedText.toBase64());
        qDebug()<<"encodedText:"<<str_encode_text;
    
    
    
        //QAESEncryption encryption(QAESEncryption::AES_128, QAESEncryption::ECB, QAESEncryption::ZERO);
        QByteArray hashKey2 = QCryptographicHash::hash(key.toUtf8(), QCryptographicHash::Md5);
        QByteArray decodedText = encryption.decode(QByteArray::fromBase64(str_encode_text.toLatin1()), hashKey2);
        qDebug()<<"decodedText:"<<QString::fromLatin1(decodedText);
        
    }
    复制代码
  • 相关阅读:
    取最小未用的账号
    Oracle 同义词
    RMAN备份报 RMAN-06059 错误
    Oracle11g memory_target
    基础记录
    uboot启动流程
    android有关生命周期探讨
    can协议
    java虚拟机
    内存管理机制
  • 原文地址:https://www.cnblogs.com/chinasoft/p/15242157.html
Copyright © 2011-2022 走看看