Closed ploef closed 12 months ago
Hi,
Does it work if you follow the code example in the readme?
https://github.com/mattosaurus/PgpCore#signstreamasync
If not it might be a bug. I'm on holiday at the moment but can take a look at it in a couple of weeks if so.
Hi,
Thanks for the quick response during your holiday! Yes, I used that example as a starting point. But for now have a nice time!
Hi, without seeing the rest of your code I'm not sure what the issue might be but the below works for me that's based on your code.
internal class Program
{
static void Main(string[] args)
{
try
{
MainAsync(args).GetAwaiter().GetResult();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
static async Task MainAsync(string[] args)
{
string inputFilePath = @"C:\TEMP\Content\content.txt";
string publicKeyFilePath = @"C:\Temp\public.asc";
string privateKeyFilePath = @"C:\Temp\private.asc";
string passPhrase = "password";
PGP pgpKeys = new PGP();
await pgpKeys.GenerateKeyAsync(publicKeyFilePath, privateKeyFilePath, password: passPhrase);
EncryptionKeys encryptionKeys;
using (Stream privateKeyStream = new MemoryStream(Encoding.UTF8.GetBytes(File.ReadAllText(privateKeyFilePath))))
{
encryptionKeys = new EncryptionKeys(privateKeyStream, passPhrase);
}
var pgp = new PGP(encryptionKeys);
using (Stream inputFileStream = new MemoryStream(Encoding.UTF8.GetBytes(File.ReadAllText(inputFilePath))))
using (Stream outputFileStream = new MemoryStream())
{
await pgp.SignStreamAsync(inputFileStream, outputFileStream);
}
}
}
If you can share a full example of you're non-working code I'll take a look in more detail.
Hi,
I'm trying to sign a stream using the following code. Unfortunately I' getting a "MethodNotSupported" exception executing the "SignStreamAsync" method.