Base64 로 인코딩된 파일을 복호화하고 파일로 쓰기
텍스트 파일로 쓰기
#include <QFile>
#include <QByteArray>
#include <QDebug>
void write(QString filename)
{
QFile file(filename);
// Trying to open in WriteOnly
if(!file.open(QFile::WriteOnly))
{
qDebug() << " Could not open file for writing";
return;
}
file.write(QByteArray::fromBase64("aGVsbG8gbWFrZXJzd2ViLm5ldA=="));
file.flush();
file.close();
}
int main()
{
write("helloworld.txt");
}
이미지 파일로 쓰기
#include <QFile>
#include <QByteArray>
#include <QDebug>
void write(QString filename)
{
QFile file(filename);
// Trying to open in WriteOnly
if(!file.open(QFile::WriteOnly))
{
qDebug() << " Could not open file for writing";
return;
}
file.write(QByteArray::fromBase64("iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAACK1BMVEUAAAAXSx4YTB8CAAABAAABAgEBBAICBgMAAQAJHQwCaTEBCwUIGQoAQyAvlT0AWisOLhMBBQMBBgMBHA0BFQoECQRQ/2wvnD7//9MCCAMFEQb3xZZ6ZE8EAwP//////8izj2wODQsLIw4TQxwAAAABPBwAQR8AAQICAAEAKhQBAwEAAAAWPBgTZCwHlkYDSiMDAAACCAQIGgoGFQgIGQo5w1Enqkg1sklAxlEANBoCJREBVikAAAAAAAAdXSY4sUk6tUoxrkgAVSgDAAAAAAASOBcIGAo+xFAwtEsAJhIAUScvlj0UQRo5tEkxskoALRUBYS4JHAsAAAA/ylI4skk7vE00p0Q8v00uq0gVq0wDAAAAEggGFAgAAAAjby41q0YMFwsNCQYCfzwAQiABSyMBAAABDwcMJxACCAMDCAMeYigRKRIzIBkvIxwDFAsANBgDAAAAAAABBQMBBQI1IxsAAABAMiM+MycAAAAFAAECNBgBFwsLIQ4HEQcAAAA0KB4yKSBPoF8CAQG/l3AvJRsvJx95ZFAwJhwwKB7YroUCAQE3Kh45LiQQDgwOCwg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