我試圖使用名爲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)。 –