AsymmetricKeyParameter pubKey = null;
PgpPublicKeyRing pgpPub = new PgpPublicKeyRing(mypubkey /*
byte[] */);
PgpSecretKeyRing pgpPriv = new PgpSecretKeyRing(myprvkey /
* byte[] */);
pubKey = pgpPub.GetPublicKey().GetKey();
PgpSecretKey pgpPrivSecretKey = pgpPriv.GetSecretKey();
PgpPrivateKey pgpPrivateKey =
pgpPrivSecretKey.ExtractPrivateKey("password".ToCharArray());
IBufferedCipher c = CipherUtilities.GetCipher("ELGAMAL");
// c.Init(Cipher.ENCRYPT_MODE, pubKey);
c.Init(true, pubKey);
byte[] inBytes = Encoding.ASCII.GetBytes("Hello, can you
read this?");
c.ProcessBytes(inBytes); // encrypt the data
byte[] outBytes = c.DoFinal(); // finalize it
FileStream fs = File.Create("pgptest.enc");
fs.Write(outBytes, 0, outBytes.Length);
fs.Close();