Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
carthax12 opened this issue Nov 16, 2020 · 0 comments

Comments

@carthax12
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant