array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'fr', ), 'this' => array ( 0 => 'mhash.examples.php', 1 => 'Exemples', ), 'up' => array ( 0 => 'book.mhash.php', 1 => 'Mhash', ), 'prev' => array ( 0 => 'mhash.constants.php', 1 => 'Constantes pré-définies', ), 'next' => array ( 0 => 'ref.mhash.php', 1 => 'Fonctions Mhash', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'fr', 'path' => 'reference/mhash/examples.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
Exemple #1 Calcule le MD5 et le hmac, puis l'affiche comme un hexadécimal
<?php
$input = "what do ya want for nothing?";
$hash = mhash(MHASH_MD5, $input);
echo "Le hash vaut " . bin2hex($hash) . "<br />\n";
$hash = mhash(MHASH_MD5, $input, "Jefe");
echo "Le hmac vaut " . bin2hex($hash) . "<br />\n";
?>
L'exemple ci-dessus va afficher :
Le hash vaut d03cb659cbf9192dcd066272249f8412 Le hmac vaut 750c783e6ab0b503eaa86e310a5db738