Skip to content

How to decrypt file using CryptFileDevice? #7

Description

@y-a-r-i-k

Hello!
I am using the cryptFileDevice class and the code below to encrypt a file. Please tell me how to decrypt the received file using cryptFileDevice?

QFile file(filePath);
    if (!file.open(QIODevice::ReadOnly))
    {
        QMessageBox::warning(this, qApp->applicationName(), "Cannot open the file");
        return;
    }

    CryptFileDevice cryptFileDevice;
    cryptFileDevice.setFileName(filePath + ".e");
    cryptFileDevice.setPassword(QByteArrayLiteral("databasepass")); //Here is a problem with password!!!!
    cryptFileDevice.setSalt(QByteArrayLiteral("salt"));

    if(!cryptFileDevice.open(QIODevice::WriteOnly | QIODevice::Truncate))
    {
        QMessageBox::warning(this, qApp->applicationName(), "Cannot encrypt file");
        return;
    }

    cryptFileDevice.write(file.readAll());

    file.close();
    cryptFileDevice.close();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions