Build with the Virtru Developer Hub

It's Your Data. Protect It. Control It. Everywhere.

Try the Demo          Learn More     

How to Decrypt a File

Decrypting a previously protected file is easy with the Virtru SDK. Provided authentication has been implemented (see How to Add Authentication), you can decrypt a file with just a few lines of code:

Decrypt Using the Virtru Secure Reader

You (or your app's users) can also decrypt files using Virtru's Secure Reader. Click here to see how.

// Configure the parameters to decrypt a local file.
const decryptParams = new Virtru.DecryptParamsBuilder()
  .withFileSource('/tmp/statement.pdf.html')
  .build();

// Run the decrypt.
const stream = await client.decrypt(decryptParams);

// Write the plaintext to a .pdf file
await stream.toFile('/tmp/statement.pdf');
from virtru_tdf3_python import Client

# two authentication methods are supported: 
# (a) HMAC sent by your Virtru Rep (b) AppId Token that you can copy from Virtru Dashboard.

# Create an instance of Virtru client using HMAC auth.
client = Client(owner = "bob@example.com",
                app_id = "12345678-1234-1234-1234-123456789012")

# Create an instance of Virtru client using AppId copied from Dashboard.
# client = Client(owner="bob@example.com",
#                api_key="12345678-1234-1234-1234-123456789012@tokens.example.com",
#                secret="somesecret==")

# decrypt the file.
client.decrypt_file(in_file_path = "sample.docx.html",
                    out_file_path = "sample.docx")
#include <virtru_client.h>
// two authentication methods are supported: 
// (a) HMAC sent by your Virtru Rep (b) AppId Token that you can copy from Virtru Dashboard.

// Create an instance of Virtru client using HMAC auth.
Client client {"bob@example.com", // Owner
               "12345678-1234-1234-1234-123456789012@tokens.example.com", // token
               "somesecret="}; // secret
// Create an instance of Virtru client using AppId bundle downloaded from Dashboard.
// Client client {"bob@example.com", "12345678-1234-1234-1234-123456789012"};


// Decrypt the file.
client.decryptFile("sample.docx.html", "sample.docx");  

Note About Watermarked Files

Please note that watermarked files cannot be decrypted using the Virtru SDK. You or your end users can still decrypt files using the Virtru Secure Reader.

How to Decrypt a File


Suggested Edits are limited on API Reference Pages

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