473,327 Members | 2,094 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

GPG - can't write anything

1
Hi,

I'd like to write an application which would encrypt a file using GnuPG.
It would be a Windows Application which would run a GnuPG as a Console Application.

I found this code but it doesn't work properly.
http://www.codeproject.com/KB/security/gnupgdotnet.aspx

On the basis of this application I wrote a simple console application with some adjustments.

Expand|Select|Wrap|Line Numbers
  1.         public void ExecuteCommand() {
  2.  
  3.             StreamWriter sw;
  4.             StreamReader sr;
  5.  
  6.             string gpgOptions = BuildOptions();
  7.             string gpgExecutable = _bindirectory + "\\gpg.exe";
  8.  
  9.             // Create startinfo object
  10.             ProcessStartInfo pInfo = new ProcessStartInfo(gpgExecutable, gpgOptions);
  11.             pInfo.WorkingDirectory = _bindirectory;
  12.  
  13.             pInfo.CreateNoWindow = false; //true;
  14.             pInfo.RedirectStandardInput = true;
  15.             pInfo.RedirectStandardOutput = true;
  16.             pInfo.UseShellExecute = false;
  17.  
  18.             _processObject = Process.Start(pInfo);
  19.  
  20.             Thread.Sleep(500);
  21.  
  22.             sw = _processObject.StandardInput;
  23.             sr = _processObject.StandardOutput;
  24.  
  25.             sw.Write(_passphrase + Environment.NewLine);
  26.             sw.Flush();
  27.  
  28.  
  29.             sw.Write("y" + Environment.NewLine);
  30.             sw.Flush();
  31.  
  32.             _processObject.Close();
These are my Buildoptions:
string sBuildOptions = @" --output KALIN01_1582020_0012_08.sig --sign --encrypt --recipient KEY_ATVP_001 KALIN01_1582020_0012_08.xml";

The code actually starts the GPG.EXE but it stops at the PassPhrase. Even I try to enter the passphrase from the application it simply does nothing.

As you can see I tried with pInfo.CreateNoWindow = false; //true; Having no success.

I really have no idea how to write some text by the application using StandardInput and not manually.

Thanks for any hint.
Apr 7 '08 #1
0 794

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Jim Hubbard | last post by:
I don't think you can hook system events outside your application in .Net without using an unmanaged DLL, but I thought I'd ask. Jim Hubbard
26
by: Paul | last post by:
public class A { public A () { // here I would like to call the second version of _ctor, how to accomplish this ? } public A (int a, int b, int c) {
9
by: WRH | last post by:
Hello I am new to asp but I made some Jscript functions which work fine. The functions contain some strings used as a registration key for some apps. It is important that these strings not be...
5
by: Jim Hubbard | last post by:
I don't think you can hook system events outside your application in .Net without using an unmanaged DLL, but I thought I'd ask. Jim Hubbard
26
by: Bill Reid | last post by:
Bear with me, as I am not a "professional" programmer, but I was working on part of program that reads parts of four text files into a buffer which I re-allocate the size as I read each file. I...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.