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.

422 Chapter 18 Implementing Secure Transactions with <strong>PHP</strong> <strong>and</strong> <strong>MySQL</strong><br />

Type<br />

cd ~<br />

mkdir .gnupg<br />

The user nobody needs a signing key of her own.To create this key, run this comm<strong>and</strong><br />

again:<br />

gpg --gen-key<br />

Because your nobody user probably receives very little personal email, you can create a<br />

signing-only key for her.This key’s only purpose is to allow you to trust the public key<br />

you extracted earlier.<br />

To import the pubic key exported earlier, use the following comm<strong>and</strong>:<br />

gpg --import filename<br />

To tell GPG that you want to trust this key, you need to edit the key’s properties using<br />

this comm<strong>and</strong>:<br />

gpg --edit-key ‘Luke Welling ’<br />

On this line, the text in single quotation marks is the name of the key. Obviously, the<br />

name of your key will not be ‘Luke Welling ’, but a<br />

combination of the name, comment, <strong>and</strong> email address you provided when generating it.<br />

Options within this program include help, which describes the available comm<strong>and</strong>s:<br />

trust, sign, <strong>and</strong> save.<br />

Type trust <strong>and</strong> tell GPG that you trust your key fully.Type sign to sign this public<br />

key using nobody’s private key. Finally, type save to exit this program, keeping your<br />

changes.<br />

Testing GPG<br />

GPG should now be set up <strong>and</strong> ready to use. Creating a file containing some text <strong>and</strong><br />

saving it as test.txt will allow you to test it.<br />

Typing the following comm<strong>and</strong> (modified to use the name of your key)<br />

gpg -a --recipient ‘Luke Welling ’ --encrypt test.txt<br />

should give you the warning<br />

gpg: Warning: using insecure memory!

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

Saved successfully!

Ooh no, something went wrong!