P
P
photosho2016-01-08 16:18:12
Laravel
photosho, 2016-01-08 16:18:12

How to verify the password during authorization?

Hello. The question is this: when registering a user, I hash the password with the "bcrypt" function, and when authorizing it, I also hash the password entered by him (in the authorization form) and compare it with the value that was saved to the database during registration. With exactly the same passwords, "bcrypt" produces different values.
Even more so, if you call "bcrypt" twice in a row on the same string, it will return different values. That being said, I've seen that standard logging also uses "bcrypt" to hash passwords. How to get around such a problem?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dinar Garipov, 2016-01-08
@photosho

Or for example
Hash::check('secret', $hashedPassword)

A
ajaxtelamonid, 2016-01-08
@ajaxtelamonid

The fact that each time the hash is different from the same password is a feature of bcrypt.
You can verify the password using the password_verify() function: www.php.net/manual/en/function.password-verify.php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question