reference/password/functions/password-verify.xml
5baba54a67be43d689970983cfc6d24debad1ce0
5baba54a67be43d689970983cfc6d24debad1ce0
...
...
@@ -1,6 +1,5 @@
1
1
<?xml version="1.0" encoding="utf-8"?>
2
2
<!-- $Revision$ -->
3
-
4
3
<refentry xml:id="function.password-verify" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
5
4
<refnamediv>
6
5
<refname>password_verify</refname>
...
...
@@ -11,11 +10,14 @@
11
10
&reftitle.description;
12
11
<methodsynopsis>
13
12
<type>bool</type><methodname>password_verify</methodname>
14
-
<methodparam><type>string</type><parameter>password</parameter></methodparam>
13
+
<methodparam><modifier role="attribute">#[\SensitiveParameter]</modifier><type>string</type><parameter>password</parameter></methodparam>
15
14
<methodparam><type>string</type><parameter>hash</parameter></methodparam>
16
15
</methodsynopsis>
17
16
<para>
18
17
Verifies that the given hash matches the given password.
18
+
<function>password_verify</function> is compatible with <function>crypt</function>.
19
+
Therefore, password hashes created by <function>crypt</function> can be used with
20
+
<function>password_verify</function>.
19
21
</para>
20
22
<para>
21
23
Note that <function>password_hash</function> returns the algorithm, cost and salt
...
...
@@ -62,11 +64,15 @@
62
64
<para>
63
65
<example>
64
66
<title><function>password_verify</function> example</title>
67
+
<para>
68
+
This is a simplified example; it is recommended to rehash a correct password
69
+
if necessary; see <function>password_needs_rehash</function> for an example.
70
+
</para>
65
71
<programlisting role="php">
66
72
<![CDATA[
67
73
<?php
68
74
// See the password_hash() example to see where this came from.
69
-
$hash = '$2y$07$BCryptRequires22Chrcte/VlQH0piJtjXl.0t1XkA8pw9dMXTpOq';
75
+
$hash = '$2y$12$4Umg0rCJwMswRw/l.SwHvuQV01coP0eWmGzd61QH2RvAOMANUBGC.';
70
76
71
77
if (password_verify('rasmuslerdorf', $hash)) {
72
78
echo 'Password is valid!';
...
...
@@ -90,15 +96,14 @@ Password is valid!
90
96
&reftitle.seealso;
91
97
<para>
92
98
<simplelist>
99
+
<member><function>password_needs_rehash</function></member>
93
100
<member><function>password_hash</function></member>
94
-
<member><link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="&url.password.compat;">userland implementation</link></member>
95
101
<member><function>sodium_crypto_pwhash_str_verify</function></member>
96
102
</simplelist>
97
103
</para>
98
104
</refsect1>
99
105
100
106
</refentry>
101
-
102
107
<!-- Keep this comment at the end of the file
103
108
Local variables:
104
109
mode: sgml
105
110