Laravel6 - How to check current password with hash password in laravel

In this article we will share with you how to check your current password string with laravel's hash generated password help of hash::check() function. we know laravel store password in hash formate so password not seen in readable formate. so, how to check any string with that hash converted laravel's password string?

Many times you need to compare any password string with laravel's olds password hash string. this is needed when we built password change functionality in an application. before changes password, we want to check the user put the string in the input box that is matched with his/her old password string?

You can be done it help of Hash::check() function in your laravel application.


public function changePassword(Request $request)
    $input = $request->all();
    $user = User::find(auth()->user()->id);
    // Check password string with hash string..
    if(!Hash::check($input['current_password'], $user->password)) {
        dd('Return error with current passowrd is not match.');
        dd('Write here your update password code');

As you can see, how to check your current password string with your old one laravel's hash password in your laravel application help of Hash::check() function.

We hope that small tutorials help everyone. if you have known more ways to check the current password with an old password in laravel or any issues or questions related to these tutorials so please comment below. Thanks.