Go to http://mcrypt.sourceforge.net/ and download the package source.
2. Extract the contents of the compressed distribution and follow the installation
instructions as specified in the INSTALL document.
3. Compile PHP with the --with-mcrypt option.
MCrypt supports a number of encryption algorithms, all of which are listed here:
??? ARCFOUR
??? ARCFOUR_IV
CHAPTER 21 ?– SECURE PHP PROGRAMMING 563
??? BLOWFISH
??? CAST
??? CRYPT
??? DES
??? ENIGMA
??? GOST
??? IDEA
??? LOKI97
??? MARS
??? PANAMA
??? RC (2, 4)
??? RC6 (128, 192, 256)
??? RIJNDAEL (128, 192, 256)
??? SAFER (64, 128, and PLUS)
??? SERPENT (128, 192, and 256)
??? SKIPJACK
??? TEAN
??? THREEWAY
??? 3DES
??? TWOFISH (128, 192, and 256)
??? WAKE
??? XTEA
564 CHAPTER 21 ?– SECURE PHP PROGRAMMING
This section introduces just a sample of the more than 35 functions made available
via this PHP extension. For a complete introduction, consult the PHP manual.
Encrypting Data with MCrypt
The mcrypt_encrypt() function encrypts the provided data, returning the encrypted
result. The prototype 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 determines the 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 output feedback, and a special stream
mode.
Pages:
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648