reference/password/functions/password-verify.xml
ba9021d03c30d208158471c45dc83613e3159edf
...
...
@@ -16,6 +16,9 @@
16
16
</methodsynopsis>
17
17
<para>
18
18
Verifies that the given hash matches the given password.
19
+
<function>password_verify</function> is compatible with <function>crypt</function>.
20
+
Therefore, password hashes created by <function>crypt</function> can be used with
21
+
<function>password_verify</function>.
19
22
</para>
20
23
<para>
21
24
Note that <function>password_hash</function> returns the algorithm, cost and salt
...
...
@@ -62,11 +65,15 @@
62
65
<para>
63
66
<example>
64
67
<title><function>password_verify</function> example</title>
68
+
<para>
69
+
This is a simplified example; it is recommended to rehash a correct password
70
+
if necessary; see <function>password_needs_rehash</function> for an example.
71
+
</para>
65
72
<programlisting role="php">
66
73
<![CDATA[
67
74
<?php
68
75
// See the password_hash() example to see where this came from.
69
-
$hash = '$2y$07$BCryptRequires22Chrcte/VlQH0piJtjXl.0t1XkA8pw9dMXTpOq';
76
+
$hash = '$2y$10$.vGA1O9wmRjrwAVXD98HNOgsNpDczlqm3Jq7KnEd1rVAGv3Fykk1a';
70
77

71
78
if (password_verify('rasmuslerdorf', $hash)) {
72
79
echo 'Password is valid!';
...
...
@@ -90,6 +97,7 @@ Password is valid!
90
97
&reftitle.seealso;
91
98
<para>
92
99
<simplelist>
100
+
<member><function>password_needs_rehash</function></member>
93
101
<member><function>password_hash</function></member>
94
102
<member><link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="&url.password.compat;">userland implementation</link></member>
95
103
<member><function>sodium_crypto_pwhash_str_verify</function></member>
96
104