Re: PGP/PHP
| From: | David T-G | Date: | Mon, 16 Dec 2002 10:57:36 +0000 |
| Subject: | Re: PGP/PHP | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-128390@lists.php.net to get a copy of this message | ||
Jonathan --
..and then Jonathan said...
%
% I have necessary PGP client software on my machine and have tested the
% functionality of PGP from my site, however, I want to know how to use
% PHP to send a PGP email.
1) Do you know how to use pgp to encrypt and decrypt a file?
2) Do you know how pgp is used by a mail user agent to encrypt a mail
message?
%
% This is the scenario,
%
% I have a shopping cart which directs to SSL, then while in SSL, the
% customer will input their information, including credit card info.
OK.
In general, you send a mail message to someone with the mail() function,
and many people choose to predefine their headers, recipient, and content.
To wit:
[From the manual:]
mail
(PHP 3, PHP 4 )
mail -- send mail
Description
bool mail ( string to, string subject, string message [, string
additional_headers [, string additional_parameters]])
and
<?php
$to = "recipient@addr.ess" ;
$subject = "this is a message" ;
$headers = "From: my@addr.ess\nX-Stuff: another header\n" ;
$body = "This is my message body.\n\nThere; that was fun.\n" ;
mail($to,$subject,$message,$headers) ;
?>
All you have to do is encrypt your message body and then paste that into
this example as $body. You could do it either by capturing $body or just
doing an inline replacement. To wit:
bash-2.05a$ echo "this is text" \
| gpg --encrypt --armor --recipient 7B9F4700 \
| gpg --armor --decrypt
You need a passphrase to unlock the secret key for
user: "David T-G <davidtg@justpickone.org>"
2048-bit ELG-E key, ID 1AEFE05A, created 2001-12-16 (main key ID
7B9F4700)
gpg: encrypted with 2048-bit ELG-E key, ID 1AEFE05A, created 2001-12-16
"David T-G <davidtg@justpickone.org>"
this is text
Of course, leaving off the decrypt side will spit out a lovely encrypted
text block -- but that takes up more lines to demo :-)
%
% I want to show a receipt, (no cc #'s of course) and send the order to an
% administrator of the site using PGP after all the information has been
% gathered and send it from SSL. The site's admin will be able decrypt the
% information using the client software.
So the site's admin will get a encrypted mail message, right? What's
this about no cc number -- you won't print one on the receipt, or you
won't give one to the admin, or the receipt without the number is what
the admin gets?
%
%
% Thanks in advance.
HTH & HAND
:-D
--
David T-G * There is too much animal courage in
(play) davidtg@justpickone.org * society and not sufficient moral courage.
(work) davidtgwork@justpickone.org -- Mary Baker Eddy, "Science and Health"
http://www.justpickone.org/davidtg/ Shpx gur
Pbzzhavpngvbaf Qrprapl Npg!