Reputation: 710
I try to use PHP's password_hash()
function with the PASSWORD_ARGON2I
algorithm, however, I get the following error message:
Warning: Use of undefined constant PASSWORD_ARGON2I - assumed 'PASSWORD_ARGON2I' (this will throw an Error in a future version of PHP) in some-file.php on line 181
Warning: password_hash() expects parameter 2 to be integer, string given in some-file.php on line 192
Fatal error: Uncaught PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'password' cannot be null in some-file.php:232 Stack trace: #0 some-file.php(232): PDOStatement->execute() #1 {main} thrown in some-file.php on line 232
I followed the official documentation of the function word by word, but I still faced this error.
Then I made some research and I figured out that "PHP should be compiled using –with-password-argon2
" (where they refer to this file).
I have no idea how to do this and I could not find any page which would guide me through the steps or provide me more info.
The hashing function works perfectly with PASSWORD_DEFAULT
, but that is not what I need at the moment.
Upvotes: 2
Views: 4282
Reputation: 710
I did not know but OSX comes with pre-installed PHP. I had a very early version so I needed to upgrade it in order to make Argon2 algorithm work. When I checked my version by php --version
in the command line, I got the following result:
PHP 5.6.30 (cli) (built: Oct 29 2017 20:30:32)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
So I followed through this guide but I also had to install Argon2 library (which was not mentioned) and use ./configure —with-password-argon2
. So here are the steps which solved my problem based on this guide:
brew install libjpeg
, brew install pcre
, brew install libxml2
, etc. in the command line)./configure —with-password-argon2
make test
in the command line (time-consuming process, feel free to drink a beer meanwhile)sudo make install
afterUpvotes: 10