加密
bool getFileContetBase64(const QString& strFilePath,QString &val)
{
bool bRet = false;
if(!strFilePath.isEmpty() && QFileInfo(strFilePath).exists())
{
QFile file(strFilePath);
if(file.open(QIODevice::ReadOnly))
{
val = file.readAll().toBase64();
bRet = true;
}
else
{
qDebug()<<"打开文件失败"<<endl;
}
}
else
{
qDebug()<<"文件路径不存在"<<endl;
}
return bRet;
}
解密
获得解密后的内容显示到QLabel上,假如
void show(QString base64str)
{
QPixmap pixmap;
pixmap.loadFromData(QByteArray::fromBase64(base64str.toLocal8Bit()));
ui.label->setPixmap(pixmap);
}