Encrypt File
  • 06 Sep 2023
  • 2 Minutes to read
  • Dark
    Light

Encrypt File

  • Dark
    Light

Article Summary

Step Details

Introduced in Version4.0.0
Last Modified in Version8.5.0
LocationPGP Steps

The Encrypt File step allows a user to use the PGP module to encrypt a file. 

Prerequisites 

This step requires the PGP module to be installed before it will be available in the toolbox. 


Properties

Inputs

PropertyDescriptionData Type
BinaryDefines whether the output file is encrypted as bytes or raw text/asciiBoolean
DataThe desired file to encryptList of Byte
Internal File NameSpecifies the filename and file type extension of the file when decrypting the file (i.e., text.pdf). It is best practice to have this match what is entered in the Data field.
String
Output File NameSpecifies the file name and file type extension of the encrypted file (i.e., newFile.pdf)String
Public KeyGenerated PGP public key file used to encrypt fileList of Byte

Outputs

PropertyDescriptionData Type
OutputOutputs the encrypted file as the specified output file nameString

Example Inputs and Outputs

BinaryDataInternal File NameOutput File NamePublic KeyOutput
FalseContentimage.pngencryptedImageFile.png
pub.ascid:"f196435c-2f2d-4667-98b6-a5d36a3f88a8",FileName:"encryptedImageFile.png",Length:70451 ,Filetype:".png"
TrueNullexample.txtencryptex.txtpub.ascEXCEPTION MESSAGE
EmptyContentnew.txtencr.txtpub.ascEXCEPTION MESSAGE
FalseContentNullfile.docxpub.ascid:"dbb01f7c-2ebe-4ea7-bf56-2467ce731c67",FileName:"file.docx",Length:3687,Filetype:".docx"
TrueContentexample.pdfNullpub.ascEXCEPTION MESSAGE
FalseContentread.pdffile.pdfNullEXCEPTION MESSAGE


Common Errors

Buffer can't be null 

If the Data field or the Public Key fields are null or empty, the step will cause an error.

To correct this, ensure that a File is uploaded and that the appropriate Public Key file is uploaded to the fields.

Exception Message:

Exception Stack Trace: DecisionsFramework.Design.Flow.ErrorRunningFlowStep: Error running step Encrypt File 1[EncryptFile] in flow [Flow 2]: Exception invoking method EncryptFile on class PGPSteps
 ---> DecisionsFramework.LoggedException: Exception invoking method EncryptFile on class PGPSteps
 ---> System.ArgumentNullException: Buffer cannot be null. (Parameter 'buffer'
 at System.IO.MemoryStream..ctor(Byte[] buffer
 at Decsisions.PGP.Steps.PGPSteps.EncryptFile(Byte[] publicKey, Byte[] data, Boolean binary, String outputFileName, String internalFileName)
   --- End of inner exception stack trace --- at DecisionsFramework.Design.Flow.StepImplementations.InvokeMethodStep.Run(StepStartData data
 at DecisionsFramework.Design.Flow.FlowStep.RunStepInternal(String flowTrackingID, String stepTrackingID, KeyValuePairDataStructure[] stepRunDataValues, AbstractFlowTrackingData trackingData
 at DecisionsFramework.Design.Flow.FlowStep.Start(String flowTrackingID, String stepTrackingID, FlowStateData data, AbstractFlowTrackingData trackingData, RunningStepData currentStepData)
   --- End of inner exception stack trace ---

Parameter 'binary' of 'EncryptFile' can not be null

If the Binary field is empty or null, the step will cause an error.

To correct this, set the input mapping of the Binary field to Constant.

Exception Message:

Exception Stack Trace: DecisionsFramework.BusinessRuleException: [BusinessRule] Parameter 'binary' of 'EncryptFile' can not be null 
at DecisionsFramework.Design.Flow.CoreSteps.InvokeMethodUtility.ThrowErrorIfNullIsNotAllowed(MethodInfo methodInfo, Object[] parameterValues, String errorMessage
 at DecisionsFramework.Design.Flow.StepImplementations.InvokeMethodStep.Run(StepStartData data
 at DecisionsFramework.Design.Flow.FlowStep.RunStepInternal(String flowTrackingID, String stepTrackingID, KeyValuePairDataStructure[] stepRunDataValues, AbstractFlowTrackingData trackingData
 at DecisionsFramework.Design.Flow.FlowStep.Start(String flowTrackingID, String stepTrackingID, FlowStateData data, AbstractFlowTrackingData trackingData, RunningStepData currentStepData)

Object reference not set to an instance of an object.

If the Output File Name field is empty or null, the step will cause an error.

To correct this, ensure that the value is correctly entered or mapped and includes the file extension (ie. .txt, .pdf, etc.).

Exception Message:

Exception Stack Trace: DecisionsFramework.Design.Flow.ErrorRunningFlowStep: Error running step Encrypt File 1[EncryptFile] in flow [Flow 2]: Object reference not set to an instance of an object.
 ---> System.NullReferenceException: Object reference not set to an instance of an object.
 at DecisionsFramework.Data.DataTypes.FileData.ProcessValueAddedToFlowData(String filePath, Boolean isFilePathFromSearch
 at DecisionsFramework.Data.DataTypes.FileData.ValueAdded(
 at DecisionsFramework.Design.Flow.Mapping.KeyValueDictionary.Add(KeyValuePairDataStructure item
 at DecisionsFramework.Design.Flow.StepImplementations.InvokeMethodStep.Run(StepStartData data
 at DecisionsFramework.Design.Flow.FlowStep.RunStepInternal(String flowTrackingID, String stepTrackingID, KeyValuePairDataStructure[] stepRunDataValues, AbstractFlowTrackingData trackingData
 at DecisionsFramework.Design.Flow.FlowStep.Start(String flowTrackingID, String stepTrackingID, FlowStateData data, AbstractFlowTrackingData trackingData, RunningStepData currentStepData)
   --- End of inner exception stack trace ---

Related Information

Documentation:
PGP Module

Forum Posts:
Email Encrypt / Decrypt With PGP Module
Error While Encrypting A File Using PGP
PGP Issues With Decrypting Using Private Key


Was this article helpful?

What's Next