decrypting input, not a file...
Paul Evad
pevad@kudosnet.com
Thu, 18 May 2000 13:03:21 -0700
At 2:26 PM -0500 5/18/00, Frank Tobin wrote:
>Paul Evad, at 19:24 -0700 on Wed, 17 May 2000, wrote:
>
>> echo '$passphrase' | gpg -v --batch --no-secmem-warning
>> --passphrase-fd 0 --decrypt $file
>>
>> However, in a particular case... I would like to decrypt a 'string'
>> but don't want to necessarily write the 'string' to a file.
>
>While I think using shell for anything sensitive is ridiculous...this
>might work. I don't recommend passing in passphrases to stdin, however,
>in case you run situations where the passhrase isn't needed, and is
>processed as part of the normal message by GnuPG.
>
>echo "$passphrase\n$string" | gpg --passphrase-fd 0 --decrypt
>
>
>> Please CC me on reply's, I haven't subscribed to the list yet....
>
>It is advisable for you to subscribe. Lots of goodies for those who do :)
Thanks for the feedback,
If anyone is interested... here is the resulting PHP script that will
encrypt/decrypt data using this hack..
<pre>
<?
// exec($command, $encrypted, $errorcode);
putenv("HOME=/home/httpd/");
if($tocrypt) {
// encrypt and set $code to result.
$command="echo '$tocrypt' | gpg -a -q --no-tty -e -u $user -r $user";
// $code = `$command`;
// echo "code: $code";
exec($command, $encrypted, $errorcode);
// echo "command: $command \n";
while(list($key,$val) = each ($encrypted)) {
$code.="$val\n";
}
// echo "\n errorcode: $errorcode <br>\n code: $code <br>\n ";
// echo "encrypted: " . array_tunnel($encrypted);
}
if($passphrase && $code) {
// decrypt the code...
$command="echo '$passphrase\n$code' | gpg -v --batch
--no-secmem-warning --passphrase-fd 0 --decrypt";
exec($command, $encrypted, $errorcode);
// echo "command: $command \n";
// echo "\n errorcode: $errorcode <br>\n code: $code <br>\n ";
// echo "encrypted: " . array_tunnel($encrypted);
echo "your secret message was: ";
while(list($key,$val) = each ($encrypted)) {
echo "$val\n";
}
}
?>
</pre>
<form method=post action=gpgtest.php3>
<input type=text name=passphrase>
<textarea name="code" rows=10 cols=80><? echo $code ?>
</textarea>
<input type=submit value=decrypt>
</form>
</pre>
<hr>
<pre>
<form method=post action=gpgtest.php3>
<input type=text name=tocrypt>
<input type=submit value=encrypt>
</form>
</pre>
--------------------- Kudosnet Technologies Inc. ---------------------
For a copy of our most recent newsletter send a blank email to:
mailto:latestnews@kudosnet.net
---------------------------- 1-877-885-8367 --------------------------