How to install the Mhash Extension Library in PHP _ PHP Tutorial

Source: Internet
Author: User
Tags crc32 mcrypt php software
How to install the Mhash Extension Library in PHP. Summary: The version 0.8.3 Mhash extension library supports 12 mixed encoding algorithms. check the header file mhash of Mhashv.0.8.3 carefully. h. you can see that it supports the following mixed encoding algorithms: CRC32HAV Overview: the 0.8.3 version of the Mhash extension library supports 12 mixed encoding algorithms. check the header file Mhash of mhash v.0.8.3 carefully. h: it supports the following mixed encoding algorithms:
CRC32 HAVAL160 MD5
CRC32B HAVAL192 RIPEMD160
GOST haval1_sha1
HAVAL128 HAVAL256 TIGER
How to install the Mhash extension library?
Like Mcrypt, Mhash is not included in the PHP software package. The following is the installation process (not Windows ):
First download the Mhash Extension Library (http://sourceforge.net/projects/mhash)
Gunzipmhash-x.x.x.tar.gz
Tar -xvfmhash-x.x.x.tar
./Configure
Make
Make install
Cd
./Configure-with-mhash = [dir] [-- other-configuration-directives]
Make
Make install
Then, like Mcrypt, other Mhash configurations may be required based on the PHP installation method on Internet server software.
For Windows users, the http://www.php4win.de has a good PHP package including the Mhash Extension Library. Download and decompress the package, and install the package according to the instructions in readme. first.
How to use Mhash?
It is very easy to mix and compile information. let's look at the following example:
<? Php
$ Hash_alg = MHASH_TIGER;
$ Message = "These are the ctions to the secret fort. Two steps left, three steps right, and cha chacha .";

$ Hashed_message = mhash ($ hash_alg, $ message );
Print "The hashed message is". bin2hex ($ hashed_message );
?>
Execute this script to get the following output:
The hashed message is 07a92a4db3a4247f19ec9034ae5400eb60d1a9fbb4ade461
Here, the purpose of using the bin2hex () function is to help us understand the output of $ hashed_message. this is because the result of mixed encoding is in binary format, in order to convert it into an easy-to-understand format, it must be converted to the hexadecimal format.
It should be noted that the mixed editing is a one-way function and the result does not depend on the input.
Mhash has other useful functions. For example, we need to output the name of an algorithm supported by Mhash. because the names of all algorithms supported by Mhash start with MHASH _, we can execute the following code to complete this task:
<? Php
$ Hash_alg = MHASH_TIGER;
Print "This data has been hashed with the". mhash_get_hash_name ($ hashed_message). "hashing algorithm .";
?>
The output is as follows:
This data has been hashed with the TIGER hashing algorithm.
What do I need to know about PHP and encryption?
An important concern for PHP encryption is that the data transmitted between the server and the client is insecure during transmission! PHP is a server-side technology that cannot prevent data leaks during transmission. Therefore, if you want to implement a complete security application, we recommend that you use Apache-SSL or other security servers.

The header file mhash. h of v.0.8.3 can be known. it supports the following mixed encoding algorithm: CRC32 HAV...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.