You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
public static void CinchooPGP_GenerateKeys()
{
using (ChoPGPEncryptDecrypt pgp = new ChoPGPEncryptDecrypt())
{
pgp.GenerateKey(@"C:\TEMP\Keys\public.asc", @"C:\TEMP\Keys\private.asc", null, "password");
}
}
Encryption:
public static async Task<MemoryStream> CinchooPGPEncryption()
{
var ContentToEncryptStream = await FileToStreamMethod(@"C:\TEMP\Content\content.txt");
var PublicKeyStream = await FileToStreamMethod(@"C:\TEMP\Keys\public.asc");
MemoryStream encryptedContent = new MemoryStream();
using (ChoPGPEncryptDecrypt pgp = new ChoPGPEncryptDecrypt())
{
//this accepts 3 streams: stream to encrypt, stream to decrypt, public keys
await pgp.EncryptAsync(ContentToEncryptStream, encryptedContent, PublicKeyStream);
}
return encryptedContent;
}
Decryption:
public static async Task<MemoryStream> CinchooPGPDecryption(MemoryStream encryptedContent, string passPhrase)
{
var PrivateKeyStream = await FileToStreamMethod(@"C:\TEMP\Keys\private.asc");
MemoryStream decryptedContent = new MemoryStream();
using (ChoPGPEncryptDecrypt pgp = new ChoPGPEncryptDecrypt())
{
await pgp.DecryptAsync(encryptedContent, decryptedContent, PrivateKeyStream, passPhrase); //exception is thrown here
}
return decryptedContent;
}
Stacktrace:
at Cinchoo.PGP.ChoPGPEncryptDecrypt.Decrypt(Stream inputStream, Stream outputStream, Stream privateKeyStream, String passPhrase)
at Cinchoo.PGP.ChoPGPEncryptDecrypt.<>c__DisplayClass47_0.<DecryptAsync>b__0()
at System.Threading.Tasks.Task.InnerInvoke()
at System.Threading.Tasks.Task.<>c.<.cctor>b__277_0(Object obj)
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at Cinchoo.PGP.ChoPGPEncryptDecrypt.<DecryptAsync>d__47.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
No stream is null while I was debugging the app, so I think it's thrown somewhere inside the lib. Or maybe I am doing something wrong?
The text was updated successfully, but these errors were encountered:
I've been trying to encrypt and decrypt files in memory using streams, but there is a null reference exception on
method.
My code:
Stacktrace:
No stream is null while I was debugging the app, so I think it's thrown somewhere inside the lib. Or maybe I am doing something wrong?
The text was updated successfully, but these errors were encountered: