Coder Social home page Coder Social logo

Comments (3)

mattosaurus avatar mattosaurus commented on August 20, 2024

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.

from pgpcore.

ploef avatar ploef commented on August 20, 2024

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!

from pgpcore.

mattosaurus avatar mattosaurus commented on August 20, 2024

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.

from pgpcore.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.