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.

Encryption Basics<br />

353<br />

Private Key Encryption<br />

Private key encryption, also called secret key encryption, relies on authorized people<br />

knowing or having access to a key.This key must be kept secret. If the key falls into the<br />

wrong h<strong>and</strong>s, unauthorized people can also read your encrypted messages. As shown in<br />

Figure 15.4, both the sender (who encrypts the message) <strong>and</strong> the recipient (who<br />

decrypts the message) have the same key.<br />

The most widely used secret key algorithm is the Data Encryption St<strong>and</strong>ard (DES).<br />

This scheme was developed by IBM in the 1970s <strong>and</strong> adopted as the American st<strong>and</strong>ard<br />

for commercial <strong>and</strong> unclassified government communications. Computing speeds are<br />

orders of magnitudes faster now than in 1970, <strong>and</strong> DES has been obsolete since at<br />

least 1998.<br />

Other well-known secret key systems include RC2, RC4, RC5, triple DES, <strong>and</strong><br />

IDEA.Triple DES is fairly secure. It uses the same algorithm as DES, applied three times<br />

with up to three different keys. A plain text message is encrypted with key one, decrypted<br />

with key two, <strong>and</strong> then encrypted with key three.<br />

Note<br />

Somewhat paradoxically, triple DES is twice as secure as DES. If you needed something three times as<br />

strong, you would write a program or implement a quintuple DES algorithm.<br />

One obvious flaw of secret key encryption is that, to send somebody a secure message,<br />

you need a secure way to get the secret key to him. If you have a secure way to<br />

deliver a key, why not just deliver the message that way?<br />

Fortunately, there was a breakthrough in 1976, when Diffie <strong>and</strong> Hellman published<br />

the first public key scheme.<br />

Public Key Encryption<br />

Public key encryption relies on two different keys: a public key <strong>and</strong> a private key. As<br />

shown in Figure 15.5, the public key is used to encrypt messages <strong>and</strong> the private key to<br />

decrypt them.<br />

The advantage to this system is that the public key, as its name suggests, can be distributed<br />

publicly. Anybody to whom you give your public key can send you a secure<br />

message. As long as only you have your private key, then only you can decrypt the message.<br />

The most common public key algorithm is RSA, developed by Rivest, Shamir, <strong>and</strong><br />

Adelman at MIT <strong>and</strong> published in 1978. RSA was a proprietary system, but the patent<br />

expired in September 2000.

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

Saved successfully!

Ooh no, something went wrong!