By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,248 Members | 1,104 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,248 IT Pros & Developers. It's quick & easy.

Using GnuPG via exec() on Win2k

P: n/a
I am trying to run GnuPG encrypt and decrypt functions from a PHP
script on a Win2k machine. I have tried several variations to no
avail. Basically what I want to be able to do is something like this:

<?php
$cmdStr = 'C:\\GnuPG\\gpg -r recipient --encrypt file2encrypt.txt';
exec($cmdStr);
?>

Has anyone had any success with this?

Scott

Jul 17 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
In article <11********************@z14g2000cwz.googlegroups.c om>,
sc***@webscott.com says...
I am trying to run GnuPG encrypt and decrypt functions from a PHP
script on a Win2k machine. I have tried several variations to no
avail. Basically what I want to be able to do is something like this:

<?php
$cmdStr = 'C:\\GnuPG\\gpg -r recipient --encrypt file2encrypt.txt';
exec($cmdStr);
?>

Has anyone had any success with this?

Scott

Might be nice if you told us what the problem is
Jul 17 '05 #2

P: n/a
In article <11********************@z14g2000cwz.googlegroups.c om>,
sc***@webscott.com says...
I am trying to run GnuPG encrypt and decrypt functions from a PHP
script on a Win2k machine. I have tried several variations to no
avail. Basically what I want to be able to do is something like this:

<?php
$cmdStr = 'C:\\GnuPG\\gpg -r recipient --encrypt file2encrypt.txt';
exec($cmdStr);
?>

Has anyone had any success with this?

Scott

Might be nice if you told us what the problem is
Jul 17 '05 #3

P: n/a
If I try running the code, I get no errors or warnings, but also no
results. Basically, it runs, but does nothing.

Jul 17 '05 #4

P: n/a
WebScott <sc***@webscott.com> wrote:
If I try running the code, I get no errors or warnings, but also no
results.
How do you know that?
Basically, it runs, but does nothing.


You did check the exit code?

Many things can go wrong here, eg:
-input file is not readable.
-receipent is unknown
-output file already exists
-output file is not writable (IMHO most likely)

Jul 17 '05 #5

P: n/a
Let me rephrase the question:

I want to encrypt a text file, which could contain a credit card number
or other sensitive information, using GnuPG. If I launch a command
prompt, I can do it by typing "c: & cd \Program Files\GnuPGExch & gpg
-r recipientkey --encrypt fakeCC.txt".

IUSR has modify access on the GnuPGExch folder. What do I need to do
to have PHP run the same command I used at the command prompt?

Jul 17 '05 #6

P: n/a
WebScott <sc***@webscott.com> wrote:
I want to encrypt a text file, which could contain a credit card number
or other sensitive information, using GnuPG. If I launch a command
prompt, I can do it by typing "c: & cd \Program Files\GnuPGExch & gpg
-r recipientkey --encrypt fakeCC.txt".
So when you try this from php, what is the return value of gpg?
IUSR has modify access on the GnuPGExch folder. What do I need to do
to have PHP run the same command I used at the command prompt?


1) nothing is being modified, above command creates a new file, AFAIK
with NT ACLs create!=modify
2) where does gpg store the its keys? On any system I used so far (win32
is not one of them), it's in the users homedir. In this case that
would be IUSR.

You need to run the program in such a way you get _all_ output: stdout
and stderr and the exitcode.

I use http://tmp.tryba.nl/clearsign.phps to sign an arbitrary string
with gpg, the returned array might tell you more about what's going
wrong (don't forget to include sufficient -v options to gpg).

BTW you shouldn't be storing the CC number on disk in an unencrypted
file at all if you are so concerned with security. Simply deleting the
unencrypted file is not enough (and securly wiping files on a journaled
filesystem might be very tricky). Use gpgs capability to encrypt from
stdin instead.

Jul 17 '05 #7

P: n/a
Thanks, Daniel.

I'll see if I can make it work on Windows.

Jul 17 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.