php password_hash and password_verify issues no match

Daniel

I am trying out a new function from PHP 5.5 called password_hash().

No matter what i do the $hash and the $password wont match.

$password = "test";

$hash = "$2y$10$fXJEsC0zWAR2tDrmlJgSaecbKyiEOK9GDCRKDReYM8gH2bG2mbO4e";



if (password_verify($password, $hash)) {
    echo "Success";
}
else {
    echo "Error";
}
initramfs

The problem with your code is that you are using the double quotation marks " instead of the single quotation marks ' when dealing with your hash.

When assigning:

$hash = "$2y$10$fXJEsC0zWAR2tDrmlJgSaecbKyiEOK9GDCRKDReYM8gH2bG2mbO4e";

It's making php think you have a variable called $2y and another one called $10 and finally a third one called $fXJEsC0zWAR2tDrmlJgSaecbKyiEOK9GDCRKDReYM8gH2bG2mbO4e. Which obviously isn't the case.

I noticed when turning on error reporting that the error:

Notice: Undefined variable: fXJEsC0zWAR2tDrmlJgSaecbKyiEOK9GDCRKDReYM8gH2bG2mbO4e

Was being thrown by PHP.

Replace all your double quote marks with single quote marks to fix.

E.g

$hash = '$2y$10$fXJEsC0zWAR2tDrmlJgSaecbKyiEOK9GDCRKDReYM8gH2bG2mbO4e';

Treats the whole hash as a literal string instead of a string with embedded variables.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

php password_hash and password_verify issues no match

From Dev

PHP password_hash(), password_verify()

From Dev

PHP password_hash and password_verify Not Working with MySQL

From Dev

Are PHP's password_hash and password_verify functions enough?

From Dev

Issues implementing password_hash in PHP

From Java

PHP can not login with correct password using password_hash()/password_verify()

From Dev

PHP password_verify()

From Dev

php password_hash and password_verify looked all over still doesn't work

From Dev

Is PHP password_hash() + password_verify() safe today (May 2016)?

From Dev

php password_hash and password_verify looked all over still doesn't work

From Dev

Using password_hash and password_verify from different objects in OO PHP

From Dev

Using password_hash and password_verify

From Dev

PHP - password_verify issue

From Dev

Using password_verify in PHP

From Dev

PHP Password_Hash Function

From Dev

password_verify can't verify password_hash with Bcrypt

From Java

How to use PHP's password_hash to hash and verify passwords

From Dev

password_hash and password_verify returns false

From Dev

password_verify in PHP not working using database

From Dev

PHP password_verify() not working with database

From Dev

PHP password_verify() and slow equals comparison

From Dev

How to use password_verify function in PHP

From Dev

PHP password_verify always returns false

From Dev

PHP password_verify returning false

From Dev

How to use password_verify function in PHP

From Dev

PHP: password_verify always returns false

From Dev

PHP password_verify not functioning with prepared statement

From Dev

password_hash equivalent for php 5.4?

From Dev

PHP password_hash Check Two Hashes

Related Related

HotTag

Archive