Encryption & Decryption Within a Workflow

Posted on October 14, 2022

This guide will walk through the process of a Project (workflow) that encrypts and decrypts a set of files. Typically, these are not actions that would be done in the same Project, but for the sake of this demonstration, both encryption and decryption will be done in one Project.

Getting Started

Text

Before beginning the workflow, the necessary Resources should be set up, and the Public and Private PGP keys should exist in the Key Management System. This specific Workflow will also make use of a temporary Workspace, so the Create Workspace Task is added at the beginning of the Project. A Timestamp Variable called ${Today} is also defined.

The Encrypt Task

Text

The PGP Encrypt Task will begin the encryption portion of the Project. Start off by selecting the file, File Variable, or directory of files to encrypt. This example creates a list of files in the “hkath” directory, using filters to only pick up files that start with “My” and are type .PDF.

The next decision is where to put the files once they are encrypted. This example will output the encrypted files in the Workspace that was created earlier. However, a common option is to output the files directly where they need to be sent, such as a trading partner’s SFTP server or a network share Resource.

Image
The PGP Encrypt Task
The PGP Encrypt Task
Text

Further down in this Task, the Public Key is selected for encrypting these files. This key should already have been imported into the Key Vault, imported from a trading partner’s Key Pair. Going on to the Output Variables section, two Variables will be defined: the Variable ${encryptedFiles} will contain a list of all of the files that were encrypted by this Task, and ${originalFiles} will be a list of the initial, unencrypted files that were processed. These Variables will be referenced in later Tasks.

Image
The PGP Encrypt Task
The PGP Encrypt Task

The Decrypt Task

Text

After encrypting the files, this workflow will follow with a Task to decrypt them as well. Like the previous Task, the Key Location needs to be specified, but GoAnywhere will be able to find the Private Key in that Key Vault without needing to specify the exact key.

Next, the files to decrypt are defined. Like with many other Tasks, there are options to select a single file, a file list Variable, or a file set. This example will use the ${encryptedFiles} Variable created in the previous Task. The output location will again be the temporary Workspace. This Task will create a file list Variable for the resulting decrypted files for use with later Tasks.

Image
The Decrypt Task
The Decrypt Task

Additional Workflow Tasks

Text

Following the PGP encryption and decryption steps, there are some additional Tasks to process the files. The first of these is a Rename, which handles the ${originalFiles} Variable and inserts the ${Today} timestamp into the filename. A Variable for the number of files affected is defined, as well as a Variable for the file list of renamed files. The next Task copies these renamed files into another location for archiving.

Image
Rename Files
Rename Files
Image
Copy Files
Copy Files

 

Text

The final two Tasks print the Variables to the job log and delete the Workspace to clean up those temporary files. This Project also has an extra module that will be deferred to in the event of an error, sending the job log and Project details to an administrator.

Image
Print Files
Print Files

The Final Steps

Text

After reviewing the Tasks, the Project is complete. Validate the Project to ensure it compiles correctly, then go ahead and Execute. Reviewing the job log shows two files were encrypted and decrypted successfully and that the original files were renamed and archived.

Image
Reveiw The Job Log
Reveiw The Job Log