
- PHP Tutorial
- PHP - Home
- PHP - Introduction
- PHP - Environment Setup
- PHP - Syntax Overview
- PHP - Variable Types
- PHP - Constants
- PHP - Operator Types
- PHP - Decision Making
- PHP - Loop Types
- PHP - Arrays
- PHP - Strings
- PHP - Web Concepts
- PHP - GET & POST
- PHP - File Inclusion
- PHP - Files & I/O
- PHP - Functions
- PHP - Cookies
- PHP - Sessions
- PHP - Sending Emails
- PHP - File Uploading
- PHP - Coding Standard
- Advanced PHP
- PHP - Predefined Variables
- PHP - Regular Expression
- PHP - Error Handling
- PHP - Bugs Debugging
- PHP - Date & Time
- PHP & MySQL
- PHP & AJAX
- PHP & XML
- PHP - Object Oriented
- PHP - For C Developers
- PHP - For PERL Developers
- PHP Form Examples
- PHP - Form Introduction
- PHP - Validation Example
- PHP - Complete Form
- PHP login Examples
- PHP - Login Example
- PHP - Facebook Login
- PHP - Paypal Integration
- PHP - MySQL Login
- PHP AJAX Examples
- PHP - AJAX Search
- PHP - AJAX XML Parser
- PHP - AJAX Auto Complete Search
- PHP - AJAX RSS Feed Example
- PHP XML Example
- PHP - XML Introduction
- PHP - Simple XML
- PHP - Simple XML GET
- PHP - SAX Parser Example
- PHP - DOM Parser Example
- PHP Frame Works
- PHP - Frame Works
- PHP - Core PHP vs Frame Works
- PHP Design Patterns
- PHP - Design Patterns
- PHP Function Reference
- PHP - Built-In Functions
- PHP Useful Resources
- PHP - Questions & Answers
- PHP - Useful Resources
- PHP - Discussion
PHP - password_needs_rehash() Function
The password_needs_rehash() function can check if the given hash matches the given options.
Syntax
boolean password_needs_rehash ( string $hash , integer $algo [, array $options ] )
The password_needs_rehash() function can check to see if the supplied hash implements the algorithm and options provided. If not, it's assumed that the hash needs to rehash.
The password_needs_rehash() function can return true if the hash can be rehashed to match the given algo and options or false otherwise.
Example
<?php $passw01 = "53nh46u74m3nt3"; $hashp03 = '$argon2i$v=19$m=1024,t=2,p=2$d1JJWnNHMkVEekZwcTFUdA$zeSi7c/Adh/1KCTHddoF39Xxwo9ystxRzHEnRa0lQeM'; $algo03 = PASSWORD_ARGON2I; $test03 = password_verify($passw01, $hashp03); $conf03 = password_needs_rehash($hashp03, $algo03); if($conf03 == true) { echo "HASH NEEDS TO BE REHASHED!<br>SUGGESTED FOR THE NEW HASH:<br>"; $nwhas03 = password_hash($passw01, $algo03); echo $nwhas03; } else { echo "HASH DOES HAS NO NEED TO BE REHASHED!<br>"; echo $hashp03; $getinfo03 = password_get_info($hashp03); echo "<br><br>algo = " . $getinfo03["algo"] . "<br>algoName = " . $getinfo03["algoName"] . "<br>memory_cost = " . $getinfo03["options"]["memory_cost"] . "<br>time_cost = " . $getinfo03["options"]["time_cost"] . "<br>threds = " . $getinfo03["options"]["threads"] . "<br><br>"; } ?>
Output
HASH NEEDS TO BE REHASHED!<br>SUGGESTED FOR THE NEW HASH:<br>$argon2i$v=19$m=65536,t=4,p=1$dDVDRWFFTS9ObjFQMmhuRw$1uWmsNTQBbrwXtQPB7PQqWWIlcd0XBqg2mEDHGaElew
php_function_reference.htm
Advertisements