I was trying to decrypt this sample file given by the client, using a class called PgpDecrypt. But when the code comes to this line:
Stream clear = pbe.GetDataStream(privKey);
it returns an error: exception decrypting secret key
Here's my decryption code:
PgpDecrypt test = new PgpDecrypt(string.Concat(pathh, "TestDecryptionFile"),
string.Concat(pathh, "mypgpprivatekey.key"),
"mypassphrase",
@"d:/test/",
string.Concat(pathh, "clientpublickey.key"));
FileStream fs = File.Open(string.Concat(pathh, "TestDecryptionFile"), FileMode.Open);
test.Decrypt(fs, @"d:\test\");
I am using BouncyCastle as my third party library for .NET.
Any idea to solve this would be a great help. Thanks in advance!
If you're following the BouncyCastle classes PGPEncrypt, PGPDecrypt and PGPEncryptionKeys...
Under the PGPEncryptionKeys class, add this method:
still inside the PgpEncryptionKeys class, make sure the ReadSecretKey method looks like this:
^_^