I try to use PHP's password_hash()
function with the PASSWORD_ARGON2I
algorithm, however, I get the following error message:
: Use of undefined constant PASSWORD_ARGON2I - assumed 'PASSWORD_ARGON2I' (this will throw an Error in a future version of PHP) in on line :在第行的使用未定义的常量 PASSWORD_ARGON2I - 假定为“PASSWORD_ARGON2I”(这将在 PHP 的未来版本中引发错误)
: password_hash() expects parameter 2 to be integer, string given in on line :password_hash() 期望参数 2 是整数,字符串在第行的给出
: 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 on line :未捕获的 PDOException:SQLSTATE[23000]:违反完整性约束:1048 列“密码”在 some-file.php:232 中不能为 null 堆栈跟踪:#0 some-file.php(232):PDOStatement->execute( ) #1 {main} 在第行的抛出
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.
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
after
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.