150 Chapter 4 Web Application Concepts Listing 4.4.
152 Chapter 4 Web Application Concepts n mixed decrypt(string what, string my_user_id) Decrypts what with my_user_id as private key. Returns the decrypted text or false on error. n mixed decrypt_conventional(string what, string passphrase) Decrypts what with traditional decryption, using passphrase as the secret key. Returns the decrypted text or false on error. The MCrypt Functions With the MCrypt library, many block algorithms are available, including DES, TripleDES, Blowfish, and IDEA. Space doesn t allow for explaining all these algorithms here, or giving recommendations on how to choose one for a specific scenario; this is covered in detail by many in-depth books and online articles, some of which you can find listed in the Resources section of the CD-ROM. Unfortunately, another library means another API style, and as indicated in Chapter 1, Development Concepts, we think this is bad style.Why does mcrypt_cbc() take an argument defining whether to encrypt or decrypt data? Wouldn t it be more logical and consistent to have two functions, mcrypt_encrypt_cbc() and mcrypt_decrypt_cbc()? There s no session_var() taking REGISTER or UNREGISTER as argument, is there? Well,let s stop complaining.After all,we could simply edit the source for the MCrypt interface and define these additional functions that s the advantage of Open Source software.So back to the topic.The example in Listing 4.5 shows the MCrypt functions in use.The example loops through an array containing all possible MCrypt algorithms and encrypts a message with each algorithm. Listing 4.5 MCrypt routines. // Set up an array of algorithms generally supported by MCrypt $algorithms = array( MCRYPT_BLOWFISH, MCRYPT_DES, MCRYPT_TripleDES, MCRYPT_ThreeWAY, MCRYPT_GOST, MCRYPT_CRYPT, MCRYPT_DES_COMPAT, MCRYPT_SAFER64, MCRYPT_SAFER128, MCRYPT_CAST128, MCRYPT_TEAN, MCRYPT_RC2, MCRYPT_TWOFISH, MCRYPT_TWOFISH128, MCRYPT_TWOFISH192, MCRYPT_TWOFISH256, MCRYPT_RC6, MCRYPT_IDEA );
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Inexpensive Web Hosting services