11.07.2015 Views

PHP MySQL - Stilson.net

PHP MySQL - Stilson.net

PHP MySQL - Stilson.net

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

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

www.it-ebooks.infoCHAPTER 21 • SECURING YOUR WEB SITE1. Go to http://mcrypt.sourceforge.<strong>net</strong> and download the package source.2. Extract the contents of the compressed distribution and follow the installationinstructions as specified in the INSTALL document.3. Compile <strong>PHP</strong> with the --with-mcrypt option.MCrypt supports the following encryption algorithms:• ARCFOUR • ENIGMA • RC (2, 4) • TEAN• ARCFOUR_IV • GOST • RC6 (128, 192, 256) • THREEWAY• BLOWFISH • IDEA • RIJNDAEL (128, 192, 256) • 3DES• CAST • LOKI97 • SAFER (64, 128, and PLUS) • TWOFISH (128, 192, and 256)• CRYPT • MARS • SERPENT (128, 192, and 256) • WAKE• DES • PANAMA • SKIPJACK • XTEAThis section introduces just a sample of the more than 35 functions made available via this <strong>PHP</strong>extension. For a complete introduction, consult the <strong>PHP</strong> manual.Encrypting Data with MCryptThe mcrypt_encrypt() function encrypts the provided data, returning the encrypted result. Theprototype follows:string mcrypt_encrypt(string cipher, string key, string data,string mode [, string iv])The provided cipher names the particular encryption algorithm, and the parameter key determinesthe key used to encrypt the data. The mode parameter specifies one of the six available encryption modes:electronic codebook, cipher block chaining, cipher feedback, 8-bit output feedback, N-bit outputfeedback, and a special stream mode. Each is referenced by an abbreviation: ecb, cbc, cfb, ofb, nofb, andstream, respectively. Finally, the iv parameter initializes cbc, cfb, ofb, and certain algorithms used instream mode. Consider an example:435

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

Saved successfully!

Ooh no, something went wrong!