Mhash Functions
소개
These functions are intended to work with » mhash. Mhash can be used to create checksums, message digests, message authentication codes, and more.
This is an interface to the mhash library. mhash supports a wide variety of hash algorithms such as MD5, SHA1, GOST, and many others. For a complete list of supported hashes, refer to the documentation of mhash. The general rule is that you can access the hash algorithm from PHP with MHASH_HASHNAME. For example, to access TIGER you use the PHP constant MHASH_TIGER.
Note: This extension has been moved to the » PECL repository and is no longer bundled with PHP as of PHP 5.3.0. This extension is obsoleted by Hash.
요구 조건
To use it, download the mhash distribution from » its web site and follow the included installation instructions.
설치
You need to compile PHP with the --with-mhash[=DIR] parameter to enable this extension. DIR is the mhash install directory.
실행시 설정
이 확장은 php.ini 설정이 존재하지 않습니다.
자원형
이 확장은 리소스형을 정의하지 않습니다.
예약 상수
이 확장은 다음의 상수들을 정의합니다. 이 확장을 PHP에 내장했거나, 실행시에 동적으로 읽어들일 경우에만 사용할 수 있습니다.
Here is a list of hashes which are currently supported by mhash. If a hash is not listed here, but is listed by mhash as supported, you can safely assume that this documentation is outdated.
- MHASH_ADLER32
- MHASH_CRC32
- MHASH_CRC32B
- MHASH_GOST
- MHASH_HAVAL128
- MHASH_HAVAL160
- MHASH_HAVAL192
- MHASH_HAVAL256
- MHASH_MD4
- MHASH_MD5
- MHASH_RIPEMD160
- MHASH_SHA1
- MHASH_SHA256
- MHASH_TIGER
- MHASH_TIGER128
- MHASH_TIGER160
예제
Example#1 Compute the MD5 digest and hmac and print it out as hex
<?php
$input = "what do ya want for nothing?";
$hash = mhash(MHASH_MD5, $input);
echo "The hash is " . bin2hex($hash) . "<br />\n";
$hash = mhash(MHASH_MD5, $input, "Jefe");
echo "The hmac is " . bin2hex($hash) . "<br />\n";
?>
This will produce:
The hash is d03cb659cbf9192dcd066272249f8412 The hmac is 750c783e6ab0b503eaa86e310a5db738
Table of Contents
- mhash_count — Get the highest available hash id
- mhash_get_block_size — Get the block size of the specified hash
- mhash_get_hash_name — Get the name of the specified hash
- mhash_keygen_s2k — Generates a key
- mhash — Compute hash