Code Monkey home page Code Monkey logo

Comments (5)

mattosaurus avatar mattosaurus commented on June 12, 2024

Hi, did you get this error whilst using PgpCore? If so can you share your code please.

from pgpcore.

HerdMS avatar HerdMS commented on June 12, 2024

Hi @mattosaurus,

i am using PgpCore 6.2.0 with bouncyCastle.Cryptography 2.1.1

this is my code:

`
using Microsoft.Azure.Functions.Worker;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using PgpCore;

namespace encrypt_pgp_01_Firma
{
public class Function1
{
private readonly ILogger _logger;
private readonly IConfiguration _configuration;

    public Function1(ILogger<Function1> logger, IConfiguration configuration)
    {
        _logger = logger;
        _configuration = configuration;

    }

    [Function(nameof(Function1))]
    public async Task Run([BlobTrigger("%rawcontainer%Firma_{name}.csv", Connection = "")] Stream stream, string name)
    {
            
        // Stream - Version:

        // Load keys
        EncryptionKeys encryptionKeys;
        using (Stream publicKeyStream = new FileStream(@"C:\Users\frederik.ceglarek\Desktop\ReportingBeegyPublicKey.asc", FileMode.Open))
            encryptionKeys = new EncryptionKeys(publicKeyStream);

        // Reference input/output files
        PGP pgp = new PGP(encryptionKeys);

        using (FileStream inputFileStream = new FileStream(@"C:\Users\frederik.ceglarek\Desktop\Firma_20231206.csv", FileMode.Open))
        using (Stream outputFileStream = File.Create(@"C:\Users\frederik.ceglarek\Desktop\Neuer Ordner\Firma_20231206.pgp"))

            await pgp.EncryptAsync(inputFileStream, outputFileStream);
        
        /*
        // File - Version:

        // Load keys
        FileInfo publicKey = new FileInfo(@"C:\Users\frederik.ceglarek\Desktop\ReportingBeegyPublicKey.asc");
        EncryptionKeys encryptionKeys = new EncryptionKeys(publicKey);

        // Reference input/output files
        FileInfo inputFile = new FileInfo(@"C:\Users\frederik.ceglarek\Desktop\Firma_20231206.csv");
        FileInfo encryptedFile = new FileInfo(@"C:\Users\frederik.ceglarek\Desktop\Neuer Ordner\Firma_20231206.pgp");

        // Encrypt
        PGP pgp = new PGP(encryptionKeys);
        await pgp.EncryptAsync(inputFile, encryptedFile);
        */
    }
}

}
`

Curious thing is, when i use the File encryption, it works properly, only when i try to use stream encryption, the mentioned error occurs.

from pgpcore.

mattosaurus avatar mattosaurus commented on June 12, 2024

Cool, I'll take a look later when I get a chance (hopefully today or tomorrow). If this is urgent I'd suggest reverting back to v5.13.1 for now.

My initial thought is that the stream gets read by something else in PgpCore first and is then at the end when it comes to be read by this process.

from pgpcore.

HerdMS avatar HerdMS commented on June 12, 2024

Hi,
i was able to solve this by going back to v5.13.1.

I think pgp.EncryptAsync is not available in this version so I used pgp.EncryptStreamAsync, which worked as aspected!

Thanks for your help!

from pgpcore.

mattosaurus avatar mattosaurus commented on June 12, 2024

This was an issue with not setting the filename when one was available. It should now be fixed in v6.3.

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.