I am building a external application for which user login credentials will be taken from WordPress site database table 'users'
WordPress uses PHPass hashing , I am unable to validate username and password for my external application as the password in database table 'users'
is hashed
I am trying to check plain password with hashed password using wp_check_password
function but I am failing, nothing is written back with this code
<?php
$password = '965521425';
$hash = '$P$9jWFhEPMfI.KPByiNO9IyUzSTG7EZK0';
require_once('/home/nhtsoft/public_html/project/wp-includes/class-phpass.php');
function wp_check_password($password, $hash) {
global $wp_hasher;
if ( empty($wp_hasher) ) {
$wp_hasher = new PasswordHash(8, true);
}
$check = $wp_hasher->CheckPassword($password, $hash);
return apply_filters('check_password', $check, $password, $hash);
}
?>
this code is giving me an empty page.
How to check this password so that I can use these WordPress credentials for external app login?
you have passed wrong hash value , hash value for 965521425 is $P$BmI5G.LOoEx1iH.naNqVhWnSh5sMp31 and you just need to write below code into your file:
require_once($_SERVER['DOCUMENT_ROOT']."/wp-load.php");
$password = '965521425';
$hash = '$P$BmI5G.LOoEx1iH.naNqVhWnSh5sMp31';
var_dump(wp_check_password($password, $hash));
exit;