13.09.2016 Views

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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Encryption Basics<br />

351<br />

Passwords can also be captured electronically. By running a program to capture<br />

keystrokes at a terminal or using a packet sniffer to capture network traffic, crackers<br />

can—<strong>and</strong> do—capture usable pairs of login names <strong>and</strong> passwords.You can limit the<br />

opportunities to capture passwords by encrypting network traffic.<br />

For all their potential flaws, passwords are a simple <strong>and</strong> relatively effective way of<br />

authenticating your users.They provide a level of secrecy that might not be appropriate<br />

for national security but is ideal for checking on the delivery status of a customer’s order.<br />

Authentication mechanisms are built in to the most popular web browsers <strong>and</strong> web<br />

servers. A web server might require a username <strong>and</strong> password for people requesting files<br />

from particular directories on the server.<br />

When challenged for a login name <strong>and</strong> password, your browser presents a dialog box<br />

similar to the one shown in Figure 15.2.<br />

Figure 15.2 <strong>Web</strong> browsers prompt users for authentication when they<br />

attempt to visit a restricted directory on a web server.<br />

Both the Apache web server <strong>and</strong> Microsoft’s IIS enable you to very easily protect all or<br />

part of a site in this way. Using <strong>PHP</strong> or <strong>MySQL</strong>, you can achieve the same effect. Using<br />

<strong>MySQL</strong> is faster than the built-in authentication. Using <strong>PHP</strong>, you can provide more<br />

flexible authentication or present the request in a more attractive way.<br />

We look at some authentication examples in Chapter 17,“Implementing Authentication<br />

with <strong>PHP</strong> <strong>and</strong> <strong>MySQL</strong>.”<br />

Encryption Basics<br />

An encryption algorithm is a mathematical process to transform information into a seemingly<br />

r<strong>and</strong>om string of data.<br />

The data that you start with is often called plain text, although it is not important to<br />

the process what the information represents—whether it is actually text or some other<br />

sort of data. Similarly, the encrypted information is called ciphertext but rarely looks anything<br />

like text. Figure 15.3 shows the encryption process as a simple flowchart.The plain<br />

text is fed to an encryption engine, which might have been a mechanical device, such as

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

Saved successfully!

Ooh no, something went wrong!