Introduzione
These functions are intended to work with . 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.
Requisiti
To use it, download the mhash distribution from and follow the included
installation instructions.
Istallazione
You need to compile PHP with the
--with-mhash[=DIR] parameter to enable
this extension. DIR is the mhash install directory.
Configurazione Runtime
Questa estensione non definisce
alcuna direttiva di configurazione
Resource Type
Questa estensione non definisce alcun tipo di risorsa.
Costanti Predefinite
Queste costanti sono definite da questa estensione e
sono disponibili solo se l'estensione � stata compilata
nel PHP o se � stata caricata dinamicamente a runtime.
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_MD5
MHASH_SHA1
MHASH_HAVAL256
MHASH_HAVAL192
MHASH_HAVAL160
MHASH_HAVAL128
MHASH_RIPEMD160
MHASH_GOST
MHASH_TIGER
MHASH_CRC32
MHASH_CRC32B
Esempi
Esempio 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);
print "The hash is ".bin2hex ($hash)."<br />\n";
$hash = mhash (MHASH_MD5, $input, "Jefe");
print "The hmac is ".bin2hex ($hash)."<br />\n";
?> |
This will produce:
The hash is d03cb659cbf9192dcd066272249f8412
The hmac is 750c783e6ab0b503eaa86e310a5db738 |
|