<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.strings.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'ru',
  ),
  'this' => 
  array (
    0 => 'function.md5.php',
    1 => 'md5',
    2 => 'Возвращает MD5-хеш строки',
  ),
  'up' => 
  array (
    0 => 'ref.strings.php',
    1 => 'Функции для работы со строками',
  ),
  'prev' => 
  array (
    0 => 'function.ltrim.php',
    1 => 'ltrim',
  ),
  'next' => 
  array (
    0 => 'function.md5-file.php',
    1 => 'md5_file',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'ru',
    'path' => 'reference/strings/functions/md5.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.md5" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">md5</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">md5</span> &mdash; <span class="dc-title">Возвращает MD5-хеш строки</span></p>

 </div>

 <div id="function.md5-refsynopsisdiv">
  <div class="warning"><strong class="warning">Внимание</strong>
<p class="para">
 Не рекомендуется использовать эту функцию для безопасного хранения
 паролей ввиду высокой скорости работы этого алгоритма. Подробнее об этом рассказывает
 раздел «<a href="faq.passwords.php#faq.passwords.fasthash" class="link">Ответы на часто задаваемые вопросы о хешировании паролей</a>».
</p>
</div>

 </div>

 <div class="refsect1 description" id="refsect1-function.md5-description">
  <h3 class="title">Описание</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>md5</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$string</code></span>, <span class="methodparam"><span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span> <code class="parameter">$binary</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong></span></span>): <span class="type"><a href="language.types.string.php" class="type string">string</a></span></div>

  <p class="para rdfs-comment">
   Вычисляет MD5-хеш строки <code class="parameter">string</code>, используя
   <a href="https://datatracker.ietf.org/doc/html/rfc1321" class="link external">&raquo;&nbsp;алгоритм MD5 RSA Data Security,
    Inc.</a> и возвращает этот хеш.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.md5-parameters">
  <h3 class="title">Список параметров</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">string</code></dt>
     <dd>
      <p class="para">
       Строка.
      </p>
     </dd>
    
    
     <dt><code class="parameter">binary</code></dt>
     <dd>
      <p class="para">
       Если необязательный аргумент <code class="parameter">binary</code>
       имеет значение <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>, то возвращается бинарная строка из
       16 символов.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.md5-returnvalues">
  <h3 class="title">Возвращаемые значения</h3>
  <p class="para">
   Возвращает хеш в виде 32-символьного шестнадцатеричного числа.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.md5-examples">
  <h3 class="title">Примеры</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Пример #1 Пример использования <span class="function"><strong>md5()</strong></span></strong></p>
    <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$str </span><span style="color: #007700">= </span><span style="color: #DD0000">'яблоко'</span><span style="color: #007700">;<br /><br />if (</span><span style="color: #0000BB">md5</span><span style="color: #007700">(</span><span style="color: #0000BB">$str</span><span style="color: #007700">) === </span><span style="color: #DD0000">'1afa148eb41f2e7103f21410bf48346c'</span><span style="color: #007700">) {<br />    echo </span><span style="color: #DD0000">"Вам зелёное или красное яблоко?"</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

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


 <div class="refsect1 seealso" id="refsect1-function.md5-seealso">
  <h3 class="title">Смотрите также</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.hash.php" class="function" rel="rdfs-seeAlso">hash()</a> - Генерирует хеш-значение (подпись сообщения)</span></li>
    <li><span class="function"><a href="function.password-hash.php" class="function" rel="rdfs-seeAlso">password_hash()</a> - Создаёт хеш пароля</span></li>
   </ul>
  </p>
 </div>


</div><?php manual_footer($setup); ?>