WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search


Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder



Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Encoding data using PGP via PHP's proc_* functions
Categories : Cryptography, Security, Email, PHP, PGP Click here to Update Your Picture
Jon Ellis-Jones
Date : Nov 08th 2004
Grade : 2 of 5 (graded 5 times)
Viewed : 15333
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Jon Ellis-Jones
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

JONNY DOVKA'S PGP EXPERIENCE!

OK. Before I begin, YES I did this on an IIS Windows system (my boss doesn't
like Apache for some reason). YES, it uses a non-US form of PGP found at this
web-address (I'm British, but im sure the code can easily be adapted):
--> http://www.pgpi.org/

The below code is similar to the code in the PHP Manual, but there are many small
considerations you'll need to account for before PGP decides it likes you and works.

1. Make sure the path to your PGP directory is in your websystem's path. You
can check this by doing a phpinfo(); and looking under the _ENV['PATH']
key. This is very important, especially if you develop on a network!
2. CHECK what the command line arguments your version of PGP accepts. Here, I'm
using -sfa, -f being the important one (filter allows data through STDIN/STDOUT
to be checked by the PGP binary. -z supplies your password, so make sure you
change that one (no, you don't need the >).
3. $DATA_TO_ENCRYPT is the data you wish to...err, encrypt. The chr(26) is actually
the same as hitting CTRL+Z (^Z) in DOS, which is commonly known as the EOF char.
4. $pgpBuffer is a string that contains the output of the PGP binary. With that, you
can then (for example, as I have done) use it to e-mail someone!

I hope this helps someone. I'm only putting it on here because it was such a pain in
the butt to get working. If it doesn't work, check your paths, consider using chdir()
to fix the problem, and have a look at the output from PGP in error.txt!

~ dovka


<?php
$descriptorspec
= array(
   
0 => array("pipe", "r"),             // STDIN
   
1 => array("pipe", "w"),              // STDOUT
   
2 => array("file", "error.txt", "a")     // STDERR
);

$proc = proc_open("pgp -sfa -z >", $descriptorspec, $pipes);

stream_set_blocking($pipes[1], false);
stream_set_blocking($pipes[0], false);   
fwrite($pipes[0], $DATA_TO_ENCRYPT . "nn" . chr(26) . chr(26));
fclose($pipes[0]);

while(!
feof($pipes[1]))
   
$pgpBuffer .= fgets($pipes[1], 1024);

fclose($pipes[1]);
$return_value = proc_close($proc);

// echo $pgpBuffer;
?>



Protect your mailto: email addresses from bots - pure PHP
Categories : PHP, Email, Security
Generating and Matching Secure and Strong Password Hash
Categories : PHP, PHP Classes, Cryptography, Security
Protect your email links from being spidered by spam email robots!
Categories : PHP, Security, Mail, Email
Function to generate readable/remeberable random password
Categories : PHP, Security, Security
send_mail function to defeat Header Injection Hacking/Spamming
Categories : PHP, Email, Form Processing, Security
A damaged image generator (class) for validating text. CAPTCHA - Completely Automated Public Turing test to tell Computers and Humans Apart
Categories : PHP, PHP Classes, Security, GD image library, Security
Distribute PHP Software Protected by a License Key.
Categories : PHP, Cryptography, Security, Software
MD5 secured login
Categories : PHP, Java Script, Authentication, Security
PHP3 FormMail This script sends E-mail using PHP3 function mail(). Body of message is from text file that you create. Easily modified.
Categories : PHP, Email, IMAP
Class for sending mail with MIME attachments in multipart format using external sendmail, mimencode and zip
Categories : Email, Network, PHP, PHP Classes
Easily Grant Temporary SSH Access to yourself when in remote location
Categories : PHP, Linux, Cron, Security
addslashes automatically to $_POST variables
Categories : PHP, Form Processing, Security
Password using php, Javascript, and html form
Categories : Security, PHP, Authentication, Java Script
A simple PHP login script that you can modify to suite your needs. It use a session to store data in a session file submited by the page.
Categories : PHP, Sessions, Security, Authentication
Securing Web Forms with Simple PHP-CAPTCHA (Completely Automated Public Turing test to tell Computers and Humans Apart)
Categories : PHP, Security, GD image library, Sessions