Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > f800694edefe91adea2624f711a41a2d > files > 4262

php-manual-en-5.5.7-1.mga4.noarch.rpm

<!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>Calculate the md5 hash of a string</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.md5-file.html">md5_file</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.metaphone.html">metaphone</a></div>
 <div class="up"><a href="ref.strings.html">String Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.md5" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">md5</h1>
  <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">md5</span> &mdash; <span class="dc-title">Calculate the md5 hash of a string</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.md5-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">string</span> <span class="methodname"><strong>md5</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$str</code></span>
   [, <span class="methodparam"><span class="type">bool</span> <code class="parameter">$raw_output</code><span class="initializer"> = false</span></span>
  ] )</div>

  <p class="para rdfs-comment">
   Calculates the MD5 hash of <em><code class="parameter">str</code></em> using the
   <a href="http://www.faqs.org/rfcs/rfc1321" class="link external">&raquo;&nbsp;RSA Data Security, Inc.
   MD5 Message-Digest Algorithm</a>, and returns that hash.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.md5-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   <dl>

    <dt>

     <span class="term"><em><code class="parameter">str</code></em></span>
     <dd>

      <p class="para">
       The string.
      </p>
     </dd>

    </dt>

    <dt>

     <span class="term"><em><code class="parameter">raw_output</code></em></span>
     <dd>

      <p class="para">
       If the optional <em><code class="parameter">raw_output</code></em> is set to <strong><code>TRUE</code></strong>,
       then the md5 digest is instead returned in raw binary format with a
       length of 16.
      </p>
     </dd>

    </dt>

   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.md5-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns the hash as a 32-character hexadecimal number. 
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.md5-changelog">
  <h3 class="title">Changelog</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>Version</th>
       <th>Description</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>5.0.0</td>
       <td>
        The <em><code class="parameter">raw_output</code></em> parameter was added.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.md5-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-4846">
    <p><strong>Example #1 A  <span class="function"><strong>md5()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$str&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'apple'</span><span style="color: #007700">;<br /><br />if&nbsp;(</span><span style="color: #0000BB">md5</span><span style="color: #007700">(</span><span style="color: #0000BB">$str</span><span style="color: #007700">)&nbsp;===&nbsp;</span><span style="color: #DD0000">'1f3870be274f6c49b3e31a0c6728957f'</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"Would&nbsp;you&nbsp;like&nbsp;a&nbsp;green&nbsp;or&nbsp;red&nbsp;apple?"</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
 </div>

 
  <div class="refsect1 notes" id="refsect1-function.md5-notes">
  <h3 class="title">Notes</h3>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
 <strong>Secure password hashing</strong><br />
 <p class="para">
  It is not recommended to use this function to secure passwords, due to the fast nature of this hashing algorithm. See
  <a href="faq.passwords.html#faq.passwords.fasthash" class="link">here</a> for details.
 </p>
</p></blockquote>

 </div>


 <div class="refsect1 seealso" id="refsect1-function.md5-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"> <span class="function"><a href="function.md5-file.html" class="function" rel="rdfs-seeAlso">md5_file()</a> - Calculates the md5 hash of a given file</span></li>
    <li class="member"> <span class="function"><a href="function.sha1-file.html" class="function" rel="rdfs-seeAlso">sha1_file()</a> - Calculate the sha1 hash of a file</span></li>
    <li class="member"> <span class="function"><a href="function.crc32.html" class="function" rel="rdfs-seeAlso">crc32()</a> - Calculates the crc32 polynomial of a string</span></li>
    <li class="member"> <span class="function"><a href="function.sha1.html" class="function" rel="rdfs-seeAlso">sha1()</a> - Calculate the sha1 hash of a string</span></li>
    <li class="member"> <span class="function"><a href="function.hash.html" class="function" rel="rdfs-seeAlso">hash()</a> - Generate a hash value (message digest)</span></li>
   </ul>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.md5-file.html">md5_file</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.metaphone.html">metaphone</a></div>
 <div class="up"><a href="ref.strings.html">String Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>