title: Use BouncyCastle PGP library with OpenPGP Key Format
body: <p>I have an application that makes encryption of a string with an RSA PublicKey in OpenPGP format (.asc).</p>
  <p>I had discovered this code in a forum :</p>
  <pre><code>public static string EncryptWithPublicKey(string PublicKey, string Text)
      {
          byte[] BytesToOperateOn = Encoding.UTF8.GetBytes(Text);
          TextReader reader = new StringReader(PublicKey);
          AsymmetricKeyParameter KeyPair = (AsymmetricKeyParameter)new PemReader(reader).ReadObject();
  
          OaepEncoding Engine = new OaepEncoding(new RsaEngine(), new Sha256Digest(), new Sha256Digest(), null);
          Engine.Init(true, KeyPair);  //if encryption is true use public key else use private
          byte[] Output = Engine.ProcessBlock(BytesToOperateOn, 0, BytesToOperateOn.Length);
          string Result = Convert.ToBase64String(Output);
          return Result;
      }
  </code></pre>
  <p>But, when I enter my OpenPGP PublicKey, it returns &quot;Base64 data appear to be truncated&quot;. When I try with a PEM RSA Key, it perfectly works.</p>
  <p>How can I modify my code to take charge of the OpenPGP (RFC4080) Format Key?</p>