2009-07-31 71 views
2

我使用GnuPG和C#來加密具有導入的公鑰的文件。但是當我嘗試進行加密時,GnuPG使用主用戶的公鑰加密文件。我確信我通過了正確的收件人。 任何幫助表示讚賞。 謝謝。C#的GnuPG包裝器#

+0

我對重複的不同意 - 這指的是一個具體的實現,而其他被要求建議在其上使用的執行。 – 2009-07-31 18:30:30

回答

11

您可以嘗試使用我的開源免費GnuPG包裝C#(和VB.NET)。所有代碼都通過MIT許可,非GPL限制。您可以在CodePlex上找到帶有源代碼的版本。查找Alpha版本以查找GPG庫。

http://biko.codeplex.com/

例子:

GnuPG gpg = new GnuPG(); 

    gpg.Recipient = "[email protected]"; 
    FileStream sourceFile = new FileStream(@"c:\temp\source.txt", FileMode.Open); 
    FileStream outputFile = new FileStream(@"c:\temp\output.txt", FileMode.Create); 

    // encrypt the data using IO Streams - any type of input and output IO Stream can be used 
    gpg.Encrypt(sourceFile, outputFile); 
+1

嗨,這個解決方案適用於控制檯應用程序,當我從Windows服務運行這個時,我得到錯誤,因爲gpg2.exe已停止工作 – Umamaheswaran 2012-09-04 12:28:53