Skip to content

Decrypt Method throwing error: "Object reference not set to an instance of an object" #25

Description

@carthax12

Using version 1.0.1.3

My code is here:
using (ChoPGPEncryptDecrypt pgp = new ChoPGPEncryptDecrypt()) { EncryptionViewModel pem = rpt.Encryption_In; var from = setFiles.FileToProcessPath + setFiles.FileToProcess; var to = setFiles.ProcessedPath + setFiles.ProcessedName; if (from == to) { to = setFiles.ProcessedPath + "_" + setFiles.ProcessedName; pgp.DecryptFile(from, to, pem.PEMPath, pem.PassPhrase); File.Delete(from); File.Move(to, from); } else { pgp.DecryptFile(from, to, pem.PEMPath, pem.PassPhrase); } }

In this case, the file name I am decrypting is the same as the file name I want to send on to the customer (this is an EDI application), so I am renaming the To file to _To, doing the Decrypt, then deleting the From file and renaming _To to From.

My stack track is here:

at Cinchoo.PGP.ChoPGPEncryptDecrypt.Decrypt(Stream inputStream, Stream outputStream, Stream privateKeyStream, String passPhrase) at Cinchoo.PGP.ChoPGPEncryptDecrypt.DecryptFile(String inputFilePath, String outputFilePath, String privateKeyFilePath, String passPhrase) at EDI2.Data.Process_Unencrypt_File.Process(ReportAllDataViewModel rpt) in C:\TWRAProjects\EDI2\EDI2\Data\Data_Process.cs:line 544

This has been working. I have verified the From file exists, the To file does not, and that my pgp and pem references are valid. I have verified that the pem.PEMPath and pem.PassPhrase variables are filled, and are correct.

The Encrypt process is still working just fine. I encrypt three or four files per week for my customers.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions