svn: /phpdoc/zh/trunk/reference/password/functions/ password-needs-rehash.xml

From: Date: Sun, 28 Jan 2018 07:58:49 +0000
Subject: svn: /phpdoc/zh/trunk/reference/password/functions/ password-needs-rehash.xml
Groups: php.doc.zh 
Request: Send a blank email to doc-zh+get-5073@lists.php.net to get a copy of this message
daijie Sun, 28 Jan 2018 07:58:49 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=343993 Log: translate password_needs_rehash. Changed paths: A phpdoc/zh/trunk/reference/password/functions/password-needs-rehash.xml Added: phpdoc/zh/trunk/reference/password/functions/password-needs-rehash.xml =================================================================== --- phpdoc/zh/trunk/reference/password/functions/password-needs-rehash.xml (rev 0) +++ phpdoc/zh/trunk/reference/password/functions/password-needs-rehash.xml 2018-01-28 07:58:49 UTC (rev 343993) @@ -0,0 +1,117 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- $Revision$ --> +<!-- EN-Revision: 343891 Maintainer: daijie Status: ready --> +<!-- Reviewed: no --> + +<refentry xml:id="function.password-needs-rehash" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> + <refnamediv> + <refname>password_needs_rehash</refname> + <refpurpose>检测散列值是否匹配指定的选项</refpurpose> + </refnamediv> + + <refsect1 role="description"> + &reftitle.description; + <methodsynopsis> + <type>bool</type><methodname>password_needs_rehash</methodname> + <methodparam><type>string</type><parameter>hash</parameter></methodparam> + <methodparam><type>int</type><parameter>algo</parameter></methodparam> + <methodparam choice="opt"><type>array</type><parameter>options</parameter></methodparam> + </methodsynopsis> + <para> + 此函数检测指定的散列值是否实现了提供的算法和选项。 + 如果没有,需要重新生成散列值。 + </para> + </refsect1> + + <refsect1 role="parameters"> + &reftitle.parameters; + <variablelist> + <varlistentry> + <term><parameter>hash</parameter></term> + <listitem> + <para> + &password.parameter.hash; + </para> + </listitem> + </varlistentry> + <varlistentry> + <term><parameter>algo</parameter></term> + <listitem> + <para> + &password.parameter.algo; + </para> + </listitem> + </varlistentry> + <varlistentry> + <term><parameter>options</parameter></term> + <listitem> + <para> + &password.parameter.options; + </para> + </listitem> + </varlistentry> + </variablelist> + </refsect1> + + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><function>password_needs_rehash</function>用法</title> + <programlisting role="php"> +<![CDATA[ +<?php + +$password = 'rasmuslerdorf'; +$hash = '$2y$10$YCFsG6elYca568hBi2pZ0.3LDL5wjgxct1N8w/oLR/jfHsiQwCqTS'; + +// 当硬件性能得到改善时,cost 参数可以再修改 +$options = array('cost' => 11); + +// 根据明文密码验证储存的散列 +if (password_verify($password, $hash)) { + // 检测是否有更新的可用散列算法 + // 或者 cost 发生变化 + if (password_needs_rehash($hash, PASSWORD_DEFAULT, $options)) { + // 如果是这样,则创建新散列,替换旧散列 + $newHash = password_hash($password, PASSWORD_DEFAULT, $options); + } + + // 使用户登录 +} +?> +]]> + </programlisting> + </example> + </para> + </refsect1> + + <refsect1 role="returnvalues"> + &reftitle.returnvalues; + <para> + 如果散列需要重新生成才能匹配指定的 <parameter>algo</parameter> 和 <parameter>options</parameter>, + 则返回 &true;,否则返回 &false;。 + </para> + </refsect1> +</refentry> + +<!-- Keep this comment at the end of the file +Local variables: +mode: sgml +sgml-omittag:t +sgml-shorttag:t +sgml-minimize-attributes:nil +sgml-always-quote-attributes:t +sgml-indent-step:1 +sgml-indent-data:t +indent-tabs-mode:nil +sgml-parent-document:nil +sgml-default-dtd-file:"~/.phpdoc/manual.ced" +sgml-exposed-tags:nil +sgml-local-catalogs:nil +sgml-local-ecat-files:nil +End: +vim600: syn=xml fen fdm=syntax fdl=2 si +vim: et tw=78 syn=sgml +vi: ts=1 sw=1 +--> Property changes on: phpdoc/zh/trunk/reference/password/functions/password-needs-rehash.xml ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id Rev Revision Date LastChangedDate LastChangedRevision Author LastChangedBy HeadURL URL \ No newline at end of property

« previous php.doc.zh (#5073) next »