Cinchoo/ChoPGP

Exception while encrypt and signed

Salmanferozkhan opened this issue · 3 comments

Hello can you please tell me why it is giving this error
Org.BouncyCastle.Bcpg.OpenPgp.PgpPublicKeyRing found where PgpSecretKeyRing expected

It throws only when I create keys through OpenPGP studio. otherwise, it is working fine

need some sample code to look at it to advise

using (ChoPGPEncryptDecrypt pgp = new ChoPGPEncryptDecrypt() { FileType = ChoPGPFileType.UTF8 }) { MemoryStream outStream = new MemoryStream(); using (Stream publicKeyStream = new MemoryStream(GetPublicKey()), privateKeyStream = new MemoryStream(GetPrivateKey())) { inputStream.Position = 0; pgp.EncryptAndSign(inputStream, outStream, publicKeyStream, privateKeyStream, SignPassword); return outStream.ToArray(); } }

here is the code which is working with normal private key which I generated from online website but when I generate Keys from PGPStudio so that private key is also use compression algorithm i.e ZIP so using that key so it will give exception

Org.BouncyCastle.Bcpg.OpenPgp.PgpPublicKeyRing found where PgpSecretKeyRing expected

this issue is outside of library . Here are some references I found when I googled.

https://social.msdn.microsoft.com/Forums/office/en-US/d71151a4-40eb-4986-9368-1a7462214e6e/pgp-encrption-thorwing-error?forum=biztalkgeneral

Hope it helps.