Prev | Current Page 634 | Next

W. Jason Gilmore

"Beginning PHP and MySQL: From Novice to Professional"

There is another much more
powerful hashing alternative available via the mhash library. This library is introduced
in the next section.
Using the mhash Library
mhash is an open source library that offers an interface to a wide number of hash
algorithms. Authored by Nikos Mavroyanopoulos and Sascha Schumann, mhash can
significantly extend PHP??™s hashing capabilities. Integrating the mhash module into
your PHP distribution is rather simple:
1. Go to http://mhash.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-mhash option.
On completion of the installation process, you have the functionality offered by
mhash at your disposal. This section introduces mhash(), the most prominent of the
five functions made available to PHP when the mhash extension is included.
CHAPTER 21 ?–  SECURE PHP PROGRAMMING 561
Hashing Data with mhash
The function mhash() offers support for a number of hashing algorithms, allowing
developers to incorporate checksums, message digests, and various other digital
signatures into their PHP applications. Its prototype follows:
string mhash(int hash, string data [, string key])
Hashes are also used for storing passwords. mhash() currently supports the hashing
algorithms listed here:
??? ADLER32
??? CRC32
??? CRC32B
??? GOST
??? HAVAL
??? MD4
??? MD5
??? RIPEMD128
??? RIPEMD160
??? SHA1
??? SNEFRU
??? TIGER
Consider an example.


Pages:
622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646