我试图使用名为PgpDecrypt的类来解密客户端给出的这个示例文件。但是,当代码涉及到这一行:使用BouncyCastle解密文件的例外PGP
Stream clear = pbe.GetDataStream(privKey);
它返回一个错误:例外解密密钥
这里是我的解密代码:
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\");
我使用BouncyCastle的是我的第三个.NET的第三方库。
任何想法解决这将是一个很大的帮助。提前致谢!
在哪里分配了“pathh”? –
文件所在的本地路径... @“D:\ Users \ MyUser \ Documents \ Visual Studio 2008 \ Projects \ sFTPwithPGP \ keys \ keys26112012 \” – iceheaven31
为了增加构建路径时的安全性,您应该使用[Path.Combine] (http://msdn.microsoft.com/en-us/library/system.io.path.combine.aspx)。 –