qt讀取ini配置文件 如何使用Qt加密解密類庫(kù)QCA?
如何使用Qt加密解密類庫(kù)QCA?下載:類庫(kù)和插件:crypto copy to:QT installation directorydesktopQT4.7.4MinGWpluginscrypto qt
如何使用Qt加密解密類庫(kù)QCA?
下載:類庫(kù)和插件:crypto copy to:QT installation directorydesktopQT4.7.4MinGWpluginscrypto qtfeautre:feature copy to:QT installation directorydesktopQT4.7.4MinGWmkspecsfeatures使用類庫(kù)時(shí),需要:1。將“config=crypto”添加到QT項(xiàng)目文件Pro 2中。將“openssl-win32bin”目錄中的ssleay32.dll和libeay32.dll復(fù)制到項(xiàng)目的調(diào)試或發(fā)布目錄。三。將“qca-2.0.3lib”目錄和“qca-ossl-2.0.0-beta3lib”目錄復(fù)制到項(xiàng)目的調(diào)試或發(fā)布目錄。4在程序中使用QCA之前,請(qǐng)使用QCA::initializerinit初始化QCA
~]#<qcryptographicshash>
#include<QSettings>
#include<QDebug>
//生成MD5 Hash
QString testustring(“MD5 Hash的測(cè)試字符串”)
QByteArray MD5uhash
MD5uhash=qcryptographicshash::Hash(testu字符串.toUtf8(), qcryptographicshash::Md5)
QString md5hashuu字符串=Md5u哈希.toHex()
qDebug()<<“MD5 Hash:”<< md5hashuu字符串
//寫(xiě)入MD5u哈希.ini
QSettings md5writeFile(QString(“md5u哈希.ini“”,QSettings::IniFormat)
md5writeFile.setValue(QLatin1String(“MD5 Hash”),MD5uhash)
MD5writeFile.sync文件()
//從md5讀取哈希.ini
QSettings md5readFile(QString(“md5u哈希.ini“”,QSettings::IniFormat)
md5讀取文件.sync()
如果(真==md5readFile.contains文件(“MD5 Hash”){
QByteArray MD5 array=MD5readFile.value文件(“MD5 Hash”).toByteArray()
qDebug()<<“從文件讀取的MD5 Hash:”<< MD5數(shù)組.toHex()
}以上代碼純手工敲打和QT驗(yàn)證,請(qǐng)珍惜使用。