Я создал веб -приложение (MVC C#), чтобы расшифровать файл GPG на сервере Windows.
Проблема в том, когда я тестирую программу веб -приложения на своем ноутбуке, он работает нормально.
Но когда я развертываю ее на нашем Sit Windows Server и пытаюсь расшифровать файл gpg ore ress, но null или no decrypted файл. < /p>
code - это простой код, просто кодовый код. ProcessStart Чтобы выполнить командную строку DOS "GNUPG" под powerShell.exe.
-> Что не так с этим моим простым кодом?public FileInfo DecrypAVFile_GPGA(string encryptedSourceFile, string decryptedFile,string avPAthFile, string decryptFilePath, string loggedUser)
{
System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo("gpg.exe");
string _msg = "";
string inputFile = avPAthFile + "\\" + encryptedSourceFile;
string outputFile = decryptFilePath + "\\" + decryptedFile;
try
{
string arguments_A = "gpg.exe --passphrase-fd 0 --output " + outputFile + " --decrypt --pinentry-mode=loopback --passphrase 0 " + inputFile;
string arguments_B = @" gpg.exe --decrypt -o " + "\"{0}\"" + @" " + "\"{1}\"";
string cmdFormat = arguments_B;
//-- Check if File is Existing delete it
if (File.Exists(outputFile))
{
File.Delete(outputFile);
}
_msg = PgpCmd(string.Format(cmdFormat, outputFile, inputFile), loggedUser);
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return new FileInfo(decryptedFile);
}
public string PgpCmd(string command,string loggedUser)
{
string _msg = "Success";
string gpgWorkingDir = @"" + appPath; //-- @"C:\Program Files (x86)\GnuPG\bin";
string path = string.Format(@"{0}\gpg.exe", gpgWorkingDir);
try
{
var psi = new ProcessStartInfo("powershell.exe") //-- ProcessStartInfo("cmd.exe")
{
WorkingDirectory = gpgWorkingDir,
CreateNoWindow = true,
UseShellExecute = false,
RedirectStandardError = true,
RedirectStandardInput = true,
RedirectStandardOutput = true,
};
loggedAction = _lgs.avAppLogs(loggedUser, "AVDECRYPT", "DecrypAVFile_GPGA", "DecrypAVFile_GPGA is About to decrypt - File: " + command, "DecrypAVFile_GPGA -> PgpCmd");
string sCommandLine = command;
//--var proc = new Process { StartInfo = psi };
System.Diagnostics.Process proc = System.Diagnostics.Process.Start(psi);
proc.StandardInput.WriteLine(sCommandLine);
proc.StandardInput.Flush();
proc.StandardInput.Close();
proc.WaitForExit();
proc.Close();
loggedAction = _lgs.avAppLogs(loggedUser, "AVDECRYPT", "DecrypAVFile_GPGA", "DecrypAVFile_GPGA Success on decrypting file in Action -> " + command, "DecrypAVFile_GPGA -> PgpCmd");
}
catch (Exception ex)
{
_msg = "Fail";
string error = "Error : " + ex.Message;
loggedAction = _lgs.avAppLogs(loggedUser, "AVDECRYPT", "DecrypAVFile_GPGA", "DecrypAVFile_GPGA Decryption Failed : " + error + " at " + command + " Message : " + ex.Message, "PlayReviewVideo Function on Decryption");
throw new Exception(ex.Message);
}
return _msg;
}
Подробнее здесь: https://stackoverflow.com/questions/795 ... ank-output
Мне нужно расшифровать файлы GPG, но дать мне пустой вывод ⇐ C#
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Я хочу зашифровать и расшифровать AES-GCM на языке C#, но не могу расшифровать
Anonymous » » в форуме C# - 0 Ответы
- 44 Просмотры
-
Последнее сообщение Anonymous
-