WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
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 Index
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
Mobile Dev World

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 : gpg encryption. 99% of it will apply to PGP.
Categories : Credit Cards, Authentication, Ecommerce, Misc Update Picture
Richard Lynch
Date : Sep 28th 1999
Grade : 5 of 5 (graded 2 times)
Viewed : 9300
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Richard Lynch
Action : Grade This Code Example
Tools : My Examples List

  Submit your own code examples 
 

As a result of the thread on PGP/gpg, somebody asked me to post my script.

It's not so much a script as a few lines of code, and hours and hours of playing with gpg to make it work :-)

But here it is, with copious notes:

// This "script" and its comments apply only
// to taking a chunk of text and using a
// public key to encrypt it for a private
// key to decode.
// A private key on a web server that
// PHP can get to just isn't private.

// If you wanna argue that, take it up with
// Werner & co. I'm just parroting what
// they said. :-)

$data = "Text to encrypt."

// Explanation follows...
$command = "echo '$data' | /full/path/gpg -a --batch --no-secmem-warning -e -u 'webmaster' -r 'sales'";
/*
-u 'webmaster' ==> the "From" user that PHP masquerades as
It needs to be the first user you set up in gpg
with a private/public key pair
gpg doesn't grok the idea of an anonymously publicly
encrypted message
NOTE: I heard that newer versions of gpg do this okay.

-r 'sales' ==> the "To" user for which you keep *ONLY*
the public key on your web server

The private key matching 'sales's public key
should be considered the "Secret Decoder Ring"

Under no circumstances should it be on your
web server at any time.

The other flags are well-explained by 'gpg --help'
*/

// Store HOME and set it to what gpg needs.
// This may not be needed any more...
$oldhome = getEnv("HOME");
putenv("HOME=/path/to/the/home/dir/of/webmaster/above/");

// Actually execute the command
$result = exec($command, $encrypted, $errorcode);

// Restore HOME, silly as it is.
putenv("HOME=$oldhome");

if ($errorcode){
echo "Error $errorcode encrypting your data.<BR>\n";
echo "99.999% of the time this boils down to path/permissions.<BR>\n";
exit;
}

$encrypteddata = implode("\n", $encrypted);

References:
http://www.gnupg.org
http://www.php.net



Validation function for LUHNMod10 and variant. Can discriminate credit card numbers of varying lengths. Uses [Double >> Sum-of-Digits] transform.
Categories : Credit Cards, Authentication, Ecommerce, PHP
Real-Time Transaction Processing PHP Class. Credit Cards & Checks. Supports system check, address verification, authorization and deposit, deposit, credit, commercial card, electronic check debit, and more.
Categories : PHP Classes, OpenSSL, Credit Cards, Ecommerce, Verisign Payflow Pro
Validating Credit Card Numbers Without Bank Involvement
Categories : Credit Cards, Ecommerce, Java Script
Credit Card Identification and Validation Class - The credit_card class provides methods for cleaning, validating and identifying the type of credit card numbers.
Categories : PHP, PHP Classes, Credit Cards, Ecommerce, Algorithms
ECHO-Perl Module Credit Card, Check and ACH Transaction Processor
Categories : Perl, Cybercash, Classes and Objects, Ecommerce, Credit Cards
ECHOcart - Open Source Shopping Cart
Categories : PHP, Credit Cards, Ecommerce
A set of functions to check the validity of a credit card number.
Categories : Ecommerce, Credit Cards, PHP
Credit Card validation routine. Uses MOD 10 to check if credit card number is valid.
Categories : Ecommerce, Credit Cards, PHP, Complete Programs
an example of the cyberlib payment class
Categories : PHP, PHP Classes, Ecommerce, Credit Cards
After discovering some credit card validation routines didnt work - here is one that I found works with all the numbers I have tried so far
Categories : Credit Cards, Ecommerce, PHP
credit card security code
Categories : PHP, Credit Cards, PHP Classes, Credit Cards
Credit Card Numbers for testing
Categories : Credit Cards, Ecommerce, Debugging
mod_auth_mysql - mod_auth_mysql was written in order to allow users to use the blazing quick speed of MySQL in order to store authentication information for their apache web servers.
Categories : Authentication, MySQL, Databases
Password protection for Phorum 3.1.x with userlevels and log.
Categories : PHP, MySQL, Authentication, Security
This script allows people to add their favorite quotes to your website. This could easily be modified to be a guestbook script or comment page script.
Categories : PHP, Complete Programs, HTML and PHP, Misc