Check WordPress hashed password with plain password
Solution 1
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;
Solution 2
In your code, you include the wp library and it looks like you redefine a function named wp_check_password
but you do not call any function at all. Add the following line before the closing php tag ("?>") and try again.
echo (wp_check_password($password, $hash) ? 'TRUE' : 'FALSE');
Keep an eye on the error logs in case you miss some dependencies.
Solution 3
i would simply do this <?php wp_check_password( $password, $hash, $user_id ) ?>
Refer
Related videos on Youtube
ManojGeek
Updated on May 25, 2022Comments
-
ManojGeek almost 2 years
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 hashedI 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?
-
ManojGeek over 10 yearswordpress will not use only md5 hashing. . . . @user2092317
-
-
ManojGeek over 10 yearsi have already tried this. . . and here nothing to do with $user_id
-
Bhumi Shah over 10 yearsyeah,i got output , you can place code into functions.php and var_dump(wp_check_password($password, $hash); exit; and check it.
-
ManojGeek over 10 yearsas i need this to be implemented in external application not releated to wordpress, i have included class-phpass.php file and wrote the above code. . . sorry but i didnt get you, where to place the code. . .can u please tell me in detail. . .
-
Bhumi Shah over 10 yearsif you are using external file, you need to load wp-load.php file. see code i have edited above.
-
ManojGeek over 10 yearsSuperb. . .Thankyou so much @Bhumi