We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Hash generating a different hash for same password

Hello, If i use

$password = '123456'; $this->security->hash($password);

I get a different hash everytime, i don't understand this...is this a bug?



93.7k
Accepted
answer

No, its intended. You have to use checkHash() method in order to compare passwords.

$this->security->checkHash($this->request->getPost('password'), $dbPasswordHere)


4.5k
edited Aug '16

I used checkHash() and it keeps sending false even wtih the right password

Edit : Ok problem solved, should use

$this->security->checkHash($this->request->getPost('password'), $dbPasswordHere) and not

$this->security->checkHash($dbPasswordHere, $this->request->getPost('password'))

Inverted the parameters thinking it doesn't matter..