Exemples

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