Comments (4)
Can you post your code? Without it is hard to determine what is going on, as I (and I gues lots of others), don't experience this problem.
from password_compat.
In one of my PHP files (processSignup.php) that involves storing the hashed password:
$password = $_POST['password'];
$password = $mysqli->real_escape_string($password);
$securePassword = password_hash($password, PASSWORD_BCRYPT);
then the $securePassword
variable is stored into a MySQL database with the following parameters in my prepared statement:
$statement = $mysqli->prepare("INSERT INTO users SET `username` = ?, `password` = ?, `email_address` = ?, `signup_ts` = ?, `isadmin` = ?");
$statement->bind_param('sssdd',$username, $securePassword, $email, time(), $defaultAdmin);
For the verification of password (loginProcess.php), which involves retrieving the hashed password and then verifying it with the password inputted for the specified user:
$password = $_POST['password'];
$password = $mysqli->real_escape_string($password);
$statement = $mysqli->prepare("SELECT userid, username, password, email_address, isadmin, isbanned FROM users WHERE `username`=?");
...
$statement->bind_result($a, $b, $c, $d, $e, $f);
while ($statement->fetch()) {
$user[] = ['userid' => $a, 'username' => $b, 'password' => $c, 'email_address' => $d, 'isadmin' => $e, 'isbanned' => $f];
}
$verifiedPassword = password_verify($password, $user['password']);
However, whenever I restart my PHP server, $verifiedPassword
always returns false, no matter when the password was hashed. The $user
array returns fine whenever I debug it through print($user);
Also, in my MySQL table, password
is a VARCHAR with 255 character length.
from password_compat.
$password = $mysqli->real_escape_string($password);
What's with that line? It might be the cause of your issues.
from password_compat.
Also, $user
is a 2-dimensional array, yet you're accessing it as a single-dimensional array. It should be something like $user[0]['password']
in the last line (assuming that you're correctly checking for errors and no-returns).
from password_compat.
Related Issues (20)
- password_verify fails for hashes from crypt() HOT 3
- mysqli_real_escape_string
- PASSWORD_ARGON2I Algo Support HOT 1
- Password verify issues HOT 1
- php7 Compatibility problem HOT 5
- PHPCompatibility ruleset for password_compat
- Trouble with PHP 5.6 & Password Verify HOT 1
- A HOT 1
- A
- Function not outputting the same hash as built-in function HOT 8
- Bcrypt issue HOT 1
- function_exists('PasswordCompat\\binary\\_strlen') needed? HOT 4
- password_hash("foo") returning false on 5.3.2-1ubuntu4.30 HOT 7
- Cannot verify the password after hashing HOT 1
- Suggestion: use *.phpt tests from php-src to improve compatibility
- Problem with verifiying the hashed password HOT 3
- Using the project on a newer version of PHP HOT 2
- This Repo HOT 7
- use password_compact in codeigniter HOT 2
- This lib on php 5.5 HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from password_compat.