11.07.2015 Views

PHP MySQL - Stilson.net

PHP MySQL - Stilson.net

PHP MySQL - Stilson.net

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

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

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

CHAPTER 21 • SECURING YOUR WEB SITEwww.it-ebooks.infoThis returns the following:f5d8b337f27e251c25f6a17c74f93c5e9a8a21b91f2b1b0151e649232b486c93b36af467914bc7d8You can then decrypt the text with the mcrypt_decrypt() function.Decrypting Data with MCryptThe mcrypt_decrypt() function decrypts a previously encrypted cipher, provided that the cipher, key,and mode are the same as those used to encrypt the data. Its prototype follows:string mcrypt_decrypt(string cipher, string key, string data,string mode [, string iv])Go ahead and insert the following line into the previous example, directly after the last statement:echo mcrypt_decrypt(MCRYPT_DES, $key, $enc, MCRYPT_MODE_CBC, $iv);This returns the following:This is the message I want to encrypt.The methods in this section are only those that are in some way incorporated into the <strong>PHP</strong>extension set. However, you are not limited to these encryption/hashing solutions. Keep in mind thatyou can use functions such as popen() or exec() with any of your favorite third-party encryptiontechnologies, for example, PGP (www.pgpi.org) or GPG (www.gnupg.org).SummaryThe material presented in this chapter provided you with several important tips, but the main goal wasto get you thinking about the many attack vectors that your application and server face. Note that thetopics described in this chapter are but a tiny sliver of the total security pie. If you’re new to the subject,take some time to visit the prominent security-related web sites.Regardless of your prior experience, you need to devise a strategy for staying abreast of breakingsecurity news. Subscribing to the newsletters from the more prevalent security-focused web sites as wellas from the product developers may be the best way to do so. Above all, it’s important that you have astrategy and stick to it, lest your castle be conquered.436

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

Saved successfully!

Ooh no, something went wrong!