2017-08-04 106 views
0

我需要使用shell從文件傳遞密碼短語,並且希望註釋行可以從此文件讀取密碼短語,--passphrase-fd對我不起作用。它總是輸出一個錯誤「找不到文件」。我調試輸出和輸入文件,它們是正確的。可能是passphrase.cat文件,但我檢查過,文件中沒有問題。評論欄中的任何問題?使用gpg傳遞密碼文件來解密文件

我的代碼如下,感謝您的幫助:

     Shell(pgp & "--passphrase -fd 0 <C:\Temp\test.txt" & " -output " & output & "--decrypt " & input & """", AppWinStyle.Hide, True) ' the error happens here. 


        End If 

''' The error as follows: 
''' Unable to complete the request: System.IO.FileNotFoundException: File not found. at Microsoft.VisualBasic.Interaction.Shell(String PathName, AppWinStyle Style, Boolean Wait, Int32 Timeout) at the Sign_Click(object sender, EventArgs e) in C:\sign\MainForm.vb:line361 
+0

執行的確切命令行是什麼(換句話說,「Shell(...)」的字符串參數是什麼),以及接收到的確切完整的錯誤消息是什麼?你是否驗證過這個文件是真正寫入的? –

+0

@JensErat嗨,我在命令中傳遞的字符串是「C:\ Temp \ test.cat」,輸出和輸入。輸出==(txtRequestDestination.Text&foundFileInfo.Name).Remove((txtRequestDestination.Text)。Input = txtRequestSource.Text&foundFileInfo.Name。錯誤提示「無法找到文件」。 – ccy

+0

@JensErat我測試了這三個參數,但所有文件都存在。「Shell(pgp&」--passphrase -fd 0 ccy

回答

0

最後,我想通了。必須使用-passphrase-file passwordfile.txt解密應用程序中的文件。

0

我想到了一大堆的問題。要進一步調試,請將命令打印到命令行,而不是使用Shell(...)執行它。

  • 我猜pgp變量不以空格結尾,因此應用程序試圖像C:\path\to\gnupg\gpg.exe--passphrase而不是C:\path\to\gnupg\gpg.exe--passphrase參數
  • 同樣的問題output變量之間可能存在,並且​​3210命令來執行一些
  • --passphrase-fd裏面可能沒有空格,你寫過passphrase -fd
  • --output是一個長參數,需要兩個破折號(你wr ote -output
+0

感謝您的回答,我在CMD.exe中運行此註釋行:C:\ Program Files \ GNU \ GnuPG> gpg2.exe --passphrase-fd 0 ccy

+0

但是,如果我在我的VB.net中使用這個不起作用。 Shell(pgp&「--passphrase-fd 0 ccy

+0

請再次提供由所有這些連接產生的確切字符串。換句話說:沒有任何變量和連接的確切字符串最終由'Shell(...)'執行。其他一切都是猜測,只會導致無盡的討論。 –