Check WordPress hashed password with plain password

人走茶凉 提交于 2019-12-05 17:17:53

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;

i would simply do this <?php wp_check_password( $password, $hash, $user_id ) ?> Refer

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.

                $password_hashed = '$P$Bgf2Hpr5pOVOYAvQZUhUZeLIi/QuPr1';
                $plain_password = '123456';
                if ((wp_check_password($plain_password, $password_hashed)) == 1) {
                    echo "YES, Matched";
                } else {
                    echo "No, Wrong Password";
                }

Try this...

I work's fine for me

require_once( ABSPATH . WPINC . '/class-phpass.php');
$wp_hasher = new PasswordHash(8, TRUE);
$plain_password     = trim($_POST['pass_current']); //user type password
$user               = get_user_by('id', get_current_user_id());
$password_hashed    =  $user->user_pass;

if($wp_hasher->CheckPassword($plain_password, $password_hashed)) {
     echo "YES, Matched";
}else{
    echo "No, Wrong Password";
}

what Bhumi Shah wrote is correct you should add

require_once($_SERVER['DOCUMENT_ROOT']."/wp-load.php");

to your code .

but hashed value for any password(number or text) is not one solid thing , it could be many things that's why they can be compared only with wp_check_password

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!