--- title: "Sign and Encrypt File" slug: "sign-and-encrypt-file" tags: ["PGP module", "sign", "Encryption", "public key", "private key", "file"] updated: 2024-03-20T16:02:01Z published: 2024-03-20T16:02:01Z canonical: "documentation.decisions.com/sign-and-encrypt-file" --- > ## Documentation Index > Fetch the complete documentation index at: https://documentation.decisions.com/llms.txt > Use this file to discover all available pages before exploring further. # Sign and Encrypt File | ## Step Details | | --- | | **Introduced in Version** | 4.0.0 | | **Last Modified in Version** | 8.1.0 | | **Location** | PGP Steps | The **Sign and Encrypt File** step allows a user to sign a file and encrypt it. ## Upgrading to v8.13+ Customers using the Sign File, Clear Sign File, or Sign And Encrypt File steps need to drag and drop these steps after upgrade into the Flows using them. Steps that are already in Flows may have their mapping set to Null on upgrade. ### Prerequisites This step requires the [PGP module](https://documentation.decisions.com/docs/pgp-module-overview#overview) to be [installed](https://documentation.decisions.com/docs/installing-modules-decisions) before it will be available in the toolbox. --- ## Properties #### Inputs | Property | Description | Data Type | | --- | --- | --- | | Algorithm | Allows the user to select a [Hash Algorithm](https://en.wikipedia.org/wiki/List_of_hash_functions#) type from a dropdown list (MD5, Sha1, RipeMD160, DoubleSha, MD2, Tiger192, Havel5pass160, Sha256, Sha384, Sha512, Sha224). To see the dropdown list, select the Constant input mapping. | HashAlgorithmTag | | Binary | Defines whether the output file is encrypted as bytes or raw text/ascii | Boolean | | Data | The desired file to sign and encrypt | List of Byte | | Internal File Label | Specifies the name of the internal file of the signed and encrypted file | String | | Output File Name | Allows the user to specify the file name and file extension for the signed file (i.e., SignednewFile.pdf) | String | | Private Key | Generated PGP Private Key file | List of Byte | | Private Key Password | Password for the specified Private Key file | String | | Public Key | Generated PGP Public Key file | List of Byte | | With Integrity Check | Adds a key string to the front of the signed files encryption text for validating the plain text portion to ensure file contents are secure | Boolean | #### Outputs | Property | Description | Data Type | | --- | --- | --- | | Output | Outputs a signed and encrypted file | String | --- ## Example Inputs and Outputs | Algorithm | Binary | Data | Internal File Label | Output File Name | Private Key | Private Key Password | Public Key | With Integrity Check | Output | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | Null | False | example.txt | Signed File | exampleSigned.txt | priv.asc | catch | pub.asc | False | EXCEPTION MESSAGE | | Sha1 | False | sample.txt | factoid file | signed.txt | priv.asc | steer | pub.asc | True | Id: "597426c4-a32d-4ac2-8e4f-7382b85874e0",FileName: "signed.txt",Length: 663,FileType: ".txt" | | DoubleSha | True | Null | New File | Newsigned.txt | priv.asc | begins | pub.asc | False | EXCEPTION MESSAGE | | MD2 | False | sample.txt | Null | NewSample.txt | priv.asc | catch | pub.asc | True | Id: "42773b60-3afa-43ca-ada8-2274d4edb0f1",FileName: "Newsigned.txt",Length: 1675,FileType: ".txt" | | Sha256 | True | flowers.png | Group | Empty | priv.asc | catch | pub.asc | False | Id: "6ad944f2-7da5-4097-9593-1fe53c1506aa",FileName: "",Length: 655,FileType: "" | | Sha384 | True | example.docx | fact | signed.docx | Null | steer | pub.asc | False | EXCEPTION MESSAGE | | MD5 | False | example.txt | Example Text | signedExample.txt | priv.asc | Null | pub.asc | True | EXCEPTION MESSAGE | | Sha512 | True | sample.pdf | Approved | newsample.pdf | priv.asc | password | Null | True | EXCEPTION MESSAGE | | Sha224 | False | showInfo.pdf | File Signed | showsign.pdf | private.txt | catch | pub.asc | False | EXCEPTION MESSAGE | | MD5 | False | partyList.xls | Signed File | confirmList.xls | priv.asc | password | pub.asc | Empty | EXCEPTION MESSAGE | #### ![](https://cdn.document360.io/6ef8bcc1-6489-4486-9ad1-83acff7e5df0/Images/Documentation/image-1675368148786.png) --- ## Common Errors ### Parameter 'binary' of 'SignAndEcryptFile' can not be null If the Binary field is null or empty, the step will cause an error. To correct this, set the input mapping for the Binary field to Constant. #### Exception Message: ```csharp Exception Stack Trace: DecisionsFramework.BusinessRuleException: [BusinessRule] Parameter 'binary' of 'SignAndEcryptFile' 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) ``` --- ### Buffer cannot be null If the Data, Private Key, or Public Key fields are null or empty, the step will cause an error. To correct this, ensure that each field's value is uploaded or mapped correctly with the appropriate file. #### Exception Message: ```csharp Exception Stack Trace: DecisionsFramework.Design.Flow.ErrorRunningFlowStep: Error running step Sign and Encrypt File 1[SignAndEcryptFile] in flow [Flow 2]: Exception invoking method SignAndEcryptFile on class PGPSteps ---> DecisionsFramework.LoggedException: Exception invoking method SignAndEcryptFile on class PGPSteps ---> System.ArgumentNullException: Buffer cannot be null. (Parameter 'buffer' at System.IO.MemoryStream..ctor(Byte[] buffer at Decsisions.PGP.Steps.PGPSteps.SignAndEcryptFile(String internalFileLabel, Byte[] publicKey, Byte[] privateKey, String privateKeyPassword, Byte[] data, Boolean binary, String outputFileName, Boolean withIntegrityCheck, HashAlgorithmTag algorithm) --- 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 --- ``` --- ### Object reference not set to an instance of an object. If the Private Key Password field is null or empty, the step will cause an error. To correct this, ensure that the correct password is entered. #### Exception Message: ```csharp Exception Stack Trace: DecisionsFramework.Design.Flow.ErrorRunningFlowStep: Error running step Sign and Encrypt File 1[SignAndEcryptFile] in flow [Flow 2]: Exception invoking method SignAndEcryptFile on class PGPSteps ---> DecisionsFramework.LoggedException: Exception invoking method SignAndEcryptFile on class PGPSteps ---> System.NullReferenceException: Object reference not set to an instance of an object. at Decsisions.PGP.Steps.Processor.GetPrivateKey(PgpSecretKey secretKey, String password at Decsisions.PGP.Steps.BouncyCastleProcessor.SignAndEncryptStream(Stream inputStream, String internalFileLabel, Stream privateKeyStream, String privateKeyPassword, String s1, Stream[] publicKeyStreams, Stream encryptedStream, DateTime date, Boolean armorAscii, Boolean withIntegrityCheck, HashAlgorithmTag hashAlgorithm at Decsisions.PGP.Steps.PGPSteps.SignAndEcryptFile(String internalFileLabel, Byte[] publicKey, Byte[] privateKey, String privateKeyPassword, Byte[] data, Boolean binary, String outputFileName, Boolean withIntegrityCheck, HashAlgorithmTag algorithm) --- 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 --- ``` --- ### [BusinessRule] Parameter 'withIntegrityCheck' of 'SignAndEncryptFile' can not be null If the With Integrity Check field is null or empty, the step will cause an error. To correct this, set the input mapping of the With Integrity Check to Constant. #### Exception Message: ```csharp Exception Stack Trace: DecisionsFramework.BusinessRuleException: [BusinessRule] Parameter 'withIntegrityCheck' of 'SignAndEcryptFile' 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) ``` --- ### unknown object in stream 32 If the file uploaded or mapped to the Private Key or Public Key fields is not the correct file type (i.e., a .txt or .pdf file), the step will cause an error. To correct this, ensure that the appropriate PGP Private Key or Public Key file is uploaded or mapped to the respective field. #### Exception Message: ```csharp Exception Stack Trace: DecisionsFramework.Design.Flow.ErrorRunningFlowStep: Error running step Sign and Encrypt File 1[SignAndEcryptFile] in flow [Flow 2]: Exception invoking method SignAndEcryptFile on class PGPSteps ---> DecisionsFramework.LoggedException: Exception invoking method SignAndEcryptFile on class PGPSteps ---> System.IO.IOException: unknown object in stream 32 at Org.BouncyCastle.Bcpg.OpenPgp.PgpObjectFactory.NextPgpObject( at Org.BouncyCastle.Bcpg.OpenPgp.PgpObjectFactory.AllPgpObjects( at Decsisions.PGP.Steps.Processor.GetSecretKeyRingBundle(Stream inputStream at Decsisions.PGP.Steps.Processor.GetPgpSecretKey(Stream stream at Decsisions.PGP.Steps.BouncyCastleProcessor.SignAndEncryptStream(Stream inputStream, String internalFileLabel, Stream privateKeyStream, String privateKeyPassword, String s1, Stream[] publicKeyStreams, Stream encryptedStream, DateTime date, Boolean armorAscii, Boolean withIntegrityCheck, HashAlgorithmTag hashAlgorithm at Decsisions.PGP.Steps.PGPSteps.SignAndEcryptFile(String internalFileLabel, Byte[] publicKey, Byte[] privateKey, String privateKeyPassword, Byte[] data, Boolean binary, String outputFileName, Boolean withIntegrityCheck, HashAlgorithmTag algorithm) --- 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 --- ``` --- Related Information Documentation: [PGP Module](https://documentation.decisions.com/docs/pgp-module-overview#overview) Forum Posts: [Email Encrypt / Decrypt With PGP Module](https://support.decisions.com/forum/topic1520-email-encrypt--decrypt-with-pgp-module.aspx) [Error While Encrypting A File Using PGP](https://support.decisions.com/forum/topic1814-error-while-encrypting-a-file-using-pgp.aspx) [PGP Issues With Decrypting Using Private Key](https://support.decisions.com/forum/topic2522-pgp-issues-with-decrypting-using-private-key.aspx) ## Related - [Sign File](/sign-file.md) - [Clear Sign File](/clear-sign-file-legacy.md) - [Decrypt and Verify File](/decrypt-and-verify-file.md) - [Encrypt File](/encrypt-file.md) - [Decrypt File](/decrypt-file.md) - [Verify File](/verify-file.md)