From 28ebb20500de0753d6eac1408ae107fe345fc78e Mon Sep 17 00:00:00 2001 From: Anthony Ferrara Date: Mon, 2 Mar 2015 22:50:57 +0000 Subject: [PATCH] Add example for password_needs_rehash to documentation. git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@336027 c90b9560-bf6c-de11-be94-00142212c4b1 --- .../functions/password-needs-rehash.xml | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/reference/password/functions/password-needs-rehash.xml b/reference/password/functions/password-needs-rehash.xml index 860758a4a4..9a4f173b2e 100644 --- a/reference/password/functions/password-needs-rehash.xml +++ b/reference/password/functions/password-needs-rehash.xml @@ -51,6 +51,40 @@ + + + &reftitle.examples; + + + Example #1 <function>password_needs_rehash()</function> example + + 11); + +// Verify stored hash against plain-text password +if (password_verify($password, $hash)) { + // Check if a newer hashing algorithm is available + // or the cost has changed + if (password_needs_rehash($hash, PASSWORD_DEFAULT, $options)) { + // If so, create a new hash, and replace the old one + $newHash = password_hash($password, PASSWORD_DEFAULT, $options); + } + + // Log user in +} +?> +]]> + + &example.outputs.similar; + + + &reftitle.returnvalues;