-2

I am learning php and was trying this php function but for some reason it isn't working despite trying all the answers here. I hashed 'b' using password_hash function and tried to verify it. Here is my code

if(password_verify('b', 
'$2y$10$OCZvoaVXX00xBkwpfGfgOu9AGXutvcZkhvpqSVWpL6v.BNnLsAN4u')){
echo "valid";
}else{
echo "invalid";
}
Dharman
  • 30,962
  • 25
  • 85
  • 135
Ayush
  • 1

1 Answers1

3

That's a hash of an empty string:

$hash = '$2y$10$OCZvoaVXX00xBkwpfGfgOu9AGXutvcZkhvpqSVWpL6v.BNnLsAN4u';
var_dump(password_verify('', $hash));

bool(true)

Find out where you're getting the input and work back from there, because it definitely isn't b.

iainn
  • 16,826
  • 9
  • 33
  • 40
  • Thanks. You are right. I accidentally ended up hashing empty string that day. I realized that much later. Again thanks for your time. – Ayush Feb 20 '19 at 05:26