13.09.2016 Views

PHP and MySQL Web Development 4th Ed-tqw-_darksiderg

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Using Encryption in <strong>PHP</strong><br />

419<br />

Storing Credit Card Numbers<br />

Now that we’ve discussed secure storage for sensitive data, one type of sensitive data<br />

deserves special mention. Internet users are paranoid about their credit card numbers. If<br />

you are going to store them, you need to be very careful.You also need to ask yourself<br />

why you are storing them <strong>and</strong> whether it is really necessary.<br />

What are you going to do with a card number? If you have a one-off transaction to<br />

process real-time card processing, you will be better off accepting the card number from<br />

your customer <strong>and</strong> sending it straight to your transaction processing gateway without<br />

storing it at all.<br />

If you have periodic charges to make, such as the authority to charge a monthly fee<br />

to the same card for an ongoing subscription, this approach might not be an option. In<br />

this case, you should think about storing the numbers somewhere other than the web<br />

server.<br />

If you are going to store large numbers of your customers’ card details, make sure that<br />

you have a skilled <strong>and</strong> somewhat paranoid system administrator who has enough time to<br />

check up-to-date sources of security information for the operating system <strong>and</strong> other<br />

products you use.<br />

Using Encryption in <strong>PHP</strong><br />

A simple, but useful, task you can use to demonstrate encryption is sending encrypted<br />

email. For many years, the de facto st<strong>and</strong>ard for encrypted email has been PGP, which<br />

st<strong>and</strong>s for Pretty Good Privacy. Philip R. Zimmermann wrote PGP specifically to add<br />

privacy to email.<br />

Freeware versions of PGP are available, but you should note that it is not Free<br />

Software.The freeware version can legally be used only for noncommercial use.<br />

You can download the freeware or purchase a commercial license of PGP from PGP<br />

Corporation. For details, see http://www.pgp.com.<br />

For more information on the history of PGP <strong>and</strong> the available versions, read the article,“Where<br />

to Get PGP,” from Philip Zimmerman: http://www.philzimmermann.com/<br />

EN/findpgp/findpgp.html.<br />

An open source alternative to PGP has more recently become available. Gnu Privacy<br />

Guard, known as GPG, is a free (as in beer) <strong>and</strong> Free (as in speech) replacement for PGP.<br />

It contains no patented algorithms <strong>and</strong> can be used commercially without restriction.<br />

The two products perform the same task in fairly similar ways. If you intend to use<br />

the comm<strong>and</strong>-line tools, the differences might not matter, but each has different interfaces<br />

such as plug-ins for email programs that automatically decrypt email when it is<br />

received.<br />

GPG is available from http://www.gnupg.org.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!