<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Examples</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="mhash.constants.html">Predefined Constants</a></div> <div class="next" style="text-align: right; float: right;"><a href="ref.mhash.html">Mhash Functions</a></div> <div class="up"><a href="book.mhash.html">Mhash</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="mhash.examples" class="appendix"> <h1>Examples</h1> <p class="para"> <div class="example" id="example-854"> <p><strong>Example #1 Computes the MD5 digest and hmac and print it out as hex</strong></p> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br />$input </span><span style="color: #007700">= </span><span style="color: #DD0000">"what do ya want for nothing?"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$hash </span><span style="color: #007700">= </span><span style="color: #0000BB">mhash</span><span style="color: #007700">(</span><span style="color: #0000BB">MHASH_MD5</span><span style="color: #007700">, </span><span style="color: #0000BB">$input</span><span style="color: #007700">);<br />echo </span><span style="color: #DD0000">"The hash is " </span><span style="color: #007700">. </span><span style="color: #0000BB">bin2hex</span><span style="color: #007700">(</span><span style="color: #0000BB">$hash</span><span style="color: #007700">) . </span><span style="color: #DD0000">"<br />\n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$hash </span><span style="color: #007700">= </span><span style="color: #0000BB">mhash</span><span style="color: #007700">(</span><span style="color: #0000BB">MHASH_MD5</span><span style="color: #007700">, </span><span style="color: #0000BB">$input</span><span style="color: #007700">, </span><span style="color: #DD0000">"Jefe"</span><span style="color: #007700">);<br />echo </span><span style="color: #DD0000">"The hmac is " </span><span style="color: #007700">. </span><span style="color: #0000BB">bin2hex</span><span style="color: #007700">(</span><span style="color: #0000BB">$hash</span><span style="color: #007700">) . </span><span style="color: #DD0000">"<br />\n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?></span> </span> </code></div> </div> <div class="example-contents"><p>The above example will output:</p></div> <div class="example-contents screen"> <div class="cdata"><pre> The hash is d03cb659cbf9192dcd066272249f8412 The hmac is 750c783e6ab0b503eaa86e310a5db738 </pre></div> </div> </div> </p> </div> <hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="mhash.constants.html">Predefined Constants</a></div> <div class="next" style="text-align: right; float: right;"><a href="ref.mhash.html">Mhash Functions</a></div> <div class="up"><a href="book.mhash.html">Mhash</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>