0

I want to create a custom C# method (no 3rd party libs) in my application that takes in a Stream (unencrypted) and a PGP key id (int) and I want it to return an encrypted stream back out to the user. The method signature looks something like this:

public Stream EncryptedData (Stream unEncryptedData, int PGP_Key_ID{...}

Anybody know how to do this or point me in the right direction?

  • "no 3rd party libs" - are you sure? It's going to be so much easier to use e.g. [BouncyCastle](https://stackoverflow.com/questions/2693769/need-example-for-bouncycastle-pgp-file-encryption-in-c-sharp) that already has the PGP format implemented. – Rup Sep 04 '18 at 14:15
  • Not really. I am either restricted to using SecureBlackbox.PGP or a custom method – user3596206 Sep 04 '18 at 14:17
  • OK, well you'll obviously need to find the PGP file format and implement that; you'll need to fetch the public key from a public repository if you don't already have it (and assume you're going to trust it), and you'll need to use the System.Security.Cryptography classes for randomness and encryption. – Rup Sep 04 '18 at 14:18
  • Have you got a sample for this @rup I've got the repo side of things set up. – user3596206 Sep 04 '18 at 14:19
  • No, sorry. If I had to do this I'd probably start with BouncyCastle myself. It might be worth considering SecureBlackbox: it might look expensive but you might be able to talk to their sales and get just the PGP component for less, and it would save a lot of development time. But seems odd to me you're restricted to that one supplier! – Rup Sep 04 '18 at 14:21

0 Answers0