C++ Decryption

Well Alice, the good news is, your first encrypted file is so safe, only you can decrypt it. Let’s confirm that with your protected file. Then, we’ll grant access to someone you trust.

Meet Secure Reader, the easiest way to decrypt

Opening a protected HTML file will take you to Virtru’s Secure Reader.

Authenticating with Virtru Secure Reader

Secure Reader will also ask you to authenticate. Again, no one trusts that you’re Alice. But trust us, it’s good for security. If Mallory tries to authenticate, he won’t see your sensitive data.

But if you authenticate, Secure Reader will render your file.

Authenticating with Virtru Secure Reader

If Secure Reader can’t render the file, you will still be able to download it.

Decrypting via SDK

Outside of Secure Reader, you can also decrypt a file via the SDK:

#include <virtru_client.h>
#include <cstdlib>
#include <iostream>

using namespace virtru;

int main()
{
    auto email = std::getenv("VIRTRU_SDK_EMAIL");
    auto appId = std::getenv("VIRTRU_SDK_APP_ID");
    if (email == nullptr || appId == nullptr) {
        std::cerr << "An environment variable is not set:\n- VIRTRU_SDK_EMAIL\n- VIRTRU_SDK_APP_ID" << std::endl;
        return EXIT_FAILURE;
    }
    Client client {email, appId};

    std::string protectedFile = "sensitive.docx.tdf.html";
    std::string unprotectedFile = "sensitive_decrypted.docx";
    client.decryptFile(protectedFile, unprotectedFile);

    std::cout << "Decrypted file " << unprotectedFile << std::endl;
    return EXIT_SUCCESS;
}

Allowing others to decrypt

But let’s say you wanted to share your sensitive data with your trusted colleague Bob, whose email is [email protected].

For existing files, you would grant access to [email protected] and save the changes to the Virtru Platform.

Policy policy;
policy.shareWithUsers({"[email protected]"});

client.updatePolicyForFile(policy, "sensitive.docx.tdf.html");

Now, [email protected] should be able to view your sensitive data in Secure Reader (anywhere) or via the SDK decrypt call (in your apps).

When protecting new files, you can grant access to Bob or any number of users as part of encryption params:

Policy policy;
policy.shareWithUsers({"[email protected]"});
EncryptFileParams params {"sensitive.docx", "sensitive.docx.tdf.html"};
params.setPolicy(policy);

client.encryptFile(params);

Updated about a year ago


C++ Decryption


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.